Skip to content

Commit

Permalink
resolve #867: remove k[A-Z][A-Za-z\d]*$ sub-rule from var-naming (#871
Browse files Browse the repository at this point in the history
)
  • Loading branch information
martinsirbe authored Aug 16, 2023
1 parent 16871ed commit 19a95d9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
9 changes: 0 additions & 9 deletions rule/var-naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,6 @@ func (w *lintNames) check(id *ast.Ident, thing string) {
})
return
}
if len(id.Name) > 2 && id.Name[0] == 'k' && id.Name[1] >= 'A' && id.Name[1] <= 'Z' {
should := string(id.Name[1]+'a'-'A') + id.Name[2:]
w.onFailure(lint.Failure{
Failure: fmt.Sprintf("don't use leading k in Go names; %s %s should be %s", thing, id.Name, should),
Confidence: 0.8,
Node: id,
Category: "naming",
})
}

should := lint.Name(id.Name, w.whitelist, w.blacklist)
if id.Name == should {
Expand Down
3 changes: 1 addition & 2 deletions testdata/golint/var-naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ func f_it() { // MATCH /don't use underscores in Go names; func f_it should be f

// Common styles in other languages that don't belong in Go.
const (
CPP_CONST = 1 // MATCH /don't use ALL_CAPS in Go names; use CamelCase/
kLeadingKay = 2 // MATCH /don't use leading k in Go names; const kLeadingKay should be leadingKay/
CPP_CONST = 1 // MATCH /don't use ALL_CAPS in Go names; use CamelCase/

HTML = 3 // okay; no underscore
X509B = 4 // ditto
Expand Down

0 comments on commit 19a95d9

Please sign in to comment.