From 0bcc996acf272d18e4ce7b6d125942532a77db38 Mon Sep 17 00:00:00 2001 From: sina safari Date: Sun, 26 Sep 2021 09:58:58 +0330 Subject: [PATCH] fixed some complex code (#580) --- lint/file.go | 5 +---- rule/add-constant.go | 2 +- rule/empty-block.go | 2 +- rule/max-public-structs.go | 1 - 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lint/file.go b/lint/file.go index ee29c1dae..7396f2859 100644 --- a/lint/file.go +++ b/lint/file.go @@ -91,10 +91,7 @@ func (f *File) IsUntypedConst(expr ast.Expr) (defType string, ok bool) { } func (f *File) isMain() bool { - if f.AST.Name.Name == "main" { - return true - } - return false + return f.AST.Name.Name == "main" } const directiveSpecifyDisableReason = "specify-disable-reason" diff --git a/rule/add-constant.go b/rule/add-constant.go index bc6268ee1..4d1579053 100644 --- a/rule/add-constant.go +++ b/rule/add-constant.go @@ -82,7 +82,7 @@ func (r *AddConstantRule) Apply(file *lint.File, arguments lint.Arguments) []lin failures = append(failures, failure) } - w := lintAddConstantRule{onFailure: onFailure, strLits: make(map[string]int, 0), strLitLimit: strLitLimit, whiteLst: whiteList} + w := lintAddConstantRule{onFailure: onFailure, strLits: make(map[string]int), strLitLimit: strLitLimit, whiteLst: whiteList} ast.Walk(w, file.AST) diff --git a/rule/empty-block.go b/rule/empty-block.go index fbec4d93c..e505fde6e 100644 --- a/rule/empty-block.go +++ b/rule/empty-block.go @@ -17,7 +17,7 @@ func (r *EmptyBlockRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure failures = append(failures, failure) } - w := lintEmptyBlock{make(map[*ast.BlockStmt]bool, 0), onFailure} + w := lintEmptyBlock{make(map[*ast.BlockStmt]bool), onFailure} ast.Walk(w, file.AST) return failures } diff --git a/rule/max-public-structs.go b/rule/max-public-structs.go index aa15628f0..b38c8b745 100644 --- a/rule/max-public-structs.go +++ b/rule/max-public-structs.go @@ -63,7 +63,6 @@ func (w *lintMaxPublicStructs) Visit(n ast.Node) ast.Visitor { if strings.ToUpper(first) == first { w.current++ } - break } return w }