diff --git a/.golangci.yml b/.golangci.yml index fb7c8748..4260037d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,7 +16,7 @@ linters: - errcheck - exhaustive - exportloopref - # - gochecknoinits + - gochecknoinits - gocognit - goconst - gocritic diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0627f5f3..f3fd55fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -149,10 +149,12 @@ type CheckFn func(*c.Checker) CheckResult Checks are registered in an init function: ```golang - AllChecks = append(AllChecks, NamedCheck{ - Name: "Code-Review", - Fn: DoesCodeReview, - }) +const codeReviewStr = "Code-Review" + +//nolint:gochecknoinits +func init() { + registerCheck(codeReviewStr, DoesCodeReview) +} ``` ### Updating Docs diff --git a/checks/active.go b/checks/active.go index 5f356d7d..21aeb3a9 100644 --- a/checks/active.go +++ b/checks/active.go @@ -26,6 +26,7 @@ const ( lookbackDays = 90 ) +//nolint:gochecknoinits func init() { registerCheck(activeStr, IsActive) } diff --git a/checks/branch_protected.go b/checks/branch_protected.go index 14461a28..c84551e5 100644 --- a/checks/branch_protected.go +++ b/checks/branch_protected.go @@ -24,6 +24,7 @@ const ( minReviews = 1 ) +//nolint:gochecknoinits func init() { registerCheck(branchProtectionStr, BranchProtection) } diff --git a/checks/ci_tests.go b/checks/ci_tests.go index d010ebe7..f1c61f7b 100644 --- a/checks/ci_tests.go +++ b/checks/ci_tests.go @@ -36,6 +36,7 @@ const ( githubCheckRuns ) +//nolint:gochecknoinits func init() { registerCheck(ciTestsStr, CITests) } diff --git a/checks/cii_best_practices.go b/checks/cii_best_practices.go index 66e3650e..ad94d8ef 100644 --- a/checks/cii_best_practices.go +++ b/checks/cii_best_practices.go @@ -25,6 +25,7 @@ import ( const ciiBestPracticesStr = "CII-Best-Practices" +//nolint:gochecknoinits func init() { registerCheck(ciiBestPracticesStr, CIIBestPractices) } diff --git a/checks/code_review.go b/checks/code_review.go index fe3fa577..8e569030 100644 --- a/checks/code_review.go +++ b/checks/code_review.go @@ -24,6 +24,7 @@ import ( const codeReviewStr = "Code-Review" +//nolint:gochecknoinits func init() { registerCheck(codeReviewStr, DoesCodeReview) } diff --git a/checks/contributors.go b/checks/contributors.go index ef6a60dc..043cf2ec 100644 --- a/checks/contributors.go +++ b/checks/contributors.go @@ -27,6 +27,7 @@ const ( contributorsStr = "Contributors" ) +//nolint:gochecknoinits func init() { registerCheck(contributorsStr, Contributors) } diff --git a/checks/frozen_deps.go b/checks/frozen_deps.go index 40ae51a6..4e0530eb 100644 --- a/checks/frozen_deps.go +++ b/checks/frozen_deps.go @@ -33,6 +33,7 @@ var ErrInvalidDockerfile = errors.New("invalid docker file") // ErrEmptyFile : Invalid docker file. var ErrEmptyFile = errors.New("file has no content") +//nolint:gochecknoinits func init() { registerCheck(frozenDepsStr, FrozenDeps) } diff --git a/checks/fuzzing.go b/checks/fuzzing.go index b533f117..c67de8c2 100644 --- a/checks/fuzzing.go +++ b/checks/fuzzing.go @@ -23,6 +23,7 @@ import ( const fuzzingStr = "Fuzzing" +//nolint:gochecknoinits func init() { registerCheck(fuzzingStr, Fuzzing) } diff --git a/checks/packaging.go b/checks/packaging.go index a9bd6f46..94667722 100644 --- a/checks/packaging.go +++ b/checks/packaging.go @@ -25,6 +25,7 @@ import ( const packagingStr = "Packaging" +//nolint:gochecknoinits func init() { registerCheck(packagingStr, Packaging) } diff --git a/checks/pull_requests.go b/checks/pull_requests.go index a2e0a589..17adf452 100644 --- a/checks/pull_requests.go +++ b/checks/pull_requests.go @@ -23,6 +23,7 @@ import ( const pullRequestsStr = "Pull-Requests" +//nolint:gochecknoinits func init() { registerCheck(pullRequestsStr, PullRequests) } diff --git a/checks/sast.go b/checks/sast.go index 78127ff0..c6558504 100644 --- a/checks/sast.go +++ b/checks/sast.go @@ -25,6 +25,7 @@ const sastStr = "SAST" var sastTools map[string]bool = map[string]bool{"github-code-scanning": true, "sonarcloud": true} +//nolint:gochecknoinits func init() { registerCheck(sastStr, SAST) } diff --git a/checks/security_policy.go b/checks/security_policy.go index 7af0ad68..c5279d24 100644 --- a/checks/security_policy.go +++ b/checks/security_policy.go @@ -22,6 +22,7 @@ import ( const securityPolicyStr = "Security-Policy" +//nolint:gochecknoinits func init() { registerCheck(securityPolicyStr, SecurityPolicy) } diff --git a/checks/signed_releases.go b/checks/signed_releases.go index 97e861ce..06a9f240 100644 --- a/checks/signed_releases.go +++ b/checks/signed_releases.go @@ -27,6 +27,7 @@ const ( releaseLookBackDays = 5 ) +//nolint:gochecknoinits func init() { registerCheck(signedReleasesStr, SignedReleases) } diff --git a/checks/signed_tags.go b/checks/signed_tags.go index 17a05da1..c66dc587 100644 --- a/checks/signed_tags.go +++ b/checks/signed_tags.go @@ -26,6 +26,7 @@ const ( tagLookBack = 5 ) +//nolint:gochecknoinits func init() { registerCheck(signedTagsStr, SignedTags) } diff --git a/cmd/root.go b/cmd/root.go index 652a4b7e..622a171d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -267,6 +267,7 @@ func fetchGitRepositoryFromRubyGems(packageName string) (string, error) { return v.SourceCodeURI, nil } +//nolint:gochecknoinits func init() { // Add the zap flag manually rootCmd.PersistentFlags().AddGoFlagSet(goflag.CommandLine) diff --git a/cmd/serve.go b/cmd/serve.go index a4f3f745..1884ce09 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -32,6 +32,7 @@ import ( "go.uber.org/zap" ) +//nolint:gochecknoinits func init() { rootCmd.AddCommand(serveCmd) }