@@ -25,7 +25,13 @@ func RunChecks(project project.Type) {
25
25
checkdata .Initialize (project )
26
26
27
27
for _ , checkConfiguration := range checkconfigurations .Configurations () {
28
- if ! shouldRun (checkConfiguration , project ) {
28
+ runCheck , err := shouldRun (checkConfiguration , project )
29
+ if err != nil {
30
+ feedback .Errorf ("Error while determining whether to run check: %v" , err )
31
+ os .Exit (errorcodes .ErrGeneric )
32
+ }
33
+
34
+ if ! runCheck {
29
35
// TODO: this should only be printed to log and in verbose mode
30
36
fmt .Printf ("Skipping check: %s\n " , checkConfiguration .ID )
31
37
continue
@@ -49,40 +55,39 @@ func RunChecks(project project.Type) {
49
55
}
50
56
51
57
// shouldRun returns whether a given check should be run for the given project under the current tool configuration.
52
- func shouldRun (checkConfiguration checkconfigurations.Type , currentProject project.Type ) bool {
58
+ func shouldRun (checkConfiguration checkconfigurations.Type , currentProject project.Type ) ( bool , error ) {
53
59
configurationCheckModes := configuration .CheckModes (currentProject .SuperprojectType )
54
60
55
61
if checkConfiguration .ProjectType != currentProject .ProjectType {
56
- return false
62
+ return false , nil
57
63
}
58
64
59
65
for _ , disableMode := range checkConfiguration .DisableModes {
60
66
if configurationCheckModes [disableMode ] == true {
61
- return false
67
+ return false , nil
62
68
}
63
69
}
64
70
65
71
for _ , enableMode := range checkConfiguration .EnableModes {
66
72
if configurationCheckModes [enableMode ] == true {
67
- return true
73
+ return true , nil
68
74
}
69
75
}
70
76
71
77
// Use default
72
78
for _ , disableMode := range checkConfiguration .DisableModes {
73
79
if disableMode == checkmode .Default {
74
- return false
80
+ return false , nil
75
81
}
76
82
}
77
83
78
84
for _ , enableMode := range checkConfiguration .EnableModes {
79
85
if enableMode == checkmode .Default {
80
- return true
86
+ return true , nil
81
87
}
82
88
}
83
89
84
- // TODO: this should return an error
85
- return false
90
+ return false , fmt .Errorf ("Check %s is incorrectly configured" , checkConfiguration .ID )
86
91
}
87
92
88
93
// message fills the message template provided by the check configuration with the check output.
0 commit comments