diff --git a/.golangci.yml b/.golangci.yml index c405b15467a..6793bed9135 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -202,7 +202,6 @@ linters: - RepositoriesSearchResult.Repositories - RepositoriesSearchResult.Total - RepositoryVulnerabilityAlert.GitHubSecurityAdvisoryID - - SCIMDisplayReference.Ref - SecretScanningAlertLocationDetails.Startline # TODO: StartLine - SecretScanningPatternOverride.Bypassrate # TODO: BypassRate - StarredRepository.Repository # TODO: Repo diff --git a/tools/jsonfieldname/jsonfieldname.go b/tools/jsonfieldname/jsonfieldname.go index e4c117e3cb6..1de10bc2f8c 100644 --- a/tools/jsonfieldname/jsonfieldname.go +++ b/tools/jsonfieldname/jsonfieldname.go @@ -134,6 +134,8 @@ func checkGoFieldName(structName, goFieldName, jsonTagName string, tokenPos toke } func splitJSONTag(jsonTagName string) []string { + jsonTagName = strings.TrimPrefix(jsonTagName, "$") + if strings.Contains(jsonTagName, "_") { return strings.Split(jsonTagName, "_") } diff --git a/tools/jsonfieldname/testdata/src/has-warnings/main.go b/tools/jsonfieldname/testdata/src/has-warnings/main.go index 04670e20b1d..c1a74c6059a 100644 --- a/tools/jsonfieldname/testdata/src/has-warnings/main.go +++ b/tools/jsonfieldname/testdata/src/has-warnings/main.go @@ -10,4 +10,5 @@ type Example struct { Id string `json:"id,omitempty"` // want `change Go field name "Id" to "ID" for JSON tag "id" in struct "Example"` strings string `json:"strings,omitempty"` // want `change Go field name "strings" to "Strings" for JSON tag "strings" in struct "Example"` camelcaseexample *int `json:"camelCaseExample,omitempty"` // want `change Go field name "camelcaseexample" to "CamelCaseExample" for JSON tag "camelCaseExample" in struct "Example"` + DollarRef string `json:"$ref"` // want `change Go field name "DollarRef" to "Ref" for JSON tag "\$ref" in struct "Example"` } diff --git a/tools/jsonfieldname/testdata/src/no-warnings/main.go b/tools/jsonfieldname/testdata/src/no-warnings/main.go index 73119c771f0..c522c7783ea 100644 --- a/tools/jsonfieldname/testdata/src/no-warnings/main.go +++ b/tools/jsonfieldname/testdata/src/no-warnings/main.go @@ -9,4 +9,5 @@ type Example struct { GithubThing string `json:"github_thing"` // Should not be flagged ID string `json:"id,omitempty"` // Should not be flagged Strings string `json:"strings,omitempty"` // Should not be flagged + Ref string `json:"$ref,omitempty"` // Should not be flagged }