Skip to content

Commit

Permalink
Merge branch 'master' into rules-avoid-using-panic
Browse files Browse the repository at this point in the history
# Conflicts:
#	rule/string_format.go
  • Loading branch information
mfederowicz committed Dec 10, 2024
2 parents 1628b5c + 10d9697 commit 96de931
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
2 changes: 1 addition & 1 deletion lint/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func (l *Linter) Lint(packages [][]string, ruleSet []Rule, config Config) (<-cha
}

var wg sync.WaitGroup
wg.Add(len(packages))
for n := range packages {
wg.Add(1)
go func(pkg []string, gover *goversion.Version) {
if err := l.lintPackage(pkg, gover, ruleSet, config, failures); err != nil {
fmt.Fprintln(os.Stderr, "error during linting: "+err.Error())
Expand Down
20 changes: 0 additions & 20 deletions rule/string_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/mgechev/revive/lint"
)

// #region Revive API

// StringFormatRule lints strings and/or comments according to a set of regular expressions given as Arguments
type StringFormatRule struct{}

Expand Down Expand Up @@ -59,10 +57,6 @@ func (StringFormatRule) ParseArgumentsTest(arguments lint.Arguments) *string {
return nil
}

// #endregion

// #region Internal structure

type lintStringFormatRule struct {
onFailure func(lint.Failure)
rules []stringFormatSubrule
Expand Down Expand Up @@ -90,10 +84,6 @@ const identRegex = "[_A-Za-z][_A-Za-z0-9]*"
var parseStringFormatScope = regexp.MustCompile(
fmt.Sprintf("^(%s(?:\\.%s)?)(?:\\[([0-9]+)\\](?:\\.(%s))?)?$", identRegex, identRegex, identRegex))

// #endregion

// #region Argument parsing

func (w *lintStringFormatRule) parseArguments(arguments lint.Arguments) error {
for i, argument := range arguments {
scopes, regex, negated, errorMessage, err := w.parseArgument(argument, i)
Expand Down Expand Up @@ -203,10 +193,6 @@ func (lintStringFormatRule) parseScopeError(msg string, ruleNum, option, scopeNu
return fmt.Errorf("failed to parse configuration for string-format: %s [argument %d, option %d, scope index %d]", msg, ruleNum, option, scopeNum)
}

// #endregion

// #region Node traversal

func (w lintStringFormatRule) Visit(node ast.Node) ast.Visitor {
// First, check if node is a call expression
call, ok := node.(*ast.CallExpr)
Expand Down Expand Up @@ -254,10 +240,6 @@ func (lintStringFormatRule) getCallName(call *ast.CallExpr) (callName string, ok
return "", false
}

// #endregion

// #region Linting logic

// apply a single format rule to a call expression (should be done after verifying the that the call expression matches the rule's scope)
func (r *stringFormatSubrule) apply(call *ast.CallExpr, scope *stringFormatSubruleScope) {
if len(call.Args) <= scope.argument {
Expand Down Expand Up @@ -331,5 +313,3 @@ func (r *stringFormatSubrule) generateFailure(node ast.Node) {
Node: node,
})
}

// #endregion

0 comments on commit 96de931

Please sign in to comment.