Skip to content

Commit

Permalink
Adjust for 0.5.0
Browse files Browse the repository at this point in the history
0.5.0 also introduced a JSON formatter, which would make our lives
easier. Just deferring biting that off because it's nice out.
  • Loading branch information
maxjacobson committed Jun 21, 2019
1 parent 481d8f1 commit 5e40e8c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/cc/engine/markdownlint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Markdownlint
CONFIG_FILE = "./.mdlrc".freeze
EXTENSIONS = %w[.markdown .md].freeze
UnexpectedOutputFormat = Class.new(StandardError)
LINES_TO_SKIP = [
"\n".freeze,
"A detailed description of the rules is available at https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md\n".freeze,
].freeze

def initialize(root, engine_config, io, err_io)
@root = root
Expand All @@ -29,8 +33,10 @@ def run
end

out.each_line do |line|
io.print JSON.dump(issue(line))
io.print "\0"
if (details = issue(line))
io.print JSON.dump(details)
io.print "\0"
end
end
end

Expand All @@ -55,6 +61,7 @@ def mdl_options
ISSUE_PATTERN = /(?<path>.*):(?<line_number>\d+): (?<code>MD\d+) (?<description>.*)/

def issue(line)
return if LINES_TO_SKIP.include?(line)
match_data = line.match(ISSUE_PATTERN) or raise UnexpectedOutputFormat, line
line_number = match_data[:line_number].to_i
path = match_data[:path]
Expand Down

0 comments on commit 5e40e8c

Please sign in to comment.