Skip to content

Commit

Permalink
S1008: allow either branch to be documented
Browse files Browse the repository at this point in the history
Updates: gh-704
Updates: gh-1488
  • Loading branch information
dominikh committed Jan 23, 2025
1 parent de48f96 commit e65b392
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions simple/s1008/s1008.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func run(pass *analysis.Pass) (any, error) {
return false
}

// Don't flag if both are commented.
if hasComments(n1) && hasComments(n2) {
// Don't flag if either branch is commented
if hasComments(n1) || hasComments(n2) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions simple/s1008/testdata/go1.0/CheckIfReturn/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ func cmt4(x string) bool {
}

func cmt5(x string) bool {
if len(x) > 0 { //@ diag(`should use 'return len(x) == 0'`)
if len(x) > 0 {
return false
}
return true // A
}

func cmt6(x string) bool {
if len(x) > 0 { //@ diag(`should use 'return len(x) == 0'`)
if len(x) > 0 {
return false // A
}
return true
Expand Down

0 comments on commit e65b392

Please sign in to comment.