Skip to content

Conversation

@Drowze
Copy link
Contributor

@Drowze Drowze commented Jun 1, 2021

Pronto might report warnings and that was not being correctly parsed by Overcommit. This is sort of a follow-up from #754.

Before: all warnings and errors were reported as errors. They actually simply crashed at

def extract_messages(output_messages, regex, type_categorizer = nil)
output_messages.map.with_index do |message, index|
unless match = message.match(regex)
raise Overcommit::Exceptions::MessageProcessingError,
'Unexpected output: unable to determine line number or type ' \
"of error/warning for output:\n" \
"#{output_messages[index..-1].join("\n")}"
end

Now warnings and errors are reported correctly. Examples below:

# Testing with an output containing only warnings
⋊> ~/w/o/cts on rg-test-branch ⨯ be pronto run --exit-code --commit=qa --runner reek
Running Pronto::Reek
app/models/shipment.rb:163 W: Calls 'loc.type' 3 times - [DuplicateMethodCall](https://github.com/troessner/reek/blob/v6.0.4/docs/Duplicate-Method-Call.md)

⋊> ~/w/o/cts on rg-test-branch ⨯ git push --dry-run origin HEAD # using a hook with reek
Running pre-push hooks
Analyzing with Pronto (brakeman, fasterer, flay and reek)[Pronto] WARNING
app/models/shipment.rb:163 W: Calls 'loc.type' 3 times - [DuplicateMethodCall](https://github.com/troessner/reek/blob/v6.0.4/docs/Duplicate-Method-Call.md)

⚠ All pre-push hooks passed, but with warnings
# Testing with an output containing warnings AND errors
⋊> ~/w/o/cts on rg-test-branch ⨯ be pronto run --exit-code --commit=qa --runner rubocop
Running Pronto::Rubocop
app/models/shipment.rb:158 E: Layout/MultilineOperationIndentation: Use 2 (not 3) spaces for indenting an expression spanning multiple lines.

 ``suggestion
          loc.status == Models::Location::STATUS_CURRENT
 ``

⋊> ~/w/o/cts on rg-test-branch ⨯ git push --dry-run origin HEAD # using a hook with reek and rubocop
Running pre-push hooks
Analyzing with Pronto (brakeman, fasterer, flay, reek and rubocop)[Pronto] FAILED
app/models/shipment.rb:163 W: Calls 'loc.type' 3 times - [DuplicateMethodCall](https://github.com/troessner/reek/blob/v6.0.4/docs/Duplicate-Method-Call.md)
app/models/shipment.rb:158 E: Layout/MultilineOperationIndentation: Use 2 (not 3) spaces for indenting an expression spanning multiple lines.

✗ One or more pre-push hooks failed

error: failed to push some refs to 'git@github.com:Org/cts'

@Drowze Drowze force-pushed the fix-pronto-warnings branch from 9b6e6f4 to 482801c Compare June 1, 2021 01:46
Pronto might raise warnings and that was not being correctly parsed by
Overcommit
@Drowze Drowze force-pushed the fix-pronto-warnings branch from 482801c to 85eeaa0 Compare June 1, 2021 01:47
@sds sds added the bug label Jun 2, 2021
@sds sds merged commit 8622f9e into sds:master Jun 2, 2021
@sds
Copy link
Owner

sds commented Jun 2, 2021

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants