Skip to content

Don't report all errors on each file analyzed #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

task default: :spec
18 changes: 11 additions & 7 deletions lib/cc/engine/csslint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@ def run
Dir.chdir(@directory) do
results.xpath('//file').each do |file|
path = file['name'].sub(/\A#{@directory}\//, '')
file.xpath('//error').each do |lint|
file.children.each do |node|
next unless node.name == "error"

lint = node.attributes

issue = {
type: "issue",
check_name: lint["source"],
description: lint["message"],
check_name: lint["source"].value,
description: lint["message"].value,
categories: ["Style"],
remediation_points: 500,
location: {
path: path,
positions: {
begin: {
line: lint["line"].to_i,
column: lint["column"].to_i
line: lint["line"].value.to_i,
column: lint["column"].value.to_i
},
end: {
line: lint["line"].to_i,
column: lint["column"].to_i
line: lint["line"].value.to_i,
column: lint["column"].value.to_i
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions spec/cc/engine/csslint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ module Engine
expect{ lint.run }.to_not output.to_stdout
end

it "only reports issues in the file where they're present" do
create_source_file('bad.css', id_selector_content)
create_source_file('good.css', '.foo { margin: 0 }')
expect{ lint.run }.not_to output(/good\.css/).to_stdout
end

describe "with exclude_paths" do
let(:engine_config) { {"exclude_paths" => %w(excluded.css)} }

Expand Down