diff --git a/pkg/build/build.go b/pkg/build/build.go index 53b45e5a6..f41d857e5 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -1058,7 +1058,6 @@ func (b *Build) BuildPackage(ctx context.Context) error { // add the main package to the linter queue lintTarget := linterTarget{ pkgName: b.Configuration.Package.Name, - checks: b.Configuration.Package.Checks, } linterQueue = append(linterQueue, lintTarget) } @@ -1112,7 +1111,6 @@ func (b *Build) BuildPackage(ctx context.Context) error { // add the main package to the linter queue lintTarget := linterTarget{ pkgName: sp.Name, - checks: sp.Checks, } linterQueue = append(linterQueue, lintTarget) } @@ -1130,7 +1128,7 @@ func (b *Build) BuildPackage(ctx context.Context) error { path := filepath.Join(b.WorkspaceDir, "melange-out", lt.pkgName) fsys := os.DirFS(path) - lctx := linter.NewLinterContext(lt.pkgName, fsys, &b.Configuration, <.checks) + lctx := linter.NewLinterContext(lt.pkgName, fsys) linters := lt.checks.GetLinters() err = lctx.LintPackageFs(fsys, linters) diff --git a/pkg/linter/linter.go b/pkg/linter/linter.go index b051e7f47..ad1be7417 100644 --- a/pkg/linter/linter.go +++ b/pkg/linter/linter.go @@ -22,19 +22,15 @@ import ( "os" "path/filepath" "regexp" - - "chainguard.dev/melange/pkg/config" ) type LinterContext struct { pkgname string fsys fs.FS - cfg *config.Configuration - chk *config.Checks } -func NewLinterContext(name string, fsys fs.FS, cfg *config.Configuration, chk *config.Checks) LinterContext { - return LinterContext{name, fsys, cfg, chk} +func NewLinterContext(name string, fsys fs.FS) LinterContext { + return LinterContext{name, fsys} } type linterFunc func(lctx LinterContext, path string, d fs.DirEntry) error diff --git a/pkg/linter/linter_test.go b/pkg/linter/linter_test.go index 6ada50293..8d6105515 100644 --- a/pkg/linter/linter_test.go +++ b/pkg/linter/linter_test.go @@ -45,7 +45,7 @@ func Test_emptyLinter(t *testing.T) { linters := cfg.Package.Checks.GetLinters() assert.Equal(t, linters, []string{"empty"}) fsys := os.DirFS(dir) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.Error(t, lctx.LintPackageFs(fsys, linters)) } @@ -74,7 +74,7 @@ func Test_usrLocalLinter(t *testing.T) { linters := cfg.Package.Checks.GetLinters() assert.Equal(t, linters, []string{"usrlocal"}) fsys := os.DirFS(dir) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.Error(t, lctx.LintPackageFs(fsys, linters)) } @@ -104,7 +104,7 @@ func Test_varEmptyLinter(t *testing.T) { linters := cfg.Package.Checks.GetLinters() assert.Equal(t, linters, []string{"varempty"}) fsys := os.DirFS(dir) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.Error(t, lctx.LintPackageFs(fsys, linters)) } @@ -134,7 +134,7 @@ func Test_devLinter(t *testing.T) { linters := cfg.Package.Checks.GetLinters() assert.Equal(t, linters, []string{"dev"}) fsys := os.DirFS(dir) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.Error(t, lctx.LintPackageFs(fsys, linters)) } @@ -164,7 +164,7 @@ func Test_optLinter(t *testing.T) { linters := cfg.Package.Checks.GetLinters() assert.Equal(t, linters, []string{"opt"}) fsys := os.DirFS(dir) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.Error(t, lctx.LintPackageFs(fsys, linters)) } @@ -194,7 +194,7 @@ func Test_srvLinter(t *testing.T) { linters := cfg.Package.Checks.GetLinters() assert.Equal(t, linters, []string{"srv"}) fsys := os.DirFS(dir) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.Error(t, lctx.LintPackageFs(fsys, linters)) } @@ -236,7 +236,7 @@ func Test_tempDirLinter(t *testing.T) { assert.NoError(t, err) _, err = os.Create(filename) assert.NoError(t, err) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.Error(t, lctx.LintPackageFs(fsys, linters)) os.Remove(filename) @@ -291,7 +291,7 @@ func Test_setUidGidLinter(t *testing.T) { linters := cfg.Package.Checks.GetLinters() assert.Equal(t, linters, []string{"setuidgid"}) fsys := os.DirFS(dir) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.Error(t, lctx.LintPackageFs(fsys, linters)) } @@ -320,7 +320,7 @@ func Test_worldWriteLinter(t *testing.T) { linters := cfg.Package.Checks.GetLinters() assert.Equal(t, linters, []string{"worldwrite"}) fsys := os.DirFS(dir) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.NoError(t, lctx.LintPackageFs(fsys, linters)) // Create test file @@ -377,6 +377,6 @@ func Test_disableDefaultLinter(t *testing.T) { linters := cfg.Package.Checks.GetLinters() fsys := os.DirFS(dir) - lctx := NewLinterContext(cfg.Package.Name, fsys, &cfg, &cfg.Package.Checks) + lctx := NewLinterContext(cfg.Package.Name, fsys) assert.NoError(t, lctx.LintPackageFs(fsys, linters)) }