Repository navigation
Fix oss-check for pull requests that change only rules - #6934
Open
lechuckcaptain wants to merge 1 commit into
Open
lechuckcaptain wants to merge 1 commit into
lechuckcaptain wants to merge 1 commit into
Conversation
When a pull request changes only rule files, oss-check runs just those rules. It did this by adding an `only_rules` list to each project's `.swiftlint.yml`. That breaks two projects, Brigade and SwiftLintPerformanceTests. oss-check keeps their own configs, and both use `opt_in_rules`. SwiftLint does not accept `only_rules` and `opt_in_rules` in the same file. SwiftLint then falls back to its default configuration. It lints those two projects with the default rules instead of the changed ones, so their results are wrong. The default configuration also has no `excluded:` list, so SwiftLint parses Brigade's crash reproducers. A release build overflows its stack on one of them and writes no report. oss-check then parses the empty report and crashes, and the Danger step fails with no comment. Pass `--only-rule` on the command line instead. You can repeat the flag, and it ignores `only_rules`, `opt_in_rules` and `disabled_rules`. A project's own config cannot conflict with it, and each project keeps its `excluded:` list. SwiftLint selects rules for `--only-rule` and `only_rules` in the same code, so every other project gets the same results as before. Also check each report before parsing it. If a report is empty, show a warning with the project name and skip that project. Before, an empty report caused a JSON parse error that hid the real problem.
lechuckcaptain
marked this pull request as ready for review
September 27, 2026 09:49
Generated by 🚫 Danger |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6933.
When a pull request changes only rule files,
oss-checkadds anonly_ruleslist to each project's config.BrigadeandSwiftLintPerformanceTestskeep their own configs, and both useopt_in_rules. SwiftLint does not accept both keys in one file:So SwiftLint lints those two projects with the default rules and without their
excluded:lists. It parses Brigade's crash reproducers, and a release build crashes with no report.JSON.parsefails on the empty report, and the Danger step stops with no comment.This pull request makes two changes:
--only-rulefor each changed rule instead of editing the config. The flag ignoresonly_rules,opt_in_rulesanddisabled_rules, so it cannot conflict with a project's config. Each project also keeps itsexcluded:list. SwiftLint selects rules for--only-ruleandonly_rulesin the same code, inConfiguration+RulesWrapper.swift. So the other 17 projects get the same results as before.Validation
This pull request changes no rule file, so its own CI does not run the changed code. I ran it locally from a branch that changes one rule file:
JSON::ParserErrorBrigade.jsonWith the fix,
oss-checkalso reports the violations that the rule change fixes in Brigade, for example inSources/BrigadeApp/Plating.swift.Overlap with #6826
The draft #6826 moves the same
only_rulesblock insetup_repos. It keeps the append, so it does not fix this. The two pull requests will conflict in that block. I can rebase this one if #6826 lands first.