Skip to content

Commit 9b85f8b

Browse files
Fixed test failures
1 parent 984f82e commit 9b85f8b

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

pkg/analysis/noreferences/analyzer.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ const (
3030
doc = "Enforces that fields use Ref/Refs and not Reference/References"
3131
)
3232

33-
var errUnexpectedInitializerType = errors.New("expected namingconventions.Initializer() to be of type initializer.ConfigurableAnalyzerInitializer, but was not")
33+
var (
34+
errUnexpectedInitializerType = errors.New("expected namingconventions.Initializer() to be of type initializer.ConfigurableAnalyzerInitializer, but was not")
35+
errInvalidPolicy = errors.New("invalid policy")
36+
)
3437

3538
// newAnalyzer creates a new analyzer for the noreferences linter that is a wrapper around the namingconventions linter.
3639
func newAnalyzer(cfg *Config) *analysis.Analyzer {
@@ -105,6 +108,6 @@ func buildConventions(policy Policy) []namingconventions.Convention {
105108

106109
default:
107110
// Should not happen due to validation
108-
panic(fmt.Errorf("invalid policy: %s", policy))
111+
panic(fmt.Errorf("%w: %s", errInvalidPolicy, policy))
109112
}
110113
}

pkg/analysis/noreferences/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License.
1515
*/
1616
package noreferences
1717

18-
// policy defines the policy for handling references in field names.
18+
// Policy defines the policy for handling references in field names.
1919
type Policy string
2020

2121
const (

pkg/analysis/noreferences/initializer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ func validateConfig(cfg *Config, fldPath *field.Path) field.ErrorList {
5959
[]string{string(PolicyPreferAbbreviatedReference), string(PolicyNoReferences)},
6060
))
6161
}
62+
6263
return errs
6364
}

0 commit comments

Comments
 (0)