aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/jgautheron/goconst/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/jgautheron/goconst/api.go')
-rw-r--r--vendor/github.com/jgautheron/goconst/api.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/vendor/github.com/jgautheron/goconst/api.go b/vendor/github.com/jgautheron/goconst/api.go
index e58894bc4..d56fcd6c2 100644
--- a/vendor/github.com/jgautheron/goconst/api.go
+++ b/vendor/github.com/jgautheron/goconst/api.go
@@ -3,6 +3,7 @@ package goconst
import (
"go/ast"
"go/token"
+ "strings"
)
type Issue struct {
@@ -13,6 +14,7 @@ type Issue struct {
}
type Config struct {
+ IgnoreTests bool
MatchWithConstants bool
MinStringLength int
MinOccurrences int
@@ -26,7 +28,7 @@ func Run(files []*ast.File, fset *token.FileSet, cfg *Config) ([]Issue, error) {
p := New(
"",
"",
- false,
+ cfg.IgnoreTests,
cfg.MatchWithConstants,
cfg.ParseNumbers,
cfg.NumberMin,
@@ -37,6 +39,11 @@ func Run(files []*ast.File, fset *token.FileSet, cfg *Config) ([]Issue, error) {
)
var issues []Issue
for _, f := range files {
+ if p.ignoreTests {
+ if filename := fset.Position(f.Pos()).Filename; strings.HasSuffix(filename, testSuffix) {
+ continue
+ }
+ }
ast.Walk(&treeVisitor{
fileSet: fset,
packageName: "",