Skip to content

Commit

Permalink
Lint messages reported from porter should not mention mixins (#2992)
Browse files Browse the repository at this point in the history
* Lint messages reported from porter not mention mixins

Signed-off-by: Kim Christensen <kimworking@gmail.com>

---------

Signed-off-by: Kim Christensen <kimworking@gmail.com>
  • Loading branch information
kichristensen authored Feb 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0b5328e commit 2c17959
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/linter/linter.go
Original file line number Diff line number Diff line change
@@ -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")
20 changes: 20 additions & 0 deletions pkg/linter/linter_test.go
Original file line number Diff line number Diff line change
@@ -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 ()")
})
}

0 comments on commit 2c17959

Please sign in to comment.