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

Feature/add support for multiple makefiles #70

Merged
Merged
Prev Previous commit
Next Next commit
Implement FileName struct member for MaxFileLength rule + tests
  • Loading branch information
trinitronx committed Apr 28, 2022
commit 2c64c1444957809cae1a21d87a8942473106faf9
1 change: 1 addition & 0 deletions rules/maxbodylength/maxbodylength.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (m *MaxBodyLength) Run(makefile parser.Makefile, config rules.RuleConfig) r
ret = append(ret, rules.RuleViolation{
Rule: "maxbodylength",
Violation: fmt.Sprintf(vT, rule.Target, maxBodyLength, len(rule.Body)),
FileName: makefile.FileName,
LineNumber: rule.LineNumber,
})
}
Expand Down
4 changes: 4 additions & 0 deletions rules/maxbodylength/maxbodylength_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
func TestFooIsTooLong(t *testing.T) {

makefile := parser.Makefile{
FileName: "maxbodylength.mk",
Rules: []parser.Rule{parser.Rule{
Target: "foo",
Body: []string{"echo 'foo'",
Expand All @@ -32,11 +33,13 @@ func TestFooIsTooLong(t *testing.T) {
rule.Description())
assert.Equal(t, "Target body for \"foo\" exceeds allowed length of 5 (7).", ret[0].Violation)
assert.Equal(t, 1, ret[0].LineNumber)
assert.Equal(t, "maxbodylength.mk", ret[0].FileName)
}

func TestFooIsTooLongWithConfig(t *testing.T) {

makefile := parser.Makefile{
FileName: "maxbodylength.mk",
Rules: []parser.Rule{parser.Rule{
Target: "foo",
Body: []string{"echo 'foo'",
Expand All @@ -58,4 +61,5 @@ func TestFooIsTooLongWithConfig(t *testing.T) {
rule.Description())
assert.Equal(t, "Target body for \"foo\" exceeds allowed length of 3 (4).", ret[0].Violation)
assert.Equal(t, 1, ret[0].LineNumber)
assert.Equal(t, "maxbodylength.mk", ret[0].FileName)
}