Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 84a4bc9

Browse files
committed
Merge pull request #18 from codeclimate/pb-fix-egregious-bug
Don't report all errors on each file analyzed
2 parents 18ad61b + e7aff4f commit 84a4bc9

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

Rakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require "rspec/core/rake_task"
2+
3+
RSpec::Core::RakeTask.new(:spec)
4+
5+
task default: :spec

lib/cc/engine/csslint.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,27 @@ def run
1414
Dir.chdir(@directory) do
1515
results.xpath('//file').each do |file|
1616
path = file['name'].sub(/\A#{@directory}\//, '')
17-
file.xpath('//error').each do |lint|
17+
file.children.each do |node|
18+
next unless node.name == "error"
19+
20+
lint = node.attributes
21+
1822
issue = {
1923
type: "issue",
20-
check_name: lint["source"],
21-
description: lint["message"],
24+
check_name: lint["source"].value,
25+
description: lint["message"].value,
2226
categories: ["Style"],
2327
remediation_points: 500,
2428
location: {
2529
path: path,
2630
positions: {
2731
begin: {
28-
line: lint["line"].to_i,
29-
column: lint["column"].to_i
32+
line: lint["line"].value.to_i,
33+
column: lint["column"].value.to_i
3034
},
3135
end: {
32-
line: lint["line"].to_i,
33-
column: lint["column"].to_i
36+
line: lint["line"].value.to_i,
37+
column: lint["column"].value.to_i
3438
}
3539
}
3640
}

spec/cc/engine/csslint_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ module Engine
2222
expect{ lint.run }.to_not output.to_stdout
2323
end
2424

25+
it "only reports issues in the file where they're present" do
26+
create_source_file('bad.css', id_selector_content)
27+
create_source_file('good.css', '.foo { margin: 0 }')
28+
expect{ lint.run }.not_to output(/good\.css/).to_stdout
29+
end
30+
2531
describe "with exclude_paths" do
2632
let(:engine_config) { {"exclude_paths" => %w(excluded.css)} }
2733

0 commit comments

Comments
 (0)