Fix some nits in the crawler and elsewhere.

This commit is contained in:
Jeffrey Regan
2019-12-03 10:44:44 -08:00
parent fd5db20a48
commit e9ab3da164
33 changed files with 31 additions and 113 deletions

View File

@@ -92,7 +92,7 @@ func main() {
_, err := idx.Put("", d)
return err
default:
return fmt.Errorf("Type %T not supported", d)
return fmt.Errorf("type %T not supported", d)
}
},
)

View File

@@ -11,8 +11,8 @@ import (
"testing"
"time"
"sigs.k8s.io/kustomize/api/konfig"
"sigs.k8s.io/kustomize/api/internal/crawl/doc"
"sigs.k8s.io/kustomize/api/konfig"
)
const (
@@ -32,7 +32,7 @@ func (c testCrawler) Match(d *doc.Document) bool {
return d != nil && strings.HasPrefix(d.ID(), c.matchPrefix)
}
func (c testCrawler) FetchDocument(ctx context.Context, d *doc.Document) error {
func (c testCrawler) FetchDocument(_ context.Context, d *doc.Document) error {
if i, ok := c.lukp[d.ID()]; ok {
d.DocumentData = c.docs[i].DocumentData
return nil
@@ -51,7 +51,7 @@ func (c testCrawler) FetchDocument(ctx context.Context, d *doc.Document) error {
d, c.matchPrefix)
}
func (c testCrawler) SetCreated(ctx context.Context, d *doc.Document) error {
func (c testCrawler) SetCreated(_ context.Context, d *doc.Document) error {
d.CreationTime = &time.Time{}
return nil
}
@@ -71,7 +71,7 @@ func newCrawler(matchPrefix string, err error,
}
// Crawl implements the Crawler interface for testing.
func (c testCrawler) Crawl(ctx context.Context,
func (c testCrawler) Crawl(_ context.Context,
output chan<- CrawledDocument) error {
for i, d := range c.docs {

View File

@@ -93,7 +93,7 @@ func (gc githubCrawler) Crawl(
return nil
}
func (gc githubCrawler) FetchDocument(ctx context.Context, d *doc.Document) error {
func (gc githubCrawler) FetchDocument(_ context.Context, d *doc.Document) error {
repoURL := d.RepositoryURL + "/" + d.FilePath + "?ref=" + d.DefaultBranch
repoSpec, err := git.NewRepoSpecFromUrl(repoURL)
if err != nil {
@@ -132,7 +132,7 @@ func (gc githubCrawler) FetchDocument(ctx context.Context, d *doc.Document) erro
return fmt.Errorf("file not found: %s, error: %v", url, err)
}
func (gc githubCrawler) SetCreated(ctx context.Context, d *doc.Document) error {
func (gc githubCrawler) SetCreated(_ context.Context, d *doc.Document) error {
fs := GhFileSpec{}
fs.Repository.FullName = d.RepositoryURL + "/" + d.FilePath
creationTime, err := gc.client.GetFileCreationTime(fs)

View File

@@ -8,7 +8,6 @@ import (
const (
perPageArg = "per_page"
accessTokenArg = "access_token"
)
const githubMaxPageSize = 100
@@ -101,12 +100,6 @@ type RequestConfig struct {
perPage uint64
}
func NewRequestConfig(perPage uint64) RequestConfig {
return RequestConfig{
perPage: perPage,
}
}
// CodeSearchRequestWith given a list of query parameters that specify the
// (patial) query, returns a request object with the (parital) query. Must call
// the URL method to get the string value of the URL. See request.CopyWith, to

View File

@@ -68,7 +68,6 @@ func TestQueryType(t *testing.T) {
func TestGithubSearchQuery(t *testing.T) {
const (
accessToken = "random_token"
perPage = 100
)