aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/jgautheron/goconst/parser.go
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-03-04 17:40:11 +0000
committerTaras Madan <tarasmadan@google.com>2024-03-04 18:34:55 +0000
commit5fc5366972c874b919f93165bb4ed4e2bcb7c350 (patch)
tree287c3361a0dee0c72af80d9a1a66714a06e98a62 /vendor/github.com/jgautheron/goconst/parser.go
parent1be5ce38a9059c356eb193a8c34d60d61c9fc31f (diff)
mod: bump github.com/golangci/golangci-lint from 1.55.2 to 1.56.2
Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.55.2 to 1.56.2. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.55.2...v1.56.2) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/jgautheron/goconst/parser.go')
-rw-r--r--vendor/github.com/jgautheron/goconst/parser.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/vendor/github.com/jgautheron/goconst/parser.go b/vendor/github.com/jgautheron/goconst/parser.go
index c1edd4c78..2f32740b9 100644
--- a/vendor/github.com/jgautheron/goconst/parser.go
+++ b/vendor/github.com/jgautheron/goconst/parser.go
@@ -24,11 +24,11 @@ const (
type Parser struct {
// Meant to be passed via New()
- path, ignore string
- ignoreTests, matchConstant bool
- minLength, minOccurrences int
- numberMin, numberMax int
- excludeTypes map[Type]bool
+ path, ignore, ignoreStrings string
+ ignoreTests, matchConstant bool
+ minLength, minOccurrences int
+ numberMin, numberMax int
+ excludeTypes map[Type]bool
supportedTokens []token.Token
@@ -39,7 +39,7 @@ type Parser struct {
// New creates a new instance of the parser.
// This is your entry point if you'd like to use goconst as an API.
-func New(path, ignore string, ignoreTests, matchConstant, numbers bool, numberMin, numberMax, minLength, minOccurrences int, excludeTypes map[Type]bool) *Parser {
+func New(path, ignore, ignoreStrings string, ignoreTests, matchConstant, numbers bool, numberMin, numberMax, minLength, minOccurrences int, excludeTypes map[Type]bool) *Parser {
supportedTokens := []token.Token{token.STRING}
if numbers {
supportedTokens = append(supportedTokens, token.INT, token.FLOAT)
@@ -48,6 +48,7 @@ func New(path, ignore string, ignoreTests, matchConstant, numbers bool, numberMi
return &Parser{
path: path,
ignore: ignore,
+ ignoreStrings: ignoreStrings,
ignoreTests: ignoreTests,
matchConstant: matchConstant,
minLength: minLength,
@@ -98,6 +99,16 @@ func (p *Parser) ProcessResults() {
delete(p.strs, str)
}
+ if p.ignoreStrings != "" {
+ match, err := regexp.MatchString(p.ignoreStrings, str)
+ if err != nil {
+ log.Println(err)
+ }
+ if match {
+ delete(p.strs, str)
+ }
+ }
+
// If the value is a number
if i, err := strconv.ParseInt(str, 0, 0); err == nil {
if p.numberMin != 0 && i < int64(p.numberMin) {