Skip to content

Commit

Permalink
Merge pull request #52 from bugcrowd/checkstyle-more-tolerant
Browse files Browse the repository at this point in the history
Make Checkstyle formatter more tolerant of missing attributes
  • Loading branch information
maschwenk authored May 30, 2019
2 parents 3d04fa2 + 58dd882 commit 282fe77
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/test_summary_buildkite_plugin/input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ def file_contents_to_failures(str)
end

def summary(filename, error)
severity = error.attribute('severity').value
line = error.attribute('line').value
column = error.attribute('column').value
location = "#{filename}:#{line}:#{column}"
message = error.attribute('message').value
severity = error.attribute('severity')&.value
line = error.attribute('line')&.value
column = error.attribute('column')&.value
location = [filename, line, column].compact.join(':')
message = error.attribute('message')&.value

"[#{severity}] #{location}: #{message}"
end
Expand Down
2 changes: 2 additions & 0 deletions spec/sample_artifacts/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
<checkstyle version="8.0">
<file name="src/main/java/io/timnew/sol/Sol.kt">
<error line="106" column="1" severity="error" message="Needless blank line(s)" source="no-consecutive-blank-lines" />
<error line="109" severity="error" message="Without column" source="no-consecutive-blank-lines" />
<error severity="error" message="Without column or line" source="no-consecutive-blank-lines" />
</file>
</checkstyle>
10 changes: 8 additions & 2 deletions spec/test_summary_buildkite_plugin/input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,19 @@
it { is_expected.to be_a(TestSummaryBuildkitePlugin::Input::Checkstyle) }

it 'has all failures' do
expect(input.failures.count).to eq(1)
expect(input.failures.count).to eq(3)
end

it 'failures have summary' do
expect(input.failures.first.summary).to eq(
expect(input.failures[0].summary).to eq(
'[error] src/main/java/io/timnew/sol/Sol.kt: Without column or line'
)
expect(input.failures[1].summary).to eq(
'[error] src/main/java/io/timnew/sol/Sol.kt:106:1: Needless blank line(s)'
)
expect(input.failures[2].summary).to eq(
'[error] src/main/java/io/timnew/sol/Sol.kt:109: Without column'
)
end

it 'failures have details' do
Expand Down

0 comments on commit 282fe77

Please sign in to comment.