Skip to content

fix(linter) : Add unparam checks and fix issues #2207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/operator-sdk/test/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ func testLocalFunc(cmd *cobra.Command, args []string) error {
case projutil.OperatorTypeGo:
return testLocalGoFunc(cmd, args)
case projutil.OperatorTypeAnsible:
return testLocalAnsibleFunc(cmd, args)
return testLocalAnsibleFunc()
case projutil.OperatorTypeHelm:
return fmt.Errorf("`test local` for Helm operators is not implemented")
}
return projutil.ErrUnknownOperatorType{}
}

func testLocalAnsibleFunc(cmd *cobra.Command, args []string) error {
func testLocalAnsibleFunc() error {
projutil.MustInProjectRoot()
testArgs := []string{}
if tlConfig.debug {
Expand Down
2 changes: 1 addition & 1 deletion hack/go-linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ golangci-lint run --disable-all \
--enable=goimports \
--enable=errcheck \
--enable=dupl \
--enable=unparam \

##todo(camilamacedo86): The following checks requires fixes in the code
# --enable=golint
# --enable=gocyclo
# --enable=lll
# --enable=gosec
# --enable=unparam \
9 changes: 4 additions & 5 deletions internal/scaffold/helm/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,12 @@ func scaffoldChart(destDir, apiVersion, kind string) (*scaffold.Resource, *chart

func fetchChart(destDir string, opts CreateChartOptions) (*scaffold.Resource, *chart.Chart, error) {
var (
stat os.FileInfo
chart *chart.Chart
err error
)

if stat, err = os.Stat(opts.Chart); err == nil {
chart, err = createChartFromDisk(destDir, opts.Chart, stat.IsDir())
if _, err = os.Stat(opts.Chart); err == nil {
chart, err = createChartFromDisk(destDir, opts.Chart)
} else {
chart, err = createChartFromRemote(destDir, opts)
}
Expand All @@ -214,7 +213,7 @@ func fetchChart(destDir string, opts CreateChartOptions) (*scaffold.Resource, *c
return r, chart, nil
}

func createChartFromDisk(destDir, source string, isDir bool) (*chart.Chart, error) {
func createChartFromDisk(destDir, source string) (*chart.Chart, error) {
chart, err := chartutil.Load(source)
if err != nil {
return nil, err
Expand Down Expand Up @@ -270,7 +269,7 @@ func createChartFromRemote(destDir string, opts CreateChartOptions) (*chart.Char
return nil, err
}

return createChartFromDisk(destDir, chartArchive, false)
return createChartFromDisk(destDir, chartArchive)
}

func fetchChartDependencies(chartPath string) error {
Expand Down
8 changes: 2 additions & 6 deletions internal/scaffold/olm-catalog/package_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ func (s *PackageManifest) CustomRender() ([]byte, error) {
return nil, errors.Wrapf(err, "failed to validate package manifest %s", pm.PackageName)
}

if err = s.setChannels(pm); err != nil {
return nil, err
}
s.setChannels(pm)

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

// setChannels checks for duplicate channels in pm and sets the default
// channel if possible.
func (s *PackageManifest) setChannels(pm *registry.PackageManifest) error {
func (s *PackageManifest) setChannels(pm *registry.PackageManifest) {
if s.Channel != "" {
channelIdx := -1
for i, channel := range pm.Channels {
Expand Down Expand Up @@ -169,6 +167,4 @@ func (s *PackageManifest) setChannels(pm *registry.PackageManifest) error {
if !defaultExists {
log.Warnf("Package manifest default channel %s does not exist in channels.", pm.DefaultChannelName)
}

return nil
}