Skip to content

Commit

Permalink
✨ Remove isScorecardRepo (#1236)
Browse files Browse the repository at this point in the history
* remove isScorecardRepo

* linter

* linter

Co-authored-by: Naveen <[email protected]>
  • Loading branch information
laurentsimon and naveensrinivasan authored Nov 10, 2021
1 parent 5524c97 commit 795505f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 35 deletions.
11 changes: 5 additions & 6 deletions checks/file_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strings"

"github.com/ossf/scorecard/v3/checker"
"github.com/ossf/scorecard/v3/clients"
sce "github.com/ossf/scorecard/v3/errors"
)

Expand Down Expand Up @@ -49,10 +48,10 @@ func isMatchingPath(pattern, fullpath string, caseSensitive bool) (bool, error)
return match, nil
}

func isScorecardTestFile(repo clients.Repo, fullpath string) bool {
func isTestdataFile(fullpath string) bool {
// testdata/ or /some/dir/testdata/some/other
return repo.IsScorecardRepo() && (strings.HasPrefix(fullpath, "testdata/") ||
strings.Contains(fullpath, "/testdata/"))
return strings.HasPrefix(fullpath, "testdata/") ||
strings.Contains(fullpath, "/testdata/")
}

// FileCbData is any data the caller can act upon
Expand All @@ -78,8 +77,8 @@ func CheckFilesContent(shellPathFnPattern string,
data FileCbData,
) error {
predicate := func(filepath string) (bool, error) {
// Filter out Scorecard's own test files.
if isScorecardTestFile(c.Repo, filepath) {
// Filter out test files.
if isTestdataFile(filepath) {
return false, nil
}
// Filter out files based on path/names using the pattern.
Expand Down
9 changes: 1 addition & 8 deletions clients/githubrepo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (
)

const (
githubOrgRepo = ".github"
scorecardOwner = "ossf"
scorecardRepo = "scorecard"
githubOrgRepo = ".github"
)

type repoURL struct {
Expand Down Expand Up @@ -116,11 +114,6 @@ func (r *repoURL) Metadata() []string {
return r.metadata
}

// IsScorecardRepo implements Repo.IsScorecardRepo.
func (r *repoURL) IsScorecardRepo() bool {
return r.owner == scorecardOwner && r.repo == scorecardRepo
}

// MakeGithubRepo takes input of form "owner/repo" or "github.com/owner/repo"
// and returns an implementation of clients.Repo interface.
func MakeGithubRepo(input string) (clients.Repo, error) {
Expand Down
5 changes: 0 additions & 5 deletions clients/localdir/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ func (r *repoLocal) AppendMetadata(m ...string) {
r.metadata = append(r.metadata, m...)
}

// IsScorecardRepo implements Repo.IsScorecardRepo.
func (r *repoLocal) IsScorecardRepo() bool {
return false
}

// MakeLocalDirRepo returns an implementation of clients.Repo interface.
func MakeLocalDirRepo(pathfn string) (clients.Repo, error) {
if !strings.HasPrefix(pathfn, filePrefix) {
Expand Down
14 changes: 0 additions & 14 deletions clients/mockrepo/repo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions clients/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ type Repo interface {
IsValid() error
Metadata() []string
AppendMetadata(metadata ...string)
// TODO: Find a better alterntive.
IsScorecardRepo() bool
}

0 comments on commit 795505f

Please sign in to comment.