mirror of
https://github.com/ossf/scorecard.git
synced 2024-09-11 00:45:36 +03:00
Fix lint issues: golint linter
This commit is contained in:
parent
a4e8751d73
commit
6a7142fe21
@ -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{})
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user