Skip to content

Commit

Permalink
Adjust golangci rules
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-palyanitsa committed Jan 17, 2025
1 parent 3382237 commit ecd429e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
7 changes: 1 addition & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 201 in parser.go

View workflow job for this annotation

GitHub Actions / build

directive `//nolint:funlen,gocyclo,gocognit // func implements an alg with well-defined concrete purpose, so high cyclomatic complexity is ok here` is unused for linter "gocyclo" (nolintlint)
func (p *Parser) parseExpression(s string, params parserParams) (Expression, error) {
if !strings.HasPrefix(s, "cti.") {
return emptyExpression, ErrNotExpression
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {

Check failure on line 407 in parser.go

View workflow job for this annotation

GitHub Actions / build

calculated cyclomatic complexity for function parseEntityNameAndVersion is 43, max is 30 (cyclop)
if s == "" {
return "", Version{}, s, fmt.Errorf(`entity name cannot be empty`)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ecd429e

Please sign in to comment.