🌱 Fix lint issues: Replace golint with revive (#493)

* Fix lint issues: Replace golint with revive
golint is deprecated and recommended to be replaced with revive

* Updating comments to be more accurate

* Updating comments again

Co-authored-by: Azeem Shaikh <azeemshaikh38@gmail.com>
This commit is contained in:
Chris McGehee 2021-05-24 11:34:33 -07:00 committed by GitHub
parent 2d9a23b4bd
commit 6b63f3f963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 60 additions and 29 deletions

View File

@ -31,7 +31,6 @@ linters:
- gofumpt
- goheader
- goimports
# - golint
- gomnd
- gomodguard
- goprintffuncname
@ -49,6 +48,7 @@ linters:
- paralleltest
- prealloc
- predeclared
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck

View File

@ -18,6 +18,7 @@ import "errors"
const MaxResultConfidence = 10
// ErrorDemoninatorZero indicates the denominator for a proportional result is 0.
var ErrorDemoninatorZero = errors.New("internal error: denominator is 0")
type CheckResult struct {

View File

@ -81,7 +81,7 @@ func Bool2int(b bool) int {
return 0
}
// Returns the best check result out of several ones performed.
// MultiCheckOr returns the best check result out of several ones performed.
func MultiCheckOr(fns ...CheckFn) CheckFn {
return func(c *CheckRequest) CheckResult {
var maxResult CheckResult
@ -102,7 +102,7 @@ func MultiCheckOr(fns ...CheckFn) CheckFn {
}
}
// All checks must succeed. This returns a conservative result
// MultiCheckAnd means all checks must succeed. This returns a conservative result
// where the worst result is returned.
func MultiCheckAnd(fns ...CheckFn) CheckFn {
return func(c *CheckRequest) CheckResult {

View File

@ -16,6 +16,7 @@ package checks
import "github.com/ossf/scorecard/checker"
// AllChecks is the list of all security checks that will be run.
var AllChecks = checker.CheckNameToFnMap{}
func registerCheck(name string, fn checker.CheckFn) {

View File

@ -27,6 +27,7 @@ import (
"github.com/ossf/scorecard/checker"
)
// ErrReadFile indicates the header size does not match the size of the file.
var ErrReadFile = errors.New("could not read entire file")
// IsMatchingPath uses 'pattern' to shell-match the 'path' and its filename

View File

@ -25,6 +25,7 @@ import (
const codeReviewStr = "Code-Review"
// ErrorNoReviews indicates no reviews were found for this repo.
var ErrorNoReviews = errors.New("no reviews found")
//nolint:gochecknoinits

View File

@ -25,9 +25,11 @@ import (
const sastStr = "SAST"
var (
sastTools map[string]bool = map[string]bool{"github-code-scanning": true, "sonarcloud": true}
ErrorNoChecks = errors.New("no check runs found")
ErrorNoMerges = errors.New("no merges found")
sastTools = map[string]bool{"github-code-scanning": true, "sonarcloud": true}
// ErrorNoChecks indicates no GitHub Check runs were found for this repo.
ErrorNoChecks = errors.New("no check runs found")
// ErrorNoMerges indicates no merges with SAST tool runs were found for this repo.
ErrorNoMerges = errors.New("no merges found")
)
//nolint:gochecknoinits

View File

@ -28,6 +28,7 @@ const (
releaseLookBackDays = 5
)
// ErrorNoReleases indicates no releases were found for this repo.
var ErrorNoReleases = errors.New("no releases found")
//nolint:gochecknoinits

View File

@ -27,7 +27,8 @@ const (
tagLookBack = 5
)
var ErrorNoTags = errors.New("no signed tags found")
// ErrorNoTags indicates no tags were found for this repo.
var ErrorNoTags = errors.New("no tags found")
//nolint:gochecknoinits
func init() {

View File

@ -44,12 +44,13 @@ var (
checksToRun []string
metaData []string
// This one has to use goflag instead of pflag because it's defined by zap.
logLevel = zap.LevelFlag("verbosity", zap.InfoLevel, "override the default log level")
format string
npm string
pypi string
rubygems string
showDetails bool
logLevel = zap.LevelFlag("verbosity", zap.InfoLevel, "override the default log level")
format string
npm string
pypi string
rubygems string
showDetails bool
// ErrorInvalidFormatFlag indicates an invalid option was passed for the 'format' argument.
ErrorInvalidFormatFlag = errors.New("invalid format flag")
)

View File

@ -28,6 +28,7 @@ import (
)
const (
// ShardNumFilename is the name of the file that stores the number of shards.
ShardNumFilename string = ".shard_num"
projectID string = "SCORECARD_PROJECT_ID"
resultDataBucketURL string = "SCORECARD_DATA_BUCKET_URL"
@ -39,8 +40,10 @@ const (
)
var (
// ErrorEmptyConfigValue indicates the value for the configuration option was empty.
ErrorEmptyConfigValue = errors.New("config value set to empty")
ErrorValueConversion = errors.New("unexpected type, cannot convert value")
// ErrorValueConversion indicates an unexpected type was found for the value of the config option.
ErrorValueConversion = errors.New("unexpected type, cannot convert value")
//go:embed config.yaml
configYAML []byte
)

View File

@ -28,7 +28,7 @@ import (
)
func PublishToRepoRequestTopic(ctx context.Context, iter data.Iterator, datetime time.Time) (int32, error) {
var shardNum int32 = 0
var shardNum int32
request := data.ScorecardBatchRequest{
JobTime: timestamppb.New(datetime),
ShardNum: &shardNum,

View File

@ -28,6 +28,7 @@ import (
"github.com/ossf/scorecard/cron/data"
)
// ErrorInParse indicates there was an error while unmarshalling the protocol buffer message.
var ErrorInParse = errors.New("error during protojson.Unmarshal")
type Subscriber interface {

View File

@ -22,9 +22,12 @@ import (
)
var (
ErrorUnsupportedHost = errors.New("unsupported host")
// ErrorUnsupportedHost indicates the repo's host is unsupported.
ErrorUnsupportedHost = errors.New("unsupported host")
// ErrorInvalidGithubURL indicates the repo's GitHub URL is not in the proper format.
ErrorInvalidGithubURL = errors.New("invalid GitHub repo URL")
ErrorInvalidURL = errors.New("invalid repo flag")
// ErrorInvalidURL indicates the repo's full GitHub URL was not passed.
ErrorInvalidURL = errors.New("invalid repo flag")
)
type RepoURL struct {

View File

@ -27,15 +27,23 @@ import (
)
const (
GithubAuthToken = "GITHUB_AUTH_TOKEN" // #nosec G101
GithubAppKeyPath = "GITHUB_APP_KEY_PATH"
GithubAppID = "GITHUB_APP_ID"
GithubAppInstallationID = "GITHUB_APP_INSTALLATION_ID"
UseDiskCache = "USE_DISK_CACHE"
DiskCachePath = "DISK_CACHE_PATH"
UseBlobCache = "USE_BLOB_CACHE"
BucketURL = "BLOB_URL"
cacheSize uint64 = 10000 * 1024 * 1024 // 10gb
// GithubAuthToken is for making requests to GiHub's API.
GithubAuthToken = "GITHUB_AUTH_TOKEN" // #nosec G101
// GithubAppKeyPath is the path to file for GitHub App key.
GithubAppKeyPath = "GITHUB_APP_KEY_PATH"
// GithubAppID is the app ID for the GitHub App.
GithubAppID = "GITHUB_APP_ID"
// GithubAppInstallationID is the installation ID for the GitHub App.
GithubAppInstallationID = "GITHUB_APP_INSTALLATION_ID"
// UseDiskCache will cache results on disk for subsequent runs if set to true.
UseDiskCache = "USE_DISK_CACHE"
// DiskCachePath is the path to where the results will be cached on disk if UseDiskCache is true.
DiskCachePath = "DISK_CACHE_PATH"
// UseBlobCache will cache results into a blob store for subsequent runs if set to true.
UseBlobCache = "USE_BLOB_CACHE"
// BucketURL is the URL for blob store cache if UseBlobCache is true.
BucketURL = "BLOB_URL"
cacheSize uint64 = 10000 * 1024 * 1024 // 10gb
)
// NewTransport returns a configured http.Transport for use with GitHub.

View File

@ -17,6 +17,8 @@ package stats
import "go.opencensus.io/stats"
var (
// CPURuntimeInSec measures the CPU runtime in seconds.
CPURuntimeInSec = stats.Int64("CPURuntimeInSec", "Measures the CPU runtime in seconds", stats.UnitSeconds)
HTTPRequests = stats.Int64("HTTPRequests", "Measures the count of HTTP requests", stats.UnitDimensionless)
// HTTPRequests measures the count of HTTP requests.
HTTPRequests = stats.Int64("HTTPRequests", "Measures the count of HTTP requests", stats.UnitDimensionless)
)

View File

@ -17,7 +17,10 @@ package stats
import "go.opencensus.io/tag"
var (
CheckName = tag.MustNewKey("checkName")
Repo = tag.MustNewKey("repo")
// CheckName is the tag key for the check name.
CheckName = tag.MustNewKey("checkName")
// Repo is the tag key for the repo name.
Repo = tag.MustNewKey("repo")
// RequestTag is the tag key for the request type.
RequestTag = tag.MustNewKey("requestTag")
)

View File

@ -21,6 +21,7 @@ import (
)
var (
// CheckRuntime tracks CPU runtime stats.
CheckRuntime = view.View{
Name: "CheckRuntime",
Description: "CPU runtime stats per repo per check",
@ -45,6 +46,7 @@ var (
1<<16),
}
// OutgoingHTTPRequests tracks HTTPRequests made.
OutgoingHTTPRequests = view.View{
Name: "OutgoingHTTPRequests",
Description: "HTTPRequests made per repo per check per URL path",