diff --git a/.golangci.yml b/.golangci.yml index 73b7caf3..58498858 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -20,7 +20,6 @@ linters: - deadcode - depguard - dogsled - - dupl - errcheck - errorlint - exhaustive @@ -38,7 +37,6 @@ linters: - gofumpt - goheader - goimports - - gomnd - gomodguard - goprintffuncname - gosec @@ -53,7 +51,6 @@ linters: - noctx - nolintlint - paralleltest - - prealloc - predeclared - revive - rowserrcheck diff --git a/checker/check_result.go b/checker/check_result.go index b23b8b09..56b07992 100644 --- a/checker/check_result.go +++ b/checker/check_result.go @@ -169,7 +169,6 @@ func CreateResultWithScore(name, reason string, score int) CheckResult { Confidence: MaxResultScore, Pass: pass, // New structure. - //nolint Version: 2, Error2: nil, Score: score, @@ -195,7 +194,6 @@ func CreateProportionalScoreResult(name, reason string, b, t int) CheckResult { Confidence: MaxResultConfidence, Pass: pass, // New structure. - //nolint Version: 2, Error2: nil, Score: score, @@ -227,7 +225,6 @@ func CreateInconclusiveResult(name, reason string) CheckResult { Confidence: 0, Pass: false, // New structure. - //nolint Version: 2, Score: InconclusiveResultScore, Reason: reason, @@ -243,7 +240,6 @@ func CreateRuntimeErrorResult(name string, e error) CheckResult { Confidence: 0, Pass: false, // New structure. - //nolint Version: 2, Error2: e, Score: InconclusiveResultScore, diff --git a/checks/pinned_dependencies.go b/checks/pinned_dependencies.go index 0c821aed..49313893 100644 --- a/checks/pinned_dependencies.go +++ b/checks/pinned_dependencies.go @@ -272,7 +272,6 @@ func validateDockerfileIsFreeOfInsecureDownloads(pathfn string, content []byte, return false, sce.Create(sce.ErrScorecardInternal, fmt.Sprintf("%v: %v", errInternalInvalidDockerFile, err)) } - // nolint: prealloc var bytes []byte // Walk the Dockerfile's AST. diff --git a/checks/shell_download_validate.go b/checks/shell_download_validate.go index cfc8493c..159bdf6c 100644 --- a/checks/shell_download_validate.go +++ b/checks/shell_download_validate.go @@ -375,7 +375,7 @@ func isGoUnpinnedDownload(cmd []string) bool { // `Go install` will automatically look up the // go.mod and go.sum, so we don't flag it. - // nolint: gomnd + if len(cmd) <= 2 { return false } @@ -396,7 +396,7 @@ func isGoUnpinnedDownload(cmd []string) bool { pkg := cmd[i+1] // Verify pkg = name@hash parts := strings.Split(pkg, "@") - // nolint: gomnd + if len(parts) != 2 { continue } diff --git a/clients/githubrepo/checkruns.go b/clients/githubrepo/checkruns.go index e9e872be..53bdfb7c 100644 --- a/clients/githubrepo/checkruns.go +++ b/clients/githubrepo/checkruns.go @@ -48,7 +48,6 @@ func (handler *checkrunsHandler) listCheckRunsForRef(ref string) ([]clients.Chec } func checkRunsFrom(data *github.ListCheckRunsResults) []clients.CheckRun { - // nolint: prealloc // https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices var checkRuns []clients.CheckRun for _, checkRun := range data.CheckRuns { checkRuns = append(checkRuns, clients.CheckRun{ diff --git a/clients/githubrepo/releases.go b/clients/githubrepo/releases.go index 0464d434..a60a5694 100644 --- a/clients/githubrepo/releases.go +++ b/clients/githubrepo/releases.go @@ -63,7 +63,6 @@ func (handler *releasesHandler) getReleases() ([]clients.Release, error) { } func releasesFrom(data []*github.RepositoryRelease) []clients.Release { - // nolint: prealloc // https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices var releases []clients.Release for _, r := range data { release := clients.Release{ diff --git a/clients/githubrepo/statuses.go b/clients/githubrepo/statuses.go index 1d6b53c2..5ddc7546 100644 --- a/clients/githubrepo/statuses.go +++ b/clients/githubrepo/statuses.go @@ -48,7 +48,6 @@ func (handler *statusesHandler) listStatuses(ref string) ([]clients.Status, erro } func statusesFrom(data []*github.RepoStatus) []clients.Status { - // nolint: prealloc // https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices var statuses []clients.Status for _, status := range data { statuses = append(statuses, clients.Status{ diff --git a/clients/githubrepo/tarball.go b/clients/githubrepo/tarball.go index 1f0e2ed3..44ff2f8e 100644 --- a/clients/githubrepo/tarball.go +++ b/clients/githubrepo/tarball.go @@ -139,7 +139,6 @@ func (handler *tarballHandler) getTarball(ctx context.Context, repo *github.Repo // nolint: gocognit func (handler *tarballHandler) extractTarball() error { - // nolint: gomnd in, err := os.OpenFile(handler.tempTarFile, os.O_RDONLY, 0o644) if err != nil { return fmt.Errorf("os.OpenFile: %w", err) @@ -167,7 +166,7 @@ func (handler *tarballHandler) extractTarball() error { if dirpath == filepath.Clean(handler.tempDir) { continue } - // nolint: gomnd + if err := os.Mkdir(dirpath, 0o755); err != nil { return fmt.Errorf("error during os.Mkdir: %w", err) } @@ -181,7 +180,6 @@ func (handler *tarballHandler) extractTarball() error { } if _, err := os.Stat(filepath.Dir(filenamepath)); os.IsNotExist(err) { - // nolint: gomnd if err := os.Mkdir(filepath.Dir(filenamepath), 0o755); err != nil { return fmt.Errorf("os.Mkdir: %w", err) } diff --git a/clients/githubrepo/workflows.go b/clients/githubrepo/workflows.go index d680a5d7..254657e7 100644 --- a/clients/githubrepo/workflows.go +++ b/clients/githubrepo/workflows.go @@ -50,7 +50,6 @@ func (handler *workflowsHandler) listSuccessfulWorkflowRuns(filename string) ([] } func workflowsRunsFrom(data *github.WorkflowRuns) []clients.WorkflowRun { - // nolint: prealloc // https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices var workflowRuns []clients.WorkflowRun for _, workflowRun := range data.WorkflowRuns { workflowRuns = append(workflowRuns, clients.WorkflowRun{ diff --git a/cron/controller/main.go b/cron/controller/main.go index 714791c0..41940a09 100644 --- a/cron/controller/main.go +++ b/cron/controller/main.go @@ -90,11 +90,10 @@ func main() { ctx := context.Background() t := time.Now() - // nolint: gomnd if len(os.Args) != 2 { panic("must provide a single argument") } - // nolint: gomnd + inFile, err := os.OpenFile(os.Args[1], os.O_RDONLY, 0o644) if err != nil { panic(err) diff --git a/cron/data/add/main.go b/cron/data/add/main.go index 6fe09a8d..4b9a106e 100644 --- a/cron/data/add/main.go +++ b/cron/data/add/main.go @@ -32,11 +32,10 @@ import ( // Args: // path to input.csv output.csv func main() { - // nolint: gomnd if len(os.Args) != 3 { panic("must provide 2 arguments") } - // nolint: gomnd + inFile, err := os.OpenFile(os.Args[1], os.O_RDONLY, 0o644) if err != nil { panic(err) @@ -55,7 +54,7 @@ func main() { if err := data.SortAndAppendTo(&buf, repoURLs, nil); err != nil { panic(err) } - // nolint: gomnd + projects, err := os.OpenFile(os.Args[2], os.O_WRONLY|os.O_CREATE, 0o755) if err != nil { panic(err) diff --git a/cron/data/update/main.go b/cron/data/update/main.go index bfa1fdb9..df87b28f 100644 --- a/cron/data/update/main.go +++ b/cron/data/update/main.go @@ -26,11 +26,10 @@ import ( // Args: // file path to old_projects.csv new_projects.csv func main() { - // nolint: gomnd if len(os.Args) != 3 { panic("must provide 2 arguments") } - // nolint: gomnd + inFile, err := os.OpenFile(os.Args[1], os.O_RDONLY, 0o644) if err != nil { panic(err) @@ -46,7 +45,6 @@ func main() { panic(err) } - // nolint: gomnd projects, err := os.OpenFile(os.Args[2], os.O_CREATE|os.O_WRONLY, 0o644) if err != nil { panic(err) diff --git a/cron/data/validate/main.go b/cron/data/validate/main.go index b334b363..6e47a6a4 100644 --- a/cron/data/validate/main.go +++ b/cron/data/validate/main.go @@ -26,11 +26,10 @@ import ( // * Check for no duplicates in repoURLs. // * Check repoURL is a valid GitHub URL. func main() { - // nolint: gomnd if len(os.Args) != 2 { panic("must provide single argument") } - // nolint: gomnd + inFile, err := os.OpenFile(os.Args[1], os.O_RDONLY, 0o644) if err != nil { panic(err) diff --git a/e2e/binary_artifacts_test.go b/e2e/binary_artifacts_test.go index e3992c20..da165ce5 100644 --- a/e2e/binary_artifacts_test.go +++ b/e2e/binary_artifacts_test.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//nolint:dupl package e2e import ( diff --git a/e2e/ci_tests_test.go b/e2e/ci_tests_test.go index 37b86e40..1a331a14 100644 --- a/e2e/ci_tests_test.go +++ b/e2e/ci_tests_test.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// nolint: dupl package e2e import ( diff --git a/e2e/code_review_test.go b/e2e/code_review_test.go index a15a67f8..2c0339a4 100644 --- a/e2e/code_review_test.go +++ b/e2e/code_review_test.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// nolint: dupl package e2e import ( diff --git a/e2e/contributors_test.go b/e2e/contributors_test.go index 7886538e..a9877350 100644 --- a/e2e/contributors_test.go +++ b/e2e/contributors_test.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// nolint: dupl package e2e import ( diff --git a/e2e/dependency_update_tool_test.go b/e2e/dependency_update_tool_test.go index dff221b3..961c6dc9 100644 --- a/e2e/dependency_update_tool_test.go +++ b/e2e/dependency_update_tool_test.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//nolint:dupl package e2e import ( diff --git a/e2e/fuzzing_test.go b/e2e/fuzzing_test.go index 274ab470..d74da908 100644 --- a/e2e/fuzzing_test.go +++ b/e2e/fuzzing_test.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// nolint: dupl package e2e import ( diff --git a/e2e/packaging_test.go b/e2e/packaging_test.go index 68643a8f..262befba 100644 --- a/e2e/packaging_test.go +++ b/e2e/packaging_test.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// nolint: dupl package e2e import ( diff --git a/e2e/permissions_test.go b/e2e/permissions_test.go index 9cc3eaca..f9334e21 100644 --- a/e2e/permissions_test.go +++ b/e2e/permissions_test.go @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -//nolint:dupl package e2e import ( diff --git a/e2e/pinned_dependencies_test.go b/e2e/pinned_dependencies_test.go index 91f87ef0..07e84c30 100644 --- a/e2e/pinned_dependencies_test.go +++ b/e2e/pinned_dependencies_test.go @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -//nolint:dupl package e2e import ( diff --git a/e2e/security_policy_test.go b/e2e/security_policy_test.go index 29b8009c..b2a761eb 100644 --- a/e2e/security_policy_test.go +++ b/e2e/security_policy_test.go @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -//nolint:dupl package e2e import ( diff --git a/e2e/signedreleases_test.go b/e2e/signedreleases_test.go index b02c3f57..1afeb7d2 100644 --- a/e2e/signedreleases_test.go +++ b/e2e/signedreleases_test.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// nolint: dupl package e2e import ( diff --git a/pkg/common.go b/pkg/common.go index 4012817f..9b051bcd 100644 --- a/pkg/common.go +++ b/pkg/common.go @@ -34,9 +34,8 @@ func textToMarkdown(s string) string { // DetailToString turns a detail information into a string. func DetailToString(d *checker.CheckDetail, logLevel zapcore.Level) string { - // UPGRADEv3: remove swtch statement. + // UPGRADEv3: remove switch statement. switch d.Msg.Version { - //nolint case 3: if d.Type == checker.DetailDebug && logLevel != zapcore.DebugLevel { return ""