Skip to content
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

Preferring early loop exits to reduce indentation #1340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

param108
Copy link

@param108 param108 commented Dec 8, 2022

Fixes #1334

The check,

  1. looks for for-loops with single children.
  2. It further checks if the child is an if condition.
  3. Finally it checks that the if condition has more than 10 children.

fn := func(node ast.Node, push bool) bool {
switch node := node.(type) {
case *ast.ForStmt:
if push {
Copy link

Choose a reason for hiding this comment

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

Can we apply the same style check of reducing indentation to this code? ;)

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.

simple: enforce early return in loops
2 participants