Skip to content

Commit d147bb3

Browse files
fix(linter) : Add unparam checks and fix issues (#2207)
* fix(linter) : Add unparam checks and fix issues
1 parent 7a5bb22 commit d147bb3

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

cmd/operator-sdk/test/local.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ func testLocalFunc(cmd *cobra.Command, args []string) error {
8383
case projutil.OperatorTypeGo:
8484
return testLocalGoFunc(cmd, args)
8585
case projutil.OperatorTypeAnsible:
86-
return testLocalAnsibleFunc(cmd, args)
86+
return testLocalAnsibleFunc()
8787
case projutil.OperatorTypeHelm:
8888
return fmt.Errorf("`test local` for Helm operators is not implemented")
8989
}
9090
return projutil.ErrUnknownOperatorType{}
9191
}
9292

93-
func testLocalAnsibleFunc(cmd *cobra.Command, args []string) error {
93+
func testLocalAnsibleFunc() error {
9494
projutil.MustInProjectRoot()
9595
testArgs := []string{}
9696
if tlConfig.debug {

hack/go-linter.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ golangci-lint run --disable-all \
2020
--enable=goimports \
2121
--enable=errcheck \
2222
--enable=dupl \
23+
--enable=unparam \
2324

2425
##todo(camilamacedo86): The following checks requires fixes in the code
2526
# --enable=golint
2627
# --enable=gocyclo
2728
# --enable=lll
2829
# --enable=gosec
29-
# --enable=unparam \

internal/scaffold/helm/chart.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,12 @@ func scaffoldChart(destDir, apiVersion, kind string) (*scaffold.Resource, *chart
185185

186186
func fetchChart(destDir string, opts CreateChartOptions) (*scaffold.Resource, *chart.Chart, error) {
187187
var (
188-
stat os.FileInfo
189188
chart *chart.Chart
190189
err error
191190
)
192191

193-
if stat, err = os.Stat(opts.Chart); err == nil {
194-
chart, err = createChartFromDisk(destDir, opts.Chart, stat.IsDir())
192+
if _, err = os.Stat(opts.Chart); err == nil {
193+
chart, err = createChartFromDisk(destDir, opts.Chart)
195194
} else {
196195
chart, err = createChartFromRemote(destDir, opts)
197196
}
@@ -214,7 +213,7 @@ func fetchChart(destDir string, opts CreateChartOptions) (*scaffold.Resource, *c
214213
return r, chart, nil
215214
}
216215

217-
func createChartFromDisk(destDir, source string, isDir bool) (*chart.Chart, error) {
216+
func createChartFromDisk(destDir, source string) (*chart.Chart, error) {
218217
chart, err := chartutil.Load(source)
219218
if err != nil {
220219
return nil, err
@@ -270,7 +269,7 @@ func createChartFromRemote(destDir string, opts CreateChartOptions) (*chart.Char
270269
return nil, err
271270
}
272271

273-
return createChartFromDisk(destDir, chartArchive, false)
272+
return createChartFromDisk(destDir, chartArchive)
274273
}
275274

276275
func fetchChartDependencies(chartPath string) error {

internal/scaffold/olm-catalog/package_manifest.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ func (s *PackageManifest) CustomRender() ([]byte, error) {
101101
return nil, errors.Wrapf(err, "failed to validate package manifest %s", pm.PackageName)
102102
}
103103

104-
if err = s.setChannels(pm); err != nil {
105-
return nil, err
106-
}
104+
s.setChannels(pm)
107105

108106
sort.Slice(pm.Channels, func(i int, j int) bool {
109107
return pm.Channels[i].Name < pm.Channels[j].Name
@@ -132,7 +130,7 @@ func (s *PackageManifest) newPackageManifest() *registry.PackageManifest {
132130

133131
// setChannels checks for duplicate channels in pm and sets the default
134132
// channel if possible.
135-
func (s *PackageManifest) setChannels(pm *registry.PackageManifest) error {
133+
func (s *PackageManifest) setChannels(pm *registry.PackageManifest) {
136134
if s.Channel != "" {
137135
channelIdx := -1
138136
for i, channel := range pm.Channels {
@@ -169,6 +167,4 @@ func (s *PackageManifest) setChannels(pm *registry.PackageManifest) error {
169167
if !defaultExists {
170168
log.Warnf("Package manifest default channel %s does not exist in channels.", pm.DefaultChannelName)
171169
}
172-
173-
return nil
174170
}

0 commit comments

Comments
 (0)