mirror of
https://github.com/mgechev/revive.git
synced 2025-11-25 22:12:38 +02:00
chore: remove unused #region comments (#1181)
This commit is contained in:
@@ -11,8 +11,6 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// #region Revive API
|
|
||||||
|
|
||||||
// StringFormatRule lints strings and/or comments according to a set of regular expressions given as Arguments
|
// StringFormatRule lints strings and/or comments according to a set of regular expressions given as Arguments
|
||||||
type StringFormatRule struct{}
|
type StringFormatRule struct{}
|
||||||
|
|
||||||
@@ -56,10 +54,6 @@ func (StringFormatRule) ParseArgumentsTest(arguments lint.Arguments) *string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
// #region Internal structure
|
|
||||||
|
|
||||||
type lintStringFormatRule struct {
|
type lintStringFormatRule struct {
|
||||||
onFailure func(lint.Failure)
|
onFailure func(lint.Failure)
|
||||||
rules []stringFormatSubrule
|
rules []stringFormatSubrule
|
||||||
@@ -87,10 +81,6 @@ const identRegex = "[_A-Za-z][_A-Za-z0-9]*"
|
|||||||
var parseStringFormatScope = regexp.MustCompile(
|
var parseStringFormatScope = regexp.MustCompile(
|
||||||
fmt.Sprintf("^(%s(?:\\.%s)?)(?:\\[([0-9]+)\\](?:\\.(%s))?)?$", identRegex, identRegex, identRegex))
|
fmt.Sprintf("^(%s(?:\\.%s)?)(?:\\[([0-9]+)\\](?:\\.(%s))?)?$", identRegex, identRegex, identRegex))
|
||||||
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
// #region Argument parsing
|
|
||||||
|
|
||||||
func (w *lintStringFormatRule) parseArguments(arguments lint.Arguments) {
|
func (w *lintStringFormatRule) parseArguments(arguments lint.Arguments) {
|
||||||
for i, argument := range arguments {
|
for i, argument := range arguments {
|
||||||
scopes, regex, negated, errorMessage := w.parseArgument(argument, i)
|
scopes, regex, negated, errorMessage := w.parseArgument(argument, i)
|
||||||
@@ -196,10 +186,6 @@ func (lintStringFormatRule) parseScopeError(msg string, ruleNum, option, scopeNu
|
|||||||
panic(fmt.Sprintf("failed to parse configuration for string-format: %s [argument %d, option %d, scope index %d]", msg, ruleNum, option, scopeNum))
|
panic(fmt.Sprintf("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 {
|
func (w lintStringFormatRule) Visit(node ast.Node) ast.Visitor {
|
||||||
// First, check if node is a call expression
|
// First, check if node is a call expression
|
||||||
call, ok := node.(*ast.CallExpr)
|
call, ok := node.(*ast.CallExpr)
|
||||||
@@ -247,10 +233,6 @@ func (lintStringFormatRule) getCallName(call *ast.CallExpr) (callName string, ok
|
|||||||
return "", false
|
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)
|
// 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) {
|
func (r *stringFormatSubrule) apply(call *ast.CallExpr, scope *stringFormatSubruleScope) {
|
||||||
if len(call.Args) <= scope.argument {
|
if len(call.Args) <= scope.argument {
|
||||||
@@ -324,5 +306,3 @@ func (r *stringFormatSubrule) generateFailure(node ast.Node) {
|
|||||||
Node: node,
|
Node: node,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// #endregion
|
|
||||||
|
|||||||
Reference in New Issue
Block a user