Skip to content

Commit 7078b02

Browse files
Fixed integration tests
1 parent aad43de commit 7078b02

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

pkg/analysis/noreferences/analyzer.go

Lines changed: 5 additions & 6 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 {
@@ -78,8 +81,6 @@ func buildConventions(policy Policy) []namingconventions.Convention {
7881
switch policy {
7982
case PolicyPreferAbbreviatedReference:
8083
// Replace "Reference" or "References" with "Ref" or "Refs" anywhere in field name
81-
// Case insensitive to handle lowercase in JSON tags
82-
// Note: May produce false positives like "Preference" → "PRef", but this is acceptable
8384
return []namingconventions.Convention{
8485
{
8586
Name: "reference-to-ref",
@@ -92,8 +93,6 @@ func buildConventions(policy Policy) []namingconventions.Convention {
9293

9394
case PolicyNoReferences:
9495
// Warn about reference words anywhere in field name without providing fixes
95-
// Case insensitive to handle all variations
96-
// Note: May flag false positives like "Preference", but user is warned to manually review
9796
return []namingconventions.Convention{
9897
{
9998
Name: "no-references",
@@ -105,6 +104,6 @@ func buildConventions(policy Policy) []namingconventions.Convention {
105104

106105
default:
107106
// Should not happen due to validation
108-
panic(fmt.Errorf("invalid policy: %s", policy))
107+
panic(fmt.Errorf("%w: %s", errInvalidPolicy, policy))
109108
}
110109
}

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 (

tests/integration/testdata/default_configurations/volume.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ type ImageVolumeSource struct {
311311
// This field is optional to allow higher level config management to default or override
312312
// container images in workload controllers like Deployments and StatefulSets.
313313
// +optional
314-
Reference string `json:"reference,omitempty" protobuf:"bytes,1,opt,name=reference"` // want "optionalfields: field Reference should be a pointer."
314+
Reference string `json:"reference,omitempty" protobuf:"bytes,1,opt,name=reference"` // want "optionalfields: field Reference should be a pointer." "noreferences: naming convention \"reference-to-ref\": field Reference: field names should use 'Ref' instead of 'Reference'"
315315

316316
// Policy for pulling OCI objects. Possible values are: // want "commentstart: godoc for field PullPolicy should start with 'pullPolicy ...'"
317317
// Always: the kubelet always attempts to pull the reference. Container creation will fail If the pull fails.

0 commit comments

Comments
 (0)