Repository navigation
Open
Description
New Issue Checklist
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub issues.
Bug Description
On a pull request that changes only rule files, the Danger step fails with exit status 2. It posts no comment. #6870 is an example.
This is what happens:
tools/oss-checkadds anonly_ruleslist to each project's.swiftlint.yml.BrigadeandSwiftLintPerformanceTestskeep their own config. Both useopt_in_rules. SwiftLint does not accept both keys in one file, so it uses its default configuration:warning: 'disabled_rules' or 'opt_in_rules' cannot be used in combination with 'only_rules' – Falling back to default configuration- The default configuration has no
excluded:list. So SwiftLint lints Brigade'sReproducers/directory, which Brigade excludes on purpose. - A release build crashes on
Reproducers/SIGILL-IdenticalOperands.swift. The report is empty. oss-checkparses the empty report and crashes:JSON::ParserError: unexpected end of input at line 1 column 1 from tools/oss-check:286:in 'block in Object#diff_and_report_changes_to_danger'
Reproduction
With a release build of swiftlint, on my machine:
git clone --depth 1 https://github.com/Brett-Best/Brigade && cd Brigade
printf 'only_rules:\n - no_magic_numbers\n' >> .swiftlint.yml
swiftlint lint --no-cache --reporter json > report.json; echo "exit $?" # exit 132
wc -c < report.json # 0Cause
- Consume test repository for file performance comparisons #6367 added
SwiftLintPerformanceTestswithkeep_config. Since then, rule-only pull requests lint it with the default rules, not the changed rule. The results are wrong, but nothing crashes. - Add Brigade to the oss-check repositories #6866 added
Brigadewithkeep_config. The fallback drops Brigade'sexcluded:list, so SwiftLint parses the file that crashes.
Why some pull requests passed
#6870 passed Danger on 10 August. #6904 passed on 3 September. Both came after #6866. I could not find what changed on CI since then. This is what I know:
- The crash is a stack overflow in the swift-syntax parser (
Lexer.Cursor.lexTrivia). - Debug builds do not crash. swift-syntax allows 20 nesting levels in debug builds and 256 in release builds.
- Every release build I tried crashes, from
0.65.0tomain. - My builds of Fix orphaned_doc_comment for current doc comment attachment #6904 have the same binary sizes that Danger reported for it (28467.96 KiB and 28451.68 KiB). With them, Fix orphaned_doc_comment for current doc comment attachment #6904's own oss-check run crashes on my machine.
So the crash most likely depends on the machine that runs it. The fix below does not depend on this.
Suggested fix
- Pass
--only-ruleon the command line instead of editing the config. This flag ignoresonly_rules,opt_in_rulesanddisabled_rules, so it cannot conflict. Each project also keeps itsexcluded:list. - Check each report before parsing it. If it is empty, show a warning with the project name.
Environment
- SwiftLint
mainatd5156105b, release build with Bazel - Xcode 26.5, macOS 26.6, Apple Silicon
Metadata
Metadata
Assignees
Labels
No labels
Activity