Skip to content

Commit

Permalink
Address lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mcastorina committed Feb 11, 2025
1 parent bb576f7 commit 81aac74
Showing 2 changed files with 7 additions and 36 deletions.
7 changes: 2 additions & 5 deletions pkg/sources/github/github_test.go
Original file line number Diff line number Diff line change
@@ -606,10 +606,9 @@ func TestEnumerate(t *testing.T) {

var reportedRepos []string
reporter := sources.VisitorReporter{
VisitUnit: func(ctx context.Context, su sources.SourceUnit) error {
VisitUnit: func(ctx context.Context, su sources.SourceUnit) {
url, _ := su.SourceUnitID()
reportedRepos = append(reportedRepos, url)
return nil
},
}

@@ -961,8 +960,6 @@ func Test_ScanMultipleTargets_MultipleErrors(t *testing.T) {

func noopReporter() sources.UnitReporter {
return sources.VisitorReporter{
VisitUnit: func(context.Context, sources.SourceUnit) error {
return nil
},
VisitUnit: func(context.Context, sources.SourceUnit) {},
}
}
36 changes: 5 additions & 31 deletions pkg/sourcestest/sourcestest.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package sourcestest

import (
"fmt"

"github.com/trufflesecurity/trufflehog/v3/pkg/context"
"github.com/trufflesecurity/trufflehog/v3/pkg/sources"
)
@@ -12,10 +10,7 @@ type reporter interface {
sources.ChunkReporter
}

var (
_ reporter = (*TestReporter)(nil)
_ reporter = (*ErrReporter)(nil)
)
var _ reporter = (*TestReporter)(nil)

// TestReporter is a helper struct that implements both UnitReporter and
// ChunkReporter by simply recording the values passed in the methods.
@@ -26,36 +21,15 @@ type TestReporter struct {
ChunkErrs []error
}

func (t *TestReporter) UnitOk(_ context.Context, unit sources.SourceUnit) error {
func (t *TestReporter) UnitOk(_ context.Context, unit sources.SourceUnit) {
t.Units = append(t.Units, unit)
return nil
}
func (t *TestReporter) UnitErr(_ context.Context, err error) error {
func (t *TestReporter) UnitErr(_ context.Context, err error) {
t.UnitErrs = append(t.UnitErrs, err)
return nil
}
func (t *TestReporter) ChunkOk(_ context.Context, chunk sources.Chunk) error {
func (t *TestReporter) ChunkOk(_ context.Context, chunk sources.Chunk) {
t.Chunks = append(t.Chunks, chunk)
return nil
}
func (t *TestReporter) ChunkErr(_ context.Context, err error) error {
func (t *TestReporter) ChunkErr(_ context.Context, err error) {
t.ChunkErrs = append(t.ChunkErrs, err)
return nil
}

// ErrReporter implements UnitReporter and ChunkReporter but always returns an
// error.
type ErrReporter struct{}

func (ErrReporter) UnitOk(context.Context, sources.SourceUnit) error {
return fmt.Errorf("ErrReporter: UnitOk error")
}
func (ErrReporter) UnitErr(context.Context, error) error {
return fmt.Errorf("ErrReporter: UnitErr error")
}
func (ErrReporter) ChunkOk(context.Context, sources.Chunk) error {
return fmt.Errorf("ErrReporter: ChunkOk error")
}
func (ErrReporter) ChunkErr(context.Context, error) error {
return fmt.Errorf("ErrReporter: ChunkErr error")
}

0 comments on commit 81aac74

Please sign in to comment.