Skip to content
Open
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
1 change: 1 addition & 0 deletions lib/cuke_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

require 'cuke_linter/version'
require 'cuke_linter/formatters/pretty_formatter'
require 'cuke_linter/formatters/pylint_formatter'
require 'cuke_linter/linters/linter'
require 'cuke_linter/linters/background_does_more_than_setup_linter'
require 'cuke_linter/linters/element_with_common_tags_linter'
Expand Down
20 changes: 20 additions & 0 deletions lib/cuke_linter/formatters/pylint_formatter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module CukeLinter
# Formats linting data into the PyLint format
# path/to/file:line:col: [Rule] Message
class PylintFormatter
# Formats the given linting data
def format(data)
''.tap do |formatted_data|
data.each do |problem|
location = problem[:location].split(":")
# Linters at the very least don't specify column numbers, but for feature file wide errors
# there's no line numbers either. Pad the location out if we need to.
while location.length() < 3
location.insert(-1, "")
end
formatted_data << "#{location.join(separator=':')}: [#{problem[:linter]}] #{problem[:problem]}\n"
end
end
end
end
end
19 changes: 19 additions & 0 deletions testing/cucumber/features/formatters/pylint_formatter.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Pylint formatter

The Pylint formatter is a formatter with a more easily machine-parseable output.

Scenario: Formatting linter data
Given the following linter data:
| linter name | problem | location |
| FeatureFileWithInvalidNameLinter | Invalid file name | path/to/the-file |
| FeatureWithoutDescriptionLinter | No description | path/to/the_file:1 |
| SomeOtherLinter | Some other problem | path/to/the_file:33 |
| SomeOtherLinter | Problem with column | path/to/the_file:33:33 |
When it is formatted by the "Pylint" formatter
Then the resulting output is the following:
"""
path/to/the/file::: [FeatureFileWithInvalidNameLinter] Invalid file name
path/to/the_file:1:: [FeatureWithoutDescriptionLinter] No description
path/to/the_file:33:: [SomeOtherLinter] Some other problem
path/to/the_file:33:33: [SomeOtherLinter] Problem with column
"""
Loading