Skip to content

Commit

Permalink
cleanup after review
Browse files Browse the repository at this point in the history
  • Loading branch information
mfederowicz committed Dec 10, 2024
1 parent ed5e149 commit 1628b5c
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion rule/add_constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (r *AddConstantRule) Apply(file *lint.File, arguments lint.Arguments) []lin
return failures
}


// Name returns the rule name.
func (*AddConstantRule) Name() string {
return "add-constant"
Expand Down
2 changes: 1 addition & 1 deletion rule/enforce_slice_style.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (r *EnforceSliceStyleRule) configure(arguments lint.Arguments) error {
var err error
r.enforceSliceStyle, err = sliceStyleFromString(enforceSliceStyle)
if err != nil {
return fmt.Errorf("invalid argument to the enforce-slice-style rule: %v", err)
return fmt.Errorf("invalid argument to the enforce-slice-style rule: %w", err)
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions rule/file_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (r *FileHeaderRule) Apply(file *lint.File, arguments lint.Arguments) []lint
r.configureOnce.Do(func() { configureErr = r.configure(arguments) })

if configureErr != nil {
return newInternalFailureError(configureErr)
return []lint.Failure{lint.NewInternalFailure(configureErr.Error())}
}

if r.header == "" {
Expand Down Expand Up @@ -75,7 +75,7 @@ func (r *FileHeaderRule) Apply(file *lint.File, arguments lint.Arguments) []lint

regex, err := regexp.Compile(r.header)
if err != nil {
return []lint.Failure{lint.NewInternalFailure(err.Error())}
return newInternalFailureError(err)
}

if !regex.MatchString(comment) {
Expand Down
2 changes: 1 addition & 1 deletion rule/file_length_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (r *FileLengthLimitRule) Apply(file *lint.File, arguments lint.Arguments) [
}

if err := scanner.Err(); err != nil {
return []lint.Failure{lint.NewInternalFailure(err.Error())}
return newInternalFailureError(err)
}

lines := all
Expand Down
4 changes: 2 additions & 2 deletions rule/import_alias_naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (r *ImportAliasNamingRule) setAllowRule(value any) error {

namingRuleRegexp, err := regexp.Compile(namingRule)
if err != nil {
return fmt.Errorf("invalid argument to the import-alias-naming allowRegexp rule. Expecting %q to be a valid regular expression, got: %v", namingRule, err)
return fmt.Errorf("invalid argument to the import-alias-naming allowRegexp rule. Expecting %q to be a valid regular expression, got: %w", namingRule, err)
}
r.allowRegexp = namingRuleRegexp
return nil
Expand All @@ -131,7 +131,7 @@ func (r *ImportAliasNamingRule) setDenyRule(value any) error {

namingRuleRegexp, err := regexp.Compile(namingRule)
if err != nil {
return fmt.Errorf("invalid argument to the import-alias-naming denyRegexp rule. Expecting %q to be a valid regular expression, got: %v", namingRule, err)
return fmt.Errorf("invalid argument to the import-alias-naming denyRegexp rule. Expecting %q to be a valid regular expression, got: %w", namingRule, err)
}
r.denyRegexp = namingRuleRegexp
return nil
Expand Down
6 changes: 3 additions & 3 deletions rule/max_public_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func (r *MaxPublicStructsRule) configure(arguments lint.Arguments) error {
return nil
}

check := checkNumberOfArguments(1, arguments, r.Name())
if check != nil {
return check
err := checkNumberOfArguments(1, arguments, r.Name())
if err != nil {
return err
}

maxStructs, ok := arguments[0].(int64) // Alt. non panicking version
Expand Down
2 changes: 1 addition & 1 deletion rule/string_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (*StringFormatRule) Apply(file *lint.File, arguments lint.Arguments) []lint
w := lintStringFormatRule{onFailure: onFailure}
err := w.parseArguments(arguments)
if err != nil {
return []lint.Failure{lint.NewInternalFailure(err.Error())}
return newInternalFailureError(err)
}

ast.Walk(w, file.AST)
Expand Down
6 changes: 3 additions & 3 deletions rule/struct_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func (r *StructTagRule) configure(arguments lint.Arguments) error {
return nil
}

check := checkNumberOfArguments(1, arguments, r.Name())
if check != nil {
return check
err := checkNumberOfArguments(1, arguments, r.Name())
if err != nil {
return err
}
r.userDefined = make(map[string][]string, len(arguments))
for _, arg := range arguments {
Expand Down

0 comments on commit 1628b5c

Please sign in to comment.