File tree
Expand file treeCollapse file tree4 files changed
+9
-3
lines changed Expand file treeCollapse file tree4 files changed
+9
-3
lines changed Original file line number | Diff line number | Diff line change |
---|
|
4 | 4 | docker build -t codeclimate/codeclimate-csslint .
|
5 | 5 |
|
6 | 6 | test: image
|
7 |
| -docker run --rm codeclimate/codeclimate-csslint rake |
| 7 | +docker run --rm codeclimate/codeclimate-csslint rspec $(RSPEC_ARGS) |
Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | require "json"
|
2 | 2 | require "nokogiri"
|
| 3 | +require "ostruct" |
3 | 4 | require "shellwords"
|
4 | 5 |
|
5 | 6 | module CC
|
6 | 7 | module Engine
|
7 | 8 | MissingAttributesError = Class.new(StandardError)
|
8 | 9 |
|
| 10 | +DEFAULT_IDENTIFIER = OpenStruct.new(value: "parse-error") |
| 11 | + |
9 | 12 | class CSSlint
|
10 | 13 | autoload :CheckDetails, "cc/engine/csslint/check_details"
|
11 | 14 |
|
@@ -30,8 +33,9 @@ def run
|
30 | 33 |
|
31 | 34 | private
|
32 | 35 |
|
| 36 | +# rubocop:disable Metrics/MethodLength |
33 | 37 | def create_issue(node, path)
|
34 |
| -check_name = node.attributes.fetch("identifier").value |
| 38 | +check_name = node.attributes.fetch("identifier", DEFAULT_IDENTIFIER).value |
35 | 39 | check_details = CheckDetails.fetch(check_name)
|
36 | 40 |
|
37 | 41 | {
|
@@ -57,6 +61,7 @@ def create_issue(node, path)
|
57 | 61 | rescue KeyError => ex
|
58 | 62 | raise MissingAttributesError, "#{ex.message} on XML '#{node}' when analyzing file '#{path}'"
|
59 | 63 | end
|
| 64 | +# rubocop:enable Metrics/MethodLength |
60 | 65 |
|
61 | 66 | def results
|
62 | 67 | @results ||= Nokogiri::XML(csslint_xml)
|
|
Original file line number | Diff line number | Diff line change |
---|
@@ -19,6 +19,7 @@ class CheckDetails
|
19 | 19 | "import" => { categories: "Bug Risk" },
|
20 | 20 | "known-properties" => { categories: "Bug Risk" },
|
21 | 21 | "overqualified-elements" => { categories: "Bug Risk" },
|
| 22 | +"parse-error" => { categories: "Bug Risk" }, |
22 | 23 | "regex-selectors" => { categories: "Bug Risk" },
|
23 | 24 | "shorthand" => { categories: "Bug Risk" },
|
24 | 25 | "star-property-hack" => { categories: "Compatibility" },
|
|
Original file line number | Diff line number | Diff line change |
---|
@@ -18,7 +18,7 @@ module Engine
|
18 | 18 |
|
19 | 19 | it 'fails on malformed file' do
|
20 | 20 | create_source_file('foo.css', '�6�')
|
21 |
| -expect{ lint.run }.to raise_error(MissingAttributesError) |
| 21 | +expect{ lint.run }.to output(/Unexpected token/).to_stdout |
22 | 22 | end
|
23 | 23 |
|
24 | 24 | it "doesn't analyze *.scss files" do
|
|
You can’t perform that action at this time.
0 commit comments