-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add Cognitive Complexity Rule
#5838
base: main
Are you sure you want to change the base?
Conversation
what needs to happen to get this merged? Is thing we can do to help on this issue. It would be amazing to have cognitive complexity rule enforcement in this library. |
also why are these warnings being generated here when none of these projects have anything to do with this project? |
So it will need to be code reviewed and approved, and then merged. Everyone who contributes to SwiftLint works on a volunteer basis, so it can take a while for people to find time to come back to it. If you look at previously merged PRs, you'll see that it can take a while. I do have some comments on the PR, but I don't have time right now to take a proper look. Generally if you can keep the branch clean and without merge conflicts that is good. The changelog can be a bit of a hotspot. |
So PRs that change any code in SwiftLint (some PRs are excluded but I can't remember the exact basis offhand) are run against a set of popular open source projects, and their violations compared against what This gives a kind of sanity check across a much wider codebase, and inspecting the new violations can be a big clue as to where we might be picking up false alarms, and "fixed" violations can be inspected to see if they really should have been fixed by the changes. In this case, it's a new rule, so you'd only expect new violations. |
@@ -16,6 +16,10 @@ | |||
[Jordan Rose](https://github.com/jrose-signal) | |||
[SimplyDanny](https://github.com/SimplyDanny) | |||
|
|||
* Add `Cognitive Complexity Rule` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at previous rule addition changelog entries, they tend to be a bit wordier, and to specify the rule by its identifier. e.g.
* Add new `contrasted_opening_brace` rule that enforces opening
braces to be on a separate line after the preceding declaration.
[SimplyDanny](https://github.com/SimplyDanny)
} | ||
|
||
override func visit(_: IfExprSyntax) -> SyntaxVisitorContinueKind { | ||
nesting += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like there's quite a lot of repetition in the methods - it would be nice to abstract that way a bit if possible
Resolves #3335
Reference: https://www.sonarsource.com/resources/cognitive-complexity/