-
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
Rewrite cyclomatic_complexity with SwiftSyntax #5308
Rewrite cyclomatic_complexity with SwiftSyntax #5308
Conversation
Generated by 🚫 Danger |
I've looked into the only change oss-check is reporting and I think this PR is actually fixing a bug. Looks like the old implementation could end up excluding |
|
||
// Switch complexity is reduced by `fallthrough` cases | ||
override func visitPost(_ node: CatchClauseSyntax) { |
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.
this is a bit weird, and maybe not intentional but this snippet:
do {} catch {}
contains a case
according to SourceKitten:
{
"key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
"key.length" : 14,
"key.offset" : 0,
"key.substructure" : [
{
"key.bodylength" : 0,
"key.bodyoffset" : 4,
"key.kind" : "source.lang.swift.stmt.brace",
"key.length" : 2,
"key.offset" : 3
},
{
"key.elements" : [
{
"key.kind" : "source.lang.swift.structure.elem.pattern",
"key.length" : 1,
"key.offset" : 12
}
],
"key.kind" : "source.lang.swift.stmt.case",
"key.length" : 8,
"key.offset" : 6
}
]
}
since it's kind of a different branch I decided to keep counting it.
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.
The fact that SourceKit thinks that's a case statement is weird, but it's true that there are two branches in do {} catch {}
: one where only do
is invoked and another where do
and catch
are invoked.
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.
Good job! I had tried this one a while back and didn't crack it, but reading through this one looks correct to me!
No description provided.