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
Client *github.Client
GraphClient *githubv4.Client
HttpClient *http.Client
HTTPClient *http.Client
Owner, Repo string
Logf func(s string, f ...interface{})
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ func (r *RepoURL) Type() string {
return "repo"
}
func (r *RepoURL) Url() string {
func (r *RepoURL) URL() string {
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
}
func (r *RepoURL) ValidGitHubUrl() error {
func (r *RepoURL) ValidGitHubURL() error {
switch r.Host {
case "github.com":
break
@ -68,7 +68,8 @@ func (r *RepoURL) ValidGitHubUrl() error {
}
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
}

View File

@ -78,7 +78,7 @@ func TestRepoURL_ValidGitHubUrl(t *testing.T) {
if err := r.Set(tt.args.s); err != nil {
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)
}
if !tt.wantErr {