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

resolve #867: remove k[A-Z][A-Za-z\d]*$ sub-rule from var-naming #871

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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