[lint] Switch to a more inclusive language

96 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Feb 8, 2021, 4:27:06 PM2/8/21
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded this change for review.

View Change

Switch to a more inclusive language

This commit changes various parts in the code that feel
very odd for someone who actually stutters. We are linting
for something bad and considering it as harmful. So let's
switch to a wording that is more technical and less
"high school yard"-like.

Change-Id: Ibf64feaef1a4f6b2c13e7dced4fd3e447249468e
GitHub-Last-Rev: 0e7d63c960c31d7d02b5c8bd219584b52833e7f1
GitHub-Pull-Request: golang/lint#507
---
M lint.go
R testdata/repetition.go
2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/lint.go b/lint.go
index 7d813e0..6e7ead4 100644
--- a/lint.go
+++ b/lint.go
@@ -472,14 +472,12 @@

const docCommentsLink = styleGuideBase + "#doc-comments"

-// lintExported examines the exported names.
-// It complains if any required doc comments are missing,
-// or if they are not of the right form. The exact rules are in
-// lintFuncDoc, lintTypeDoc and lintValueSpecDoc; this function
-// also tracks the GenDecl structure being traversed to permit
-// doc comments for constants to be on top of the const block.
-// It also complains if the names stutter when combined with
-// the package name.
+// lintExported examines the exported names. It complains if any required doc
+// comments are missing, or if they are not of the right form. The exact rules
+// are in lintFuncDoc, lintTypeDoc and lintValueSpecDoc; this function also
+// tracks the GenDecl structure being traversed to permit doc comments for
+// constants to be on top of the const block. It also complains if the names
+// are repetitive when combined with the package name.
func (f *file) lintExported() {
if f.isTest() {
return
@@ -502,9 +500,9 @@
case *ast.FuncDecl:
f.lintFuncDoc(v)
if v.Recv == nil {
- // Only check for stutter on functions, not methods.
+ // Only check for repetitives on functions, not methods.
// Method names are not used package-qualified.
- f.checkStutter(v.Name, "func")
+ f.checkRepetition(v.Name, "func")
}
// Don't proceed inside funcs.
return false
@@ -515,7 +513,7 @@
doc = lastGen.Doc
}
f.lintTypeDoc(v, doc)
- f.checkStutter(v.Name, "type")
+ f.checkRepetition(v.Name, "type")
// Don't proceed inside types.
return false
case *ast.ValueSpec:
@@ -935,16 +933,16 @@
}
}

-func (f *file) checkStutter(id *ast.Ident, thing string) {
+func (f *file) checkRepetition(id *ast.Ident, thing string) {
pkg, name := f.f.Name.Name, id.Name
if !ast.IsExported(name) {
// unexported name
return
}
- // A name stutters if the package name is a strict prefix
+ // A name is repetitive if the package name is a strict prefix
// and the next character of the name starts a new word.
if len(name) <= len(pkg) {
- // name is too short to stutter.
+ // name is too short to be repetitive.
// This permits the name to be the same as the package name.
return
}
@@ -953,10 +951,10 @@
}
// We can assume the name is well-formed UTF-8.
// If the next rune after the package name is uppercase or an underscore
- // the it's starting a new word and thus this name stutters.
+ // the it's starting a new word and thus this name is repetitive.
rem := name[len(pkg):]
if next, _ := utf8.DecodeRuneInString(rem); next == '_' || unicode.IsUpper(next) {
- f.errorf(id, 0.8, link(styleGuideBase+"#package-names"), category("naming"), "%s name will be used as %s.%s by other packages, and that stutters; consider calling this %s", thing, pkg, name, rem)
+ f.errorf(id, 0.8, link(styleGuideBase+"#package-names"), category("naming"), "%s name will be used as %s.%s by other packages. This is repetitive; consider calling this %s", thing, pkg, name, rem)
}
}

diff --git a/testdata/stutter.go b/testdata/repetition.go
similarity index 95%
rename from testdata/stutter.go
rename to testdata/repetition.go
index 3e6b13e..2430bc8 100644
--- a/testdata/stutter.go
+++ b/testdata/repetition.go
@@ -1,4 +1,4 @@
-// Test of stuttery names.
+// Test of repetetive names.

// Package donut ...
package donut

To view, visit change 290510. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: lint
Gerrit-Branch: master
Gerrit-Change-Id: Ibf64feaef1a4f6b2c13e7dced4fd3e447249468e
Gerrit-Change-Number: 290510
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-MessageType: newchange

Gerrit Bot (Gerrit)

unread,
Feb 8, 2021, 5:58:43 PM2/8/21
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot uploaded patch set #2 to this change.

View Change

Switch to a more inclusive language

This commit changes various parts in the code that feel
very odd for someone who actually stutters. We are linting
for something bad and considering it as harmful. So let's
switch to a wording that is more technical and less
"high school yard"-like.

Change-Id: Ibf64feaef1a4f6b2c13e7dced4fd3e447249468e
GitHub-Last-Rev: e4c560611ea9235e5574d5ee013e78dddea3f615

GitHub-Pull-Request: golang/lint#507
---
M lint.go
R testdata/repetition.go
2 files changed, 17 insertions(+), 19 deletions(-)

To view, visit change 290510. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: lint
Gerrit-Branch: master
Gerrit-Change-Id: Ibf64feaef1a4f6b2c13e7dced4fd3e447249468e
Gerrit-Change-Number: 290510
Gerrit-PatchSet: 2
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-MessageType: newpatchset

Daniel Martí (Gerrit)

unread,
May 8, 2021, 4:30:24 PM5/8/21
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Daniel Martí abandoned this change.

View Change

Abandoned Thank you for submitting this patch! As proposed[1], we are freezing and deprecating golint. There's no drop-in replacement to golint per se, but you should find that Staticcheck[2] works well in encouraging good Go code, much like golint did in the past, since it also includes style checks. There's always gofmt and "go vet" too, of course. If you would like to contribute further, I'd encourage you to engage Staticcheck's issue tracker[3] or look at vet's open issues[4], as they are both actively maintained. If you have an idea that doesn't fit into either of those tools, you could look at other Go linters[5], or write your own - these days it's fairly straightforward with go/analysis[6]. To help avoid confusion, I'm closing all CLs before we freeze the repository. If you have any feedback, you can leave a comment on the proposal thread where it was decided to deprecate golint - though note that the proposal has been accepted for nearly a year. Thanks! [1] https://github.com/golang/go/issues/38968 [2] https://staticcheck.io/ [3] https://github.com/dominikh/go-tools/issues [4] https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+cmd%2Fvet+in%3Atitle [5] https://github.com/golangci/awesome-go-linters [6] https://pkg.go.dev/golang.org/x/tools/go/analysis

To view, visit change 290510. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: lint
Gerrit-Branch: master
Gerrit-Change-Id: Ibf64feaef1a4f6b2c13e7dced4fd3e447249468e
Gerrit-Change-Number: 290510
Gerrit-PatchSet: 2
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-MessageType: abandon
Reply all
Reply to author
Forward
0 new messages