1
0
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:
Vincent Baron 2024-01-17 14:01:40 +01:00 committed by GitHub
parent 9abe06adfa
commit 64dda06595
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -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,

View File

@ -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
}