Merged
Show file tree
Hide file tree
Changes from all commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
require "json"
require "nokogiri"
require "ostruct"
require "shellwords"

module CC
module Engine
MissingAttributesError = Class.new(StandardError)

DEFAULT_IDENTIFIER = OpenStruct.new(value: "parse-error")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nifty


class CSSlint
autoload :CheckDetails, "cc/engine/csslint/check_details"

Expand All@@ -30,8 +33,9 @@ def run

private

# rubocop:disable Metrics/MethodLength
def create_issue(node, path)
check_name = node.attributes.fetch("identifier").value
check_name = node.attributes.fetch("identifier", DEFAULT_IDENTIFIER).value
check_details = CheckDetails.fetch(check_name)

{
Expand All@@ -57,6 +61,7 @@ def create_issue(node, path)
rescue KeyError => ex
raise MissingAttributesError, "#{ex.message} on XML '#{node}' when analyzing file '#{path}'"
end
# rubocop:enable Metrics/MethodLength

def results
@results ||= Nokogiri::XML(csslint_xml)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ module Engine

it 'fails on malformed file' do
create_source_file('foo.css', '�6�')
expect{ lint.run }.to raise_error(MissingAttributesError)
expect{ lint.run }.to output(/Unexpected token/).to_stdout
end

it "doesn't analyze *.scss files" do
Expand Down