From 5ce2ff53c02d827ae1947cc608cde62d8c0643b3 Mon Sep 17 00:00:00 2001 From: chavacava Date: Fri, 18 Mar 2022 15:00:41 +0100 Subject: [PATCH] removes duplicated utility function (#652) --- rule/exported.go | 2 +- rule/package-comments.go | 2 +- rule/utils.go | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/rule/exported.go b/rule/exported.go index 679e164..621fae5 100644 --- a/rule/exported.go +++ b/rule/exported.go @@ -23,7 +23,7 @@ type ExportedRule struct { func (r *ExportedRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure { var failures []lint.Failure - if isTest(file) { + if file.IsTest() { return failures } diff --git a/rule/package-comments.go b/rule/package-comments.go index 00fc5bb..035e113 100644 --- a/rule/package-comments.go +++ b/rule/package-comments.go @@ -20,7 +20,7 @@ type PackageCommentsRule struct{} func (r *PackageCommentsRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { var failures []lint.Failure - if isTest(file) { + if file.IsTest() { return failures } diff --git a/rule/utils.go b/rule/utils.go index 8b0f556..2de9712 100644 --- a/rule/utils.go +++ b/rule/utils.go @@ -19,10 +19,6 @@ const styleGuideBase = "https://golang.org/wiki/CodeReviewComments" // If id == nil, the answer is false. func isBlank(id *ast.Ident) bool { return id != nil && id.Name == "_" } -func isTest(f *lint.File) bool { - return strings.HasSuffix(f.Name, "_test.go") -} - var commonMethods = map[string]bool{ "Error": true, "Read": true,