Skip to content

Commit 74816a2

Browse files
author
ABaldwinHunter
committed
Clean up Code Climate rubocop style issues
1 parent 8e69e2a commit 74816a2

File tree

7 files changed

+24
-30
lines changed

7 files changed

+24
-30
lines changed

bin/cc-tddium-post-worker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if ENV["CODECLIMATE_REPO_TOKEN"]
77
tmpdir = Dir.tmpdir
88
puts "Searching #{tmpdir} for files to POST."
99
coverage_report_files = Dir.glob("#{tmpdir}/codeclimate-test-coverage-*")
10-
if coverage_report_files.size > 0
10+
if coverage_report_files.any?
1111
puts "Found: "
1212
puts coverage_report_files.join("\n")
1313
client = CodeClimate::TestReporter::Client.new

lib/code_climate/test_reporter/calculate_blob.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module CodeClimate
22
module TestReporter
33
class CalculateBlob
4-
54
def initialize(file_path)
65
@file_path = file_path
76
end
@@ -10,7 +9,7 @@ def blob_id
109
calculate_with_file or calculate_with_git
1110
end
1211

13-
private
12+
private
1413

1514
def calculate_with_file
1615
File.open(@file_path, "rb") do |file|
@@ -31,7 +30,6 @@ def calculate_with_git
3130

3231
output
3332
end
34-
3533
end
3634
end
3735
end

lib/code_climate/test_reporter/client.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
module CodeClimate
66
module TestReporter
77
class Client
8-
98
DEFAULT_TIMEOUT = 5 # in seconds
10-
USER_AGENT = "Code Climate (Ruby Test Reporter v#{VERSION})"
9+
USER_AGENT = "Code Climate (Ruby Test Reporter v#{VERSION})".freeze
1110

1211
def host
1312
ENV["CODECLIMATE_API_HOST"] ||
@@ -72,7 +71,7 @@ def post_results(result)
7271
end
7372
end
7473

75-
private
74+
private
7675

7776
def http_client(uri)
7877
Net::HTTP.new(uri.host, uri.port).tap do |http|

lib/code_climate/test_reporter/exception_message.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ def library_name
66
end
77

88
def instructions
9-
<<-STR
9+
<<-STR
1010
WebMock.disable_net_connect!(:allow => "codeclimate.com")
11-
STR
11+
STR
1212
end
1313
end
1414

@@ -18,21 +18,20 @@ def library_name
1818
end
1919

2020
def instructions
21-
<<-STR
21+
<<-STR
2222
VCR.configure do |config|
2323
# your existing configuration
2424
config.ignore_hosts 'codeclimate.com'
2525
end
26-
STR
26+
STR
2727
end
2828
end
2929

3030
class ExceptionMessage
31-
3231
HTTP_STUBBING_MESSAGES = {
33-
"VCR::Errors::UnhandledHTTPRequestError" => VCRMessage,
34-
"WebMock::NetConnectNotAllowedError" => WebMockMessage
35-
}
32+
"VCR::Errors::UnhandledHTTPRequestError".freeze => VCRMessage,
33+
"WebMock::NetConnectNotAllowedError".freeze => WebMockMessage,
34+
}.freeze
3635

3736
def initialize(exception)
3837
@exception = exception
@@ -59,7 +58,7 @@ def message
5958
parts.join("\n")
6059
end
6160

62-
private
61+
private
6362

6463
def exception_class
6564
@exception.class.to_s

lib/code_climate/test_reporter/formatter.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def format(result)
3939
# actually private ...
4040
def short_filename(filename)
4141
return filename unless ::SimpleCov.root
42-
filename = filename.gsub(/^#{::SimpleCov.root}/, ".").gsub(/^\.\//, "")
42+
filename = filename.gsub(/^#{::SimpleCov.root}/, ".").gsub(%r{^\./}, "")
4343
apply_prefix filename
4444
end
4545

46-
private
46+
private
4747

4848
def partial?
4949
tddium?
@@ -70,8 +70,8 @@ def to_payload(result)
7070
line_counts: {
7171
total: file.lines.count,
7272
covered: file.covered_lines.count,
73-
missed: file.missed_lines.count
74-
}
73+
missed: file.missed_lines.count,
74+
},
7575
}
7676
end
7777

@@ -89,9 +89,9 @@ def to_payload(result)
8989
pwd: Dir.pwd,
9090
rails_root: (Rails.root.to_s rescue nil),
9191
simplecov_root: ::SimpleCov.root,
92-
gem_version: VERSION
92+
gem_version: VERSION,
9393
},
94-
ci_service: ci_service_data
94+
ci_service: ci_service_data,
9595
}
9696
end
9797

@@ -110,7 +110,7 @@ def write_to_file?
110110
tddium? || ENV["CODECLIMATE_TO_FILE"] || ENV["TO_FILE"]
111111
end
112112

113-
def apply_prefix filename
113+
def apply_prefix(filename)
114114
prefix = CodeClimate::TestReporter.configuration.path_prefix
115115
return filename if prefix.nil?
116116
"#{prefix}/#{filename}"

lib/code_climate/test_reporter/git.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module CodeClimate
22
module TestReporter
33
class Git
4-
54
class << self
65
def info
76
{
@@ -17,16 +16,16 @@ def branch_from_git_or_ci
1716

1817
def clean_service_branch
1918
ci_branch = String(Ci.service_data[:branch])
20-
clean = ci_branch.strip.sub(/^origin\//, "")
19+
clean = ci_branch.strip.sub(%r{^origin/}, "")
2120

22-
clean.size > 0 ? clean : nil
21+
!clean.empty? ? clean : nil
2322
end
2423

2524
def clean_git_branch
2625
git_branch = String(branch_from_git)
27-
clean = git_branch.sub(/^origin\//, "") unless git_branch.start_with?("(")
26+
clean = git_branch.sub(%r{^origin/}, "") unless git_branch.start_with?("(")
2827

29-
clean.size > 0 ? clean : nil
28+
!clean.empty? ? clean : nil
3029
end
3130

3231
private
@@ -65,4 +64,3 @@ def rails_git_dir_present?
6564
end
6665
end
6766
end
68-

lib/code_climate/test_reporter/payload_validator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def validate
2020
true
2121
end
2222

23-
private
23+
private
2424

2525
def commit_sha
2626
commit_sha_from_git || commit_sha_from_ci_service

0 commit comments

Comments
 (0)