Skip to content

Commit

Permalink
Merge pull request #8 from butuzov/off-by-one
Browse files Browse the repository at this point in the history
fix: off-by-one error
  • Loading branch information
ssgreg authored Sep 17, 2021
2 parents 0d1e458 + 73b34ed commit 3d6ba68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ func bar() int {
return a
}
```

# Args

* `-block-size n` size of the block (including return statement that is still "OK") so no return split required.
4 changes: 2 additions & 2 deletions pkg/nlreturn/nlreturn.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ func run(pass *analysis.Pass) (interface{}, error) {
}

func inspectBlock(pass *analysis.Pass, block []ast.Stmt) {

for i, stmt := range block {
switch stmt.(type) {
case *ast.BranchStmt, *ast.ReturnStmt:
if line(pass, stmt.Pos())-line(pass, block[0].Pos()) < blockSize {

if i == 0 || line(pass, stmt.Pos())-line(pass, block[0].Pos()) < blockSize {
return
}

Expand Down

0 comments on commit 3d6ba68

Please sign in to comment.