Skip to content

Commit

Permalink
🌱 Enable if-return linter check and fix issues for Kubebuilder CLI (#…
Browse files Browse the repository at this point in the history
…4461)

Enable if-return linter check and fix issues for Kubebuilder CLI
  • Loading branch information
camilamacedo86 authored Jan 1, 2025
1 parent bab2741 commit 4f1a0bf
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 40 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ linters-settings:
- name: exported
disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings.
- name: if-return
disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings.
- name: increment-decrement
- name: var-naming
- name: var-declaration
Expand Down
7 changes: 1 addition & 6 deletions pkg/cli/alpha/internal/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ func (opts *Generate) Generate() error {
return err
}
}

if err := migrateDeployImagePlugin(config); err != nil {
return err
}

return nil
return migrateDeployImagePlugin(config)
}

// Validate ensures the options are valid and kubebuilder is installed.
Expand Down
6 changes: 1 addition & 5 deletions pkg/plugins/common/kustomize/v2/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ func (p *initSubcommand) InjectConfig(c config.Config) error {
if err := validation.IsDNS1123Label(p.name); err != nil {
return fmt.Errorf("project name (%s) is invalid: %v", p.name, err)
}
if err := p.config.SetProjectName(p.name); err != nil {
return err
}

return nil
return p.config.SetProjectName(p.name)
}

func (p *initSubcommand) Scaffold(fs machinery.Filesystem) error {
Expand Down
6 changes: 1 addition & 5 deletions pkg/plugins/golang/deploy-image/v1alpha1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,7 @@ func (p *createAPISubcommand) Scaffold(fs machinery.Filesystem) error {
Kind: p.resource.GVK.Kind,
Options: configDataOptions,
})
if err := p.config.EncodePluginConfig(pluginKey, cfg); err != nil {
return err
}

return nil
return p.config.EncodePluginConfig(pluginKey, cfg)
}

func (p *createAPISubcommand) PostScaffold() error {
Expand Down
6 changes: 1 addition & 5 deletions pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ func (s *apiScaffolder) Scaffold() error {
return fmt.Errorf("error creating controller/**_controller_test.go: %v", err)
}

if err := s.addEnvVarIntoManager(); err != nil {
return err
}

return nil
return s.addEnvVarIntoManager()
}

// addEnvVarIntoManager will update the config/manager/manager.yaml by adding
Expand Down
6 changes: 1 addition & 5 deletions pkg/plugins/optional/helm/v1alpha/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,5 @@ func (p *editSubcommand) Scaffold(fs machinery.Filesystem) error {
}

// Track the resources following a declarative approach
if err := insertPluginMetaToConfig(p.config, pluginConfig{}); err != nil {
return err
}

return nil
return insertPluginMetaToConfig(p.config, pluginConfig{})
}
6 changes: 1 addition & 5 deletions pkg/plugins/optional/helm/v1alpha/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,5 @@ func (p *initSubcommand) Scaffold(fs machinery.Filesystem) error {
}

// Track the resources following a declarative approach
if err := insertPluginMetaToConfig(p.config, pluginConfig{}); err != nil {
return err
}

return nil
return insertPluginMetaToConfig(p.config, pluginConfig{})
}
10 changes: 2 additions & 8 deletions test/e2e/utils/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ func (v *KubernetesVersion) prepare() error {
if err := v.ClientVersion.parseVersionInts(); err != nil {
return err
}
if err := v.ServerVersion.parseVersionInts(); err != nil {
return err
}
return nil
return v.ServerVersion.parseVersionInts()
}

// Version is a func to run kubectl version command
Expand All @@ -158,8 +155,5 @@ func (v *KubernetesVersion) decode(out string) (err error) {
if err := dec.Decode(&v); err != nil {
return err
}
if err := v.prepare(); err != nil {
return err
}
return nil
return v.prepare()
}

0 comments on commit 4f1a0bf

Please sign in to comment.