Don't check for stutter of method names.
Method names are used object-qualified, not package-qualified.
diff --git a/lint.go b/lint.go
index d6e72a2..377c407 100644
--- a/lint.go
+++ b/lint.go
@@ -265,11 +265,11 @@
return true
case *ast.FuncDecl:
f.lintFuncDoc(v)
- thing := "func"
- if v.Recv != nil {
- thing = "method"
+ if v.Recv == nil {
+ // Only check for stutter on functions, not methods.
+ // Method names are not used package-qualified.
+ f.checkStutter(v.Name, "func")
}
- f.checkStutter(v.Name, thing)
// Don't proceed inside funcs.
return false
case *ast.TypeSpec:
diff --git a/testdata/stutter.go b/testdata/stutter.go
index 997d4b8..3e6b13e 100644
--- a/testdata/stutter.go
+++ b/testdata/stutter.go
@@ -12,9 +12,14 @@
}
// Donut is a delicious treat.
-type Donut interface{} // ok because it is the whole name
+type Donut struct{} // ok because it is the whole name
// Donuts are great, aren't they?
type Donuts []Donut // ok because it didn't start a new word
type donutGlaze int // ok because it is unexported
+
+// DonutMass reports the mass of a donut.
+func (d *Donut) DonutMass() (grams int) { // okay because it is a method
+ return 38
+}