Skip to content

[Alizer] Enable all default golangci-lint linters and fix errors reported #1302

@rm3l

Description

@rm3l

Which area/kind this issue is related to?

/area alizer

Issue Description

devfile/alizer#34 (part of #1257) introduced golangci-lint [1] as a linter aggregator, using the depguard linter to enforce that the deprecated io/ioutil package could not be used anymore.

golangci-lint comes with a set of default linters enabled by default, which currently report a few and relevant issues. Fixing those issues was actually outside of the scope of #1257 (focusing on the io/ioutil package); so they were disabled in devfile/alizer#34. But it makes sense to actually enable those default linters and fix the relevant issues reported.

Example of issues reported by `golangci-lint`
golangci-lint run ./... --timeout 15m
pkg/utils/detector.go:149:3: Error return value is not checked (errcheck)
	}()
	 ^
pkg/utils/detector.go:361:5: Error return value is not checked (errcheck)
			}()
			 ^
pkg/utils/logger_test.go:86:14: Error return value is not checked (errcheck)
				GenLogger("info")
				         ^
pkg/utils/langfiles/languages_file_handler.go:187:3: S1011: should replace loop with `excludedFolders = append(excludedFolders, langItem.ExcludeFolders...)` (gosimple)
		for _, exclude := range langItem.ExcludeFolders {
		^
test/check_registry/check_registry.go:113:3: Error return value is not checked (errcheck)
	}()
	 ^
pkg/apis/enricher/framework/dotnet/dotnet_detector.go:81:3: Error return value is not checked (errcheck)
	}()
	 ^
pkg/apis/enricher/framework/javascript/nodejs/nuxt_detector.go:48:2: ineffectual assignment to ports (ineffassign)
	ports := []int{}
	^
pkg/apis/enricher/framework/javascript/nodejs/vue_detector.go:49:2: ineffectual assignment to ports (ineffassign)
	ports := []int{}
	^
pkg/apis/enricher/enricher.go:134:5: Error return value is not checked (errcheck)
			}()
			 ^
pkg/apis/enricher/docker_enricher.go:42:2: S1021: should merge variable declaration with assignment on next line (gosimple)
	var ports []int
	^
pkg/apis/enricher/docker_enricher.go:35:2: S1023: redundant `return` statement (gosimple)
	return
	^
pkg/apis/enricher/docker_enricher.go:47:2: S1023: redundant `return` statement (gosimple)
	return
	^
pkg/apis/recognizer/devfile_recognizer.go:250:3: Error return value is not checked (errcheck)
	}()
	 ^
test/apis/utils.go:27:3: Error return value is not checked (errcheck)
	}()
	 ^

Acceptance Criteria

  • it should enable all default linters in golangci-lint config file
  • it should fix all issues reported by golangci-lint
  • make lint should pass

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done ✅

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions