Skip to content

refactor (rule/cyclomatic): replace AST walker by iteration over declarations #1161

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

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

chavacava
Copy link
Collaborator

Simplifies cyclomatic rule by replacing AST walker by an iteration over global declarations

@chavacava chavacava merged commit 4b13782 into master Dec 4, 2024
5 checks passed
fn, ok := decl.(*ast.FuncDecl)
if !ok {
continue
}

c := complexity(fn)
if c > w.complexity {
w.onFailure(lint.Failure{
if c > r.maxComplexity {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You merged, but this would have been simpler

Suggested change
if c > r.maxComplexity {
if c <= r.maxComplexity {
continue
}

@denisvmedia denisvmedia deleted the refactor/cyclomatic branch December 5, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants