internal: re-enable staticcheck SA1019
Replaces use of strings.Title with a caser from
/x/text/cases.
Change-Id: I35f9f96720bb84b40cef3d7bfda1a7370991c5cd
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/413317
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/frontend/server.go b/internal/frontend/server.go
index 26bf102..a267232 100644
--- a/internal/frontend/server.go
+++ b/internal/frontend/server.go
@@ -37,6 +37,8 @@
"golang.org/x/pkgsite/internal/queue"
"golang.org/x/pkgsite/internal/static"
"golang.org/x/pkgsite/internal/version"
+ "golang.org/x/text/cases"
+ "golang.org/x/text/language"
vulnc "golang.org/x/vuln/client"
)
@@ -688,7 +690,7 @@
return strings.Join(s, ", ")
},
"stripscheme": stripScheme,
- "capitalize": strings.Title,
+ "capitalize": cases.Title(language.Und).String,
"queryescape": url.QueryEscape,
}
diff --git a/internal/frontend/styleguide.go b/internal/frontend/styleguide.go
index 10b5e58..958b9bd 100644
--- a/internal/frontend/styleguide.go
+++ b/internal/frontend/styleguide.go
@@ -26,6 +26,8 @@
"golang.org/x/pkgsite/internal"
"golang.org/x/pkgsite/internal/derrors"
"golang.org/x/pkgsite/internal/experiment"
+ "golang.org/x/text/cases"
+ "golang.org/x/text/language"
)
// serveStyleGuide serves the styleguide page, the content of which is
@@ -216,7 +218,7 @@
p := strings.Split(s, "-")
var o []string
for _, v := range p {
- o = append(o, strings.Title(v))
+ o = append(o, cases.Title(language.Und).String(v))
}
return strings.Join(o, "")
}
diff --git a/internal/godoc/dochtml/dochtml.go b/internal/godoc/dochtml/dochtml.go
index 2cca7b3..404b81b 100644
--- a/internal/godoc/dochtml/dochtml.go
+++ b/internal/godoc/dochtml/dochtml.go
@@ -29,6 +29,8 @@
"golang.org/x/pkgsite/internal"
"golang.org/x/pkgsite/internal/derrors"
"golang.org/x/pkgsite/internal/godoc/dochtml/internal/render"
+ "golang.org/x/text/cases"
+ "golang.org/x/text/language"
)
var (
@@ -382,7 +384,7 @@
Map: make(map[string][]*example),
}
WalkExamples(p, func(id string, ex *doc.Example) {
- suffix := strings.Title(ex.Suffix)
+ suffix := cases.Title(language.English, cases.NoLower).String(ex.Suffix)
ex0 := &example{
Example: ex,
ID: exampleID(id, suffix),
@@ -433,7 +435,7 @@
for marker := range notes {
headers[marker] = noteHeader{
SafeIdentifier: safehtml.IdentifierFromConstantPrefix("pkg-note", marker),
- Label: strings.Title(strings.ToLower(marker)),
+ Label: cases.Title(language.Und).String(strings.ToLower(marker)),
}
}
return headers
diff --git a/staticcheck.conf b/staticcheck.conf
deleted file mode 100644
index c0e14e7..0000000
--- a/staticcheck.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-# This file configures staticheck to ignore SA1019 throughout
-# the pkgsite codebase.
-
-# TODO(jamalcarvalho): fix SA1019.
-# The text for this check reads:
-# strings.Title has been deprecated since Go 1.18 and an alternative
-# has been available since Go 1.0: The rule Title uses for word
-# boundaries does not handle Unicode punctuation properly.
-# Use golang.org/x/text/cases instead.
-
-checks = ["inherit", "-SA1019"]