aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamal Carvalho <jamal@golang.org>2022-06-23 20:56:13 +0000
committerJamal Carvalho <jamal@golang.org>2022-06-30 15:52:19 +0000
commit0b288825799277442e38232a9e9d079bc5956ef4 (patch)
tree1ddb62858c2f683aad886a3b9568bba58174b256
parent5681099b04426fb86423dac2314d5cc8c6f62d52 (diff)
downloadgo-x-pkgsite-0b288825799277442e38232a9e9d079bc5956ef4.tar.xz
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>
-rw-r--r--internal/frontend/server.go4
-rw-r--r--internal/frontend/styleguide.go4
-rw-r--r--internal/godoc/dochtml/dochtml.go6
-rw-r--r--staticcheck.conf11
4 files changed, 10 insertions, 15 deletions
diff --git a/internal/frontend/server.go b/internal/frontend/server.go
index 26bf102a..a2672326 100644
--- a/internal/frontend/server.go
+++ b/internal/frontend/server.go
@@ -37,6 +37,8 @@ import (
"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 @@ var templateFuncs = template.FuncMap{
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 10b5e588..958b9bdc 100644
--- a/internal/frontend/styleguide.go
+++ b/internal/frontend/styleguide.go
@@ -26,6 +26,8 @@ import (
"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 @@ func camelCase(s string) string {
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 2cca7b39..404b81bb 100644
--- a/internal/godoc/dochtml/dochtml.go
+++ b/internal/godoc/dochtml/dochtml.go
@@ -29,6 +29,8 @@ import (
"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 @@ func collectExamples(p *doc.Package) *examples {
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 @@ func buildNoteHeaders(notes map[string][]*doc.Note) map[string]noteHeader {
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 c0e14e7e..00000000
--- 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"]