Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint messages reported from porter should not mention mixins #2992

Merged
merged 7 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 20 additions & 0 deletions pkg/linter/linter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()")
})
}
Loading