diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..8281788 --- /dev/null +++ b/Rakefile @@ -0,0 +1,5 @@ +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new(:spec) + +task default: :spec diff --git a/lib/cc/engine/csslint.rb b/lib/cc/engine/csslint.rb index d89da9d..0614c7a 100644 --- a/lib/cc/engine/csslint.rb +++ b/lib/cc/engine/csslint.rb @@ -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 } } } diff --git a/spec/cc/engine/csslint_spec.rb b/spec/cc/engine/csslint_spec.rb index 7a12bff..e1fc37b 100644 --- a/spec/cc/engine/csslint_spec.rb +++ b/spec/cc/engine/csslint_spec.rb @@ -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)} }