Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Danger crashes if multiple inline comments have same severity, file and line number #1332

Open
pahnev opened this issue Oct 25, 2021 · 3 comments

Comments

@pahnev
Copy link
Contributor

pahnev commented Oct 25, 2021

Report

What did you do?

While implementing support for SwiftFormat plugin's inline_mode, I noticed that if multiple plugins are trying to add inline_comment with the same severity to the same file and line, danger crashes with lib/danger/request_sources/bitbucket_server.rb:158:in 'sort': comparison of Danger::Violation with Danger::Violation failed (ArgumentError).
Github seems to have the same sort.

https://github.com/danger/danger/blob/master/lib/danger/request_sources/bitbucket_server.rb#L158

What did you expect to happen?

Expected danger not to crash, and all comments to be sorted out in any order.

What happened instead?

💥

Your Environment

Dangerfile

swiftlint.lint_files(fail_on_error: true, inline_mode: true, additional_swiftlint_args: '--strict')
swiftformat.check_format(fail_on_error: true, inline_mode: true)
@pahnev pahnev changed the title Inline comment crashes if multiple Inline comment crashes if multiple comments have same severity, file and line number Oct 25, 2021
@pahnev pahnev changed the title Inline comment crashes if multiple comments have same severity, file and line number Danger crashes if multiple inline comments have same severity, file and line number Oct 25, 2021
@orta
Copy link
Member

orta commented Nov 10, 2021

Fair, yeah, seems reasonable

manicmaniac added a commit to manicmaniac/danger that referenced this issue Feb 3, 2022
@manicmaniac
Copy link
Member

manicmaniac commented Feb 3, 2022

I wrote the following spec to reproduce this issue but it passes.

manicmaniac@92630ff

@pahnev Could you tell me what values in file and line caused this error? I suppose they were invalid values that is not possible to compare.

@pahnev
Copy link
Contributor Author

pahnev commented Feb 23, 2022

Hi, @manicmaniac, so here's my Dangerfile:

swiftformat.check_format(fail_on_error: true, inline_mode: true)
swiftlint.lint_files(fail_on_error: true, inline_mode: true)

And here's the output:

Results:
Errors:
- [ ] Path/To/File/ActivationTokenTests.swift#L11: warning: (consecutiveBlankLines) Replace consecutive blank lines with a single blank line. `ActivationTokenTests.swift:11`
- [ ] SwiftFormat found issues
Warnings:
- [ ] Path/To/File/ActivationTokenTests.swift#L12: Limit vertical whitespace to a single empty line. Currently 3.
`vertical_whitespace` `ActivationTokenTests.swift:12`

And if I make the SwiftLint elevate the message to an error:
swiftlint.lint_files(fail_on_error: true, inline_mode: true, additional_swiftlint_args: '--strict')
it results in a crash I mentioned above.

Both Swiftformat and SwiftLint work with the desired command alone, but not together.

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

No branches or pull requests

3 participants