Fix lint issues: golint linter

This commit is contained in:
Chris McGehee 2021-05-02 12:35:29 -07:00 committed by Naveen
parent a4e8751d73
commit 6a7142fe21
21 changed files with 29 additions and 28 deletions

View File

@ -26,7 +26,7 @@ type CheckRequest struct {
Ctx context.Context Ctx context.Context
Client *github.Client Client *github.Client
GraphClient *githubv4.Client GraphClient *githubv4.Client
HttpClient *http.Client HTTPClient *http.Client
Owner, Repo string Owner, Repo string
Logf func(s string, f ...interface{}) Logf func(s string, f ...interface{})
} }

View File

@ -34,13 +34,13 @@ type response struct {
} }
func CIIBestPractices(c *checker.CheckRequest) checker.CheckResult { func CIIBestPractices(c *checker.CheckRequest) checker.CheckResult {
repoUrl := fmt.Sprintf("https://github.com/%s/%s", c.Owner, c.Repo) repoURL := fmt.Sprintf("https://github.com/%s/%s", c.Owner, c.Repo)
url := fmt.Sprintf("https://bestpractices.coreinfrastructure.org/projects.json?url=%s", repoUrl) url := fmt.Sprintf("https://bestpractices.coreinfrastructure.org/projects.json?url=%s", repoURL)
req, err := http.NewRequestWithContext(c.Ctx, "GET", url, nil) req, err := http.NewRequestWithContext(c.Ctx, "GET", url, nil)
if err != nil { if err != nil {
return checker.MakeRetryResult(ciiBestPracticesStr, err) return checker.MakeRetryResult(ciiBestPracticesStr, err)
} }
resp, err := c.HttpClient.Do(req) resp, err := c.HTTPClient.Do(req)
if err != nil { if err != nil {
return checker.MakeRetryResult(ciiBestPracticesStr, err) return checker.MakeRetryResult(ciiBestPracticesStr, err)
} }

View File

@ -100,7 +100,7 @@ or ./scorecard --{npm,pypi,rubgems}=<package_name> [--checks=check1,...] [--show
} }
} }
if err := repo.ValidGitHubUrl(); err != nil { if err := repo.ValidGitHubURL(); err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -67,7 +67,7 @@ func main() {
if err := repoURL.Set(r.Repo); err != nil { if err := repoURL.Set(r.Repo); err != nil {
panic(err) panic(err)
} }
if err := repoURL.ValidGitHubUrl(); err != nil { if err := repoURL.ValidGitHubURL(); err != nil {
panic(err) panic(err)
} }

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:Active", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "apache", Owner: "apache",
Repo: "airflow", Repo: "airflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:Branch Protection", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "apache", Owner: "apache",
Repo: "airflow", Repo: "airflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:CITests", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "apache", Owner: "apache",
Repo: "airflow", Repo: "airflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:CIIBestPractices", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "tensorflow", Owner: "tensorflow",
Repo: "tensorflow", Repo: "tensorflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:CodeReview", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "apache", Owner: "apache",
Repo: "airflow", Repo: "airflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:CodeReview", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "ossf", Owner: "ossf",
Repo: "scorecard", Repo: "scorecard",
GraphClient: graphClient, GraphClient: graphClient,
@ -45,7 +45,7 @@ var _ = Describe("E2E TEST:CodeReview", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "apache", Owner: "apache",
Repo: "airflow", Repo: "airflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:FrozenDeps", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "tensorflow", Owner: "tensorflow",
Repo: "tensorflow", Repo: "tensorflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:Fuzzing", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "tensorflow", Owner: "tensorflow",
Repo: "tensorflow", Repo: "tensorflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:Packaging", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "apache", Owner: "apache",
Repo: "orc", Repo: "orc",
GraphClient: graphClient, GraphClient: graphClient,
@ -45,7 +45,7 @@ var _ = Describe("E2E TEST:Packaging", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "ossf", Owner: "ossf",
Repo: "scorecard", Repo: "scorecard",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:PullRequests", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "apache", Owner: "apache",
Repo: "airflow", Repo: "airflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:SAST", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "apache", Owner: "apache",
Repo: "airflow", Repo: "airflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:SecurityPolicy", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "tensorflow", Owner: "tensorflow",
Repo: "tensorflow", Repo: "tensorflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -30,7 +30,7 @@ var _ = Describe("E2E TEST:Signedreleases", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "apache", Owner: "apache",
Repo: "airflow", Repo: "airflow",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -31,7 +31,7 @@ var _ = Describe("E2E TEST:Signedtags", func() {
checkRequest := checker.CheckRequest{ checkRequest := checker.CheckRequest{
Ctx: context.Background(), Ctx: context.Background(),
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: "bitcoin", Owner: "bitcoin",
Repo: "bitcoin", Repo: "bitcoin",
GraphClient: graphClient, GraphClient: graphClient,

View File

@ -47,7 +47,7 @@ func runEnabledChecks(ctx context.Context, logger *zap.SugaredLogger, repo repos
c := checker.CheckRequest{ c := checker.CheckRequest{
Ctx: ctx, Ctx: ctx,
Client: ghClient, Client: ghClient,
HttpClient: client, HTTPClient: client,
Owner: repo.Owner, Owner: repo.Owner,
Repo: repo.Repo, Repo: repo.Repo,
GraphClient: graphClient, GraphClient: graphClient,
@ -64,7 +64,7 @@ func runEnabledChecks(ctx context.Context, logger *zap.SugaredLogger, repo repos
func RunScorecards(ctx context.Context, logger *zap.SugaredLogger, func RunScorecards(ctx context.Context, logger *zap.SugaredLogger,
repo repos.RepoURL, checksToRun checker.CheckNameToFnMap) repos.RepoResult { repo repos.RepoURL, checksToRun checker.CheckNameToFnMap) repos.RepoResult {
ret := repos.RepoResult{ ret := repos.RepoResult{
Repo: repo.Url(), Repo: repo.URL(),
Date: time.Now().Format("2006-01-02"), Date: time.Now().Format("2006-01-02"),
} }
resultsCh := make(chan checker.CheckResult) resultsCh := make(chan checker.CheckResult)

View File

@ -30,7 +30,7 @@ func (r *RepoURL) Type() string {
return "repo" return "repo"
} }
func (r *RepoURL) Url() string { func (r *RepoURL) URL() string {
return fmt.Sprintf("%s/%s/%s", r.Host, r.Owner, r.Repo) return fmt.Sprintf("%s/%s/%s", r.Host, r.Owner, r.Repo)
} }
@ -59,7 +59,7 @@ func (r *RepoURL) Set(s string) error {
return nil return nil
} }
func (r *RepoURL) ValidGitHubUrl() error { func (r *RepoURL) ValidGitHubURL() error {
switch r.Host { switch r.Host {
case "github.com": case "github.com":
break break
@ -68,7 +68,8 @@ func (r *RepoURL) ValidGitHubUrl() error {
} }
if len(strings.TrimSpace(r.Owner)) == 0 || len(strings.TrimSpace(r.Repo)) == 0 { if len(strings.TrimSpace(r.Owner)) == 0 || len(strings.TrimSpace(r.Repo)) == 0 {
return fmt.Errorf("invalid GitHub repo url: [%s], pass the full repository URL", r.Url()) //nolint:goerr113 // This is not passing an error as an argument.
return fmt.Errorf("invalid GitHub repo url: [%s], pass the full repository URL", r.URL())
} }
return nil return nil
} }

View File

@ -78,7 +78,7 @@ func TestRepoURL_ValidGitHubUrl(t *testing.T) {
if err := r.Set(tt.args.s); err != nil { if err := r.Set(tt.args.s); err != nil {
t.Errorf("RepoURL.Set() error = %v", err) t.Errorf("RepoURL.Set() error = %v", err)
} }
if err := r.ValidGitHubUrl(); (err != nil) != tt.wantErr { if err := r.ValidGitHubURL(); (err != nil) != tt.wantErr {
t.Errorf("RepoURL.ValidGitHubUrl() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("RepoURL.ValidGitHubUrl() error = %v, wantErr %v", err, tt.wantErr)
} }
if !tt.wantErr { if !tt.wantErr {