diff --git a/pkg/linter/linter.go b/pkg/linter/linter.go index 93d83604f..73840f98b 100644 --- a/pkg/linter/linter.go +++ b/pkg/linter/linter.go @@ -68,7 +68,9 @@ type Result struct { func (r Result) String() string { var buffer strings.Builder buffer.WriteString(fmt.Sprintf("%s(%s) - %s\n", r.Level, r.Code, r.Title)) - buffer.WriteString(r.Location.String() + "\n") + if r.Location.Mixin != "" { + buffer.WriteString(r.Location.String() + "\n") + } if r.Message != "" { buffer.WriteString(r.Message + "\n") diff --git a/pkg/linter/linter_test.go b/pkg/linter/linter_test.go index 8a8a490c7..641e1bca2 100644 --- a/pkg/linter/linter_test.go +++ b/pkg/linter/linter_test.go @@ -153,4 +153,24 @@ func TestLinter_Lint(t *testing.T) { require.NoError(t, err, "Lint failed") require.Len(t, results, 0, "linter should have returned 1 result") }) + + t.Run("lint messages does not mention mixins in message not coming from mixin", func(t *testing.T) { + cxt := portercontext.NewTestContext(t) + mixins := mixin.NewTestMixinProvider() + l := New(cxt.Context, mixins) + param := map[string]manifest.ParameterDefinition{ + "A": { + Name: "porter_test", + }, + } + + m := &manifest.Manifest{ + Parameters: param, + } + + results, err := l.Lint(ctx, m) + require.NoError(t, err, "Lint failed") + require.Len(t, results, 1, "linter should have returned 1 result") + require.NotContains(t, results[0].String(), ": 0th step in the mixin ()") + }) }