Skip to content

Commit

Permalink
Removed unused variable "inspected_file_count"
Browse files Browse the repository at this point in the history
Variable "inspected_file_count" in the result of the linters has been removed due to missing use. It was not used in the pull request comment describing the offenses detected by linters in the source code.
  • Loading branch information
europ committed Apr 9, 2018
1 parent fa2a5ff commit 8a2a68a
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 32 deletions.
12 changes: 5 additions & 7 deletions app/workers/concerns/code_analysis_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ def merged_linter_results
results = {
"files" => [],
"summary" => {
"inspected_file_count" => 0,
"offense_count" => 0,
"target_file_count" => 0,
"offense_count" => 0,
"target_file_count" => 0,
},
}

run_all_linters.each do |result|
%w(offense_count target_file_count inspected_file_count).each do |m|
%w(offense_count target_file_count).each do |m|
results['summary'][m] += result['summary'][m]
end
results['files'] += result['files']
Expand Down Expand Up @@ -70,9 +69,8 @@ def run_all_linters
end

output["summary"] = {
"offense_count" => output["files"].sum { |item| item['offenses'].length },
"target_file_count" => output["files"].length,
"inspected_file_count" => 0 # TODO: value cannot be obtained from the result of `pronto_result` method
"offense_count" => output["files"].sum { |item| item['offenses'].length },
"target_file_count" => output["files"].length,
}

output
Expand Down
2 changes: 1 addition & 1 deletion spec/support/rubocop_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def rubocop_results
rubocop = JSON.parse(`rubocop --format=json --no-display-cop-names #{rubocop_check_path}`)
hamllint = JSON.parse(`haml-lint --reporter=json #{rubocop_check_path}`)

%w(offense_count target_file_count inspected_file_count).each do |m|
%w(offense_count target_file_count).each do |m|
rubocop['summary'][m] += hamllint['summary'][m]
end
rubocop['files'] += hamllint['files']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
],
"summary": {
"offense_count": 1,
"target_file_count": 1,
"inspected_file_count": 1
"target_file_count": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
],
"summary": {
"offense_count": 3,
"target_file_count": 1,
"inspected_file_count": 1
"target_file_count": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,6 @@
],
"summary": {
"offense_count": 292,
"target_file_count": 1,
"inspected_file_count": 1
"target_file_count": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
],
"summary": {
"offense_count": 0,
"target_file_count": 1,
"inspected_file_count": 1
"target_file_count": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
],
"summary": {
"offense_count": 4,
"target_file_count": 4,
"inspected_file_count": 4
"target_file_count": 4
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
],
"summary": {
"offense_count": 1,
"target_file_count": 1,
"inspected_file_count": 1
"target_file_count": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
],
"summary": {
"offense_count": 3,
"target_file_count": 3,
"inspected_file_count": 3
"target_file_count": 3
}
}
17 changes: 7 additions & 10 deletions spec/workers/concerns/code_analysis_mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
describe "#merged_linter_results" do
it "should always return a hash with a 'files' and 'summary' key, even with no cops running" do
allow(subject).to receive(:pronto_result).and_return([])
expect(subject.merged_linter_results).to eq("files" => [], "summary" => {"inspected_file_count" => 0, "offense_count" => 0, "target_file_count" => 0})
expect(subject.merged_linter_results).to eq("files" => [], "summary" => {"offense_count" => 0, "target_file_count" => 0})
end
end

Expand Down Expand Up @@ -55,9 +55,8 @@
],
"summary" =>
{
"offense_count" => input.group_by(&:runner).values[0].count,
"target_file_count" => input.group_by(&:runner).values[0].group_by(&:path).count,
"inspected_file_count" => 0
"offense_count" => input.group_by(&:runner).values[0].count,
"target_file_count" => input.group_by(&:runner).values[0].group_by(&:path).count
}
},
{
Expand All @@ -79,9 +78,8 @@
],
"summary" =>
{
"offense_count" => input.group_by(&:runner).values[1].count,
"target_file_count" => input.group_by(&:runner).values[1].group_by(&:path).count,
"inspected_file_count" => 0
"offense_count" => input.group_by(&:runner).values[1].count,
"target_file_count" => input.group_by(&:runner).values[1].group_by(&:path).count
}
},
{
Expand All @@ -103,9 +101,8 @@
],
"summary" =>
{
"offense_count" => input.group_by(&:runner).values[2].count,
"target_file_count" => input.group_by(&:runner).values[2].group_by(&:path).count,
"inspected_file_count" => 0
"offense_count" => input.group_by(&:runner).values[2].count,
"target_file_count" => input.group_by(&:runner).values[2].group_by(&:path).count
}
}
]
Expand Down

0 comments on commit 8a2a68a

Please sign in to comment.