Repository navigation
Conversation
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.
A new rule, AZG012, that reports an
if,for,switchorselectin a longer function body run straight into the statement after it, with a fix that inserts the blank line.Why: a body reads as a sequence of steps: get something, check it, use it. The block that ends one step and the statement that starts the next need a blank line between them or a twenty-line loop body reads as one undifferentiated run. This is the judgement #70 applied by hand across the repo, turned into a check so it holds for new code.
Steps run together. In a body of more than five statements spanning more than ten lines, a block followed on the very next line by another statement is reported at that statement. A comment on that line belongs to the next step, so the report and the blank go before the comment.
if !ok || runs[fn] != nil { continue } + rest := strings.TrimPrefix(fn.Name(), "TestAcc")Things that are fine as they are. A short body is one group and gets nothing: five statements or fewer, or ten lines or fewer, both adjustable through the
statementsandlinesoptions. Two one-lineifs in a row read as a set of guards and stay together. A literal assignment that closes with a brace does not end a step. Nothing is reported before acase, and never where a blank line already is.Files the earlier pass skipped. #70 left out
AZP002.go,AZT003.goandlib/tf/registration.gobecause #67 and #68 rewrite them. The rule runs on this repo, so those three get the same blank lines here through the rule's own fix. Whichever of #67, #68 and this lands last takes a trivial rebase, since the insertions are identical.The rule is enabled on this repo through the existing
enable: [AZG]setting, and the tree is clean under it. Fixable with-fix.