Skip to content

Commit 9c4bab7

Browse files
committed
Base check level on superproject type
Previously, the check level was based on the check mode configuration associated with the project type. It should instead be based on the check mode configuration for the superproject type because different requirements may apply to subprojects than to standalone projects.
1 parent 592badc commit 9c4bab7

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

Diff for: check/checklevel/checklevel.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/arduino/arduino-lint/check/checkresult"
2424
"github.com/arduino/arduino-lint/configuration"
2525
"github.com/arduino/arduino-lint/configuration/checkmode"
26+
"github.com/arduino/arduino-lint/project"
2627
)
2728

2829
// Type is the type for the check levels.
@@ -38,11 +39,11 @@ const (
3839
)
3940

4041
// CheckLevel determines the check level assigned to the given result of the given check under the current tool configuration.
41-
func CheckLevel(checkConfiguration checkconfigurations.Type, checkResult checkresult.Type) (Type, error) {
42+
func CheckLevel(checkConfiguration checkconfigurations.Type, checkResult checkresult.Type, checkedProject project.Type) (Type, error) {
4243
if checkResult != checkresult.Fail {
4344
return Notice, nil // Level provided by FailCheckLevel() is only relevant for failure result.
4445
}
45-
configurationCheckModes := configuration.CheckModes(checkConfiguration.ProjectType)
46+
configurationCheckModes := configuration.CheckModes(checkedProject.SuperprojectType)
4647
return FailCheckLevel(checkConfiguration, configurationCheckModes)
4748
}
4849

Diff for: check/checklevel/checklevel_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"github.com/arduino/arduino-lint/check/checkresult"
2323
"github.com/arduino/arduino-lint/configuration"
2424
"github.com/arduino/arduino-lint/configuration/checkmode"
25+
"github.com/arduino/arduino-lint/project"
26+
"github.com/arduino/arduino-lint/project/projecttype"
2527
"github.com/arduino/arduino-lint/util/test"
2628
"github.com/stretchr/testify/assert"
2729
)
@@ -63,7 +65,11 @@ func TestCheckLevel(t *testing.T) {
6365
ErrorModes: testTable.errorModes,
6466
}
6567

66-
level, err := CheckLevel(checkConfiguration, testTable.checkResult)
68+
checkedProject := project.Type{
69+
SuperprojectType: projecttype.Sketch,
70+
}
71+
72+
level, err := CheckLevel(checkConfiguration, testTable.checkResult, checkedProject)
6773
testTable.errorAssertion(t, err, testTable.testName)
6874
if err == nil {
6975
assert.Equal(t, testTable.expectedLevel, level, testTable.testName)

Diff for: result/result.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (results *Type) Initialize() {
9090

9191
// Record records the result of a check and returns a text summary for it.
9292
func (results *Type) Record(checkedProject project.Type, checkConfiguration checkconfigurations.Type, checkResult checkresult.Type, checkOutput string) string {
93-
checkLevel, err := checklevel.CheckLevel(checkConfiguration, checkResult)
93+
checkLevel, err := checklevel.CheckLevel(checkConfiguration, checkResult, checkedProject)
9494
if err != nil {
9595
panic(fmt.Errorf("Error while determining check level: %v", err))
9696
}

Diff for: result/result_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestRecord(t *testing.T) {
101101
assert.Equal(t, checkConfiguration.Brief, checkReport.Brief)
102102
assert.Equal(t, checkConfiguration.Description, checkReport.Description)
103103
assert.Equal(t, checkResult.String(), checkReport.Result)
104-
checkLevel, _ := checklevel.CheckLevel(checkConfiguration, checkResult)
104+
checkLevel, _ := checklevel.CheckLevel(checkConfiguration, checkResult, checkedProject)
105105
assert.Equal(t, checkLevel.String(), checkReport.Level)
106106
assert.Equal(t, checkOutput, checkReport.Message)
107107

0 commit comments

Comments
 (0)