From ecd429e19ef06227eedb398ca53e370cf53ac5d8 Mon Sep 17 00:00:00 2001 From: Yury Palyanitsa Date: Fri, 17 Jan 2025 18:17:07 +0200 Subject: [PATCH] Adjust golangci rules --- .golangci.yml | 7 +------ expression.go | 4 +--- parser.go | 5 ++++- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ba878b0..1d7c353 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -17,11 +17,6 @@ run: # This file contains only configs which differ from defaults. # All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml linters-settings: - nestif: - # Minimal complexity of if statements to report. - # Default: 5 - min-complexity: 12 - cyclop: # The maximal code complexity to report. # Default: 10 @@ -165,7 +160,7 @@ linters-settings: nolintlint: # Exclude following linters from requiring an explanation. # Default: [] - allow-no-explanation: [ funlen, gocognit, lll ] + allow-no-explanation: [ funlen, gocognit, lll, nestif ] # Enable to require an explanation of nonzero length after each nolint directive. # Default: false require-explanation: true diff --git a/expression.go b/expression.go index 9bd75d3..5b76e88 100644 --- a/expression.go +++ b/expression.go @@ -362,7 +362,7 @@ func (e *Expression) MatchIgnoreQuery(secondExpression Expression) (bool, error) return e.match(secondExpression, true) } -//nolint:gocyclo // func implements an alg with well-defined concrete purpose, so high cyclomatic complexity is ok here +//nolint:gocognit // func implements an alg with well-defined concrete purpose, so high cyclomatic complexity is ok here func (e *Expression) match(secondExpression Expression, ignoreQuery bool) (bool, error) { if e.AttributeSelector != "" { return false, fmt.Errorf("matching of CTI with attribute selector is not supported") @@ -457,8 +457,6 @@ func (e *Expression) match(secondExpression Expression, ignoreQuery bool) (bool, type DynamicParameterValues map[string]string // InterpolateDynamicParameterValues interpolates dynamic parameter values into the Expression. -// -//nolint:funlen // func implements an alg with well-defined concrete purpose, so high cyclomatic complexity is ok here func (e *Expression) InterpolateDynamicParameterValues(values DynamicParameterValues) (Expression, error) { var cpHead *Node var cpPrevNode *Node diff --git a/parser.go b/parser.go index e050cdc..db59b4a 100644 --- a/parser.go +++ b/parser.go @@ -198,6 +198,7 @@ func (p *Parser) MustParse(input string) Expression { return expr } +//nolint:funlen,gocyclo,gocognit // func implements an alg with well-defined concrete purpose, so high cyclomatic complexity is ok here func (p *Parser) parseExpression(s string, params parserParams) (Expression, error) { if !strings.HasPrefix(s, "cti.") { return emptyExpression, ErrNotExpression @@ -228,6 +229,7 @@ func (p *Parser) parseExpression(s string, params parserParams) (Expression, err var tail *Node for s != "" { + //nolint:nestif if head != nil { if tail.HasWildcard() { return emptyExpression, fmt.Errorf(`expression may have wildcard "%c" only at the end`, Wildcard) @@ -401,7 +403,7 @@ func (p *Parser) parseVendorOrPackage(s string) (identifier string, tail string, return val, s[i:], nil } -//nolint:funlen,gocyclo // func implements an alg with well-defined concrete purpose, so high cyclomatic complexity is ok here +//nolint:funlen,gocyclo,gocognit // func implements an alg with well-defined concrete purpose, so high cyclomatic complexity is ok here func (p *Parser) parseEntityNameAndVersion(s string) (name EntityName, ver Version, tail string, err error) { if s == "" { return "", Version{}, s, fmt.Errorf(`entity name cannot be empty`) @@ -451,6 +453,7 @@ loop: } case s[i] == Wildcard: + //nolint:nestif if i > 0 { //nolint:gocritic // if-else if more readable here than nested switch. if minorIdx != -1 {