mirror of
https://github.com/mgechev/revive.git
synced 2025-01-06 03:04:06 +02:00
feat: capitalise var naming to IDs (#964)
* feat: capitalise var naming to IDs * feat: added test case for IDs case
This commit is contained in:
parent
9abe06adfa
commit
64dda06595
@ -71,6 +71,10 @@ func Name(name string, allowlist, blocklist []string) (should string) {
|
||||
if w == 0 && unicode.IsLower(runes[w]) {
|
||||
u = strings.ToLower(u)
|
||||
}
|
||||
// Keep lowercase s for IDs
|
||||
if u == "IDS" {
|
||||
u = "IDs"
|
||||
}
|
||||
// All the common initialisms are ASCII,
|
||||
// so we can replace the bytes exactly.
|
||||
copy(runes[w:], []rune(u))
|
||||
@ -99,6 +103,7 @@ var commonInitialisms = map[string]bool{
|
||||
"HTTP": true,
|
||||
"HTTPS": true,
|
||||
"ID": true,
|
||||
"IDS": true,
|
||||
"IP": true,
|
||||
"JSON": true,
|
||||
"LHS": true,
|
||||
|
3
testdata/var-naming.go
vendored
3
testdata/var-naming.go
vendored
@ -2,6 +2,7 @@ package fixtures
|
||||
|
||||
func foo() string {
|
||||
customId := "result"
|
||||
customVm := "result" // MATCH /var customVm should be customVM/
|
||||
customVm := "result" // MATCH /var customVm should be customVM/
|
||||
customIds := "result" // MATCH /var customIds should be customIDs/
|
||||
return customId
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user