Skip to content

Commit

Permalink
go fmt applyed
Browse files Browse the repository at this point in the history
  • Loading branch information
comdiv committed Jun 28, 2024
1 parent d7fc862 commit ecda17b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
24 changes: 11 additions & 13 deletions rule/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func (r *ExportedRule) configure(arguments lint.Arguments) {
r.Lock()
if !r.configured {
var sayRepetitiveInsteadOfStutters bool
r.checkPrivateReceivers,
r.disableStutteringCheck,
sayRepetitiveInsteadOfStutters,
r.checkPublicInterface = r.getConf(arguments)

r.checkPrivateReceivers,
r.disableStutteringCheck,
sayRepetitiveInsteadOfStutters,
r.checkPublicInterface = r.getConf(arguments)

r.stuttersMsg = "stutters"
if sayRepetitiveInsteadOfStutters {
Expand Down Expand Up @@ -63,9 +63,8 @@ func (r *ExportedRule) Apply(file *lint.File, args lint.Arguments) []lint.Failur
genDeclMissingComments: make(map[*ast.GenDecl]bool),
checkPrivateReceivers: r.checkPrivateReceivers,
disableStutteringCheck: r.disableStutteringCheck,
checkPublicInterface: r.checkPublicInterface,
checkPublicInterface: r.checkPublicInterface,
stuttersMsg: r.stuttersMsg,

}

ast.Walk(&walker, fileAst)
Expand All @@ -79,8 +78,8 @@ func (*ExportedRule) Name() string {
}

func (r *ExportedRule) getConf(args lint.Arguments) (
checkPrivateReceivers,
disableStutteringCheck,
checkPrivateReceivers,
disableStutteringCheck,
sayRepetitiveInsteadOfStutters bool,
checkPublicInterface bool,
) {
Expand Down Expand Up @@ -119,7 +118,7 @@ type lintExported struct {
onFailure func(lint.Failure)
checkPrivateReceivers bool
disableStutteringCheck bool
checkPublicInterface bool
checkPublicInterface bool
stuttersMsg string
}

Expand Down Expand Up @@ -346,7 +345,7 @@ func (w *lintExported) Visit(n ast.Node) ast.Visitor {
}
w.lintTypeDoc(v, doc)
w.checkStutter(v.Name, "type")

if w.checkPublicInterface {
if iface, ok := v.Type.(*ast.InterfaceType); ok {
if ast.IsExported(v.Name.Name) {
Expand All @@ -363,7 +362,6 @@ func (w *lintExported) Visit(n ast.Node) ast.Visitor {
return w
}


func (w *lintExported) doCheckPublicInterface(typeName string, iface *ast.InterfaceType) {
for _, m := range iface.Methods.List {
// case of ast.Ident and other implicit fields
Expand Down Expand Up @@ -397,4 +395,4 @@ func (w *lintExported) lintInterfaceMethod(typeName string, m *ast.Field) {
Failure: fmt.Sprintf(`comment on exported interface method %s.%s should be of the form "%s..."`, typeName, name, prefix),
})
}
}
}
3 changes: 1 addition & 2 deletions test/exported_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ func TestExportedReplacingStuttersByRepetitive(t *testing.T) {
testRule(t, "exported-issue-519", &rule.ExportedRule{}, &lint.RuleConfig{Arguments: args})
}


func TestCheckPublicInterfaceOption(t *testing.T) {
args := []any{"checkPublicInterface"}

testRule(t, "exported-issue-1002", &rule.ExportedRule{}, &lint.RuleConfig{Arguments: args})
}
}

0 comments on commit ecda17b

Please sign in to comment.