Skip to content

Commit c09c9aa

Browse files
committed
Bring Go code into golint compliance
These violations were missed due to the error in the `golint` command used by the `go:lint` task.
1 parent bd8aa38 commit c09c9aa

File tree

12 files changed

+65
-55
lines changed

12 files changed

+65
-55
lines changed

internal/project/projecttype/projecttype.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@ import (
2626
type Type int
2727

2828
const (
29-
Sketch Type = iota // sketch
30-
Library // library
31-
Platform // platform
32-
PackageIndex // package-index
33-
All // all
34-
Not // N/A
29+
// Sketch is used for Arduino sketch projects.
30+
Sketch Type = iota // sketch
31+
// Library is used for Arduino library projects.
32+
Library // library
33+
// Platform is used for Arduino boards platform projects.
34+
Platform // platform
35+
// PackageIndex is used for Arduino package index projects.
36+
PackageIndex // package-index
37+
// All is the catch-all for all supported Arduino project types.
38+
All // all
39+
// Not is the project type used when an Arduino project was not detected.
40+
Not // N/A
3541
)
3642

3743
// FromString parses the --project-type flag value and returns the corresponding project type.

internal/result/outputformat/outputformat.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import (
2626
type Type int
2727

2828
const (
29+
// Text is the text output format.
2930
Text Type = iota // text
30-
JSON // json
31+
// JSON is the JSON output format.
32+
JSON // json
3133
)
3234

3335
// FromString parses the --format flag value and returns the corresponding output format type.

internal/result/result.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ func (results *Type) AddProjectSummary(lintedProject project.Type) {
200200
for _, ruleReport := range results.Projects[projectReportIndex].Rules {
201201
if ruleReport.Result == ruleresult.Fail.String() {
202202
if ruleReport.Level == rulelevel.Warning.String() {
203-
warningCount += 1
203+
warningCount++
204204
} else if ruleReport.Level == rulelevel.Error.String() {
205-
errorCount += 1
205+
errorCount++
206206
pass = false
207207
}
208208
}

internal/result/result_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func TestAddProjectSummary(t *testing.T) {
208208
if (result == ruleresult.Fail) || configuration.Verbose() {
209209
level := testTable.levels[testDataIndex].String()
210210
results.Projects[0].Rules[ruleIndex].Level = level
211-
ruleIndex += 1
211+
ruleIndex++
212212
}
213213
}
214214
results.AddProjectSummary(lintedProject)

internal/rule/ruleconfiguration/ruleconfiguration.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ var configurations = []Type{
903903
InfoModes: nil,
904904
WarningModes: nil,
905905
ErrorModes: []rulemode.Type{rulemode.Default},
906-
RuleFunction: rulefunction.LibraryPropertiesUrlFieldMissing,
906+
RuleFunction: rulefunction.LibraryPropertiesURLFieldMissing,
907907
},
908908
{
909909
ProjectType: projecttype.Library,
@@ -919,7 +919,7 @@ var configurations = []Type{
919919
InfoModes: nil,
920920
WarningModes: nil,
921921
ErrorModes: []rulemode.Type{rulemode.Default},
922-
RuleFunction: rulefunction.LibraryPropertiesUrlFieldLTMinLength,
922+
RuleFunction: rulefunction.LibraryPropertiesURLFieldLTMinLength,
923923
},
924924
{
925925
ProjectType: projecttype.Library,
@@ -935,7 +935,7 @@ var configurations = []Type{
935935
InfoModes: nil,
936936
WarningModes: []rulemode.Type{rulemode.Permissive},
937937
ErrorModes: []rulemode.Type{rulemode.Default},
938-
RuleFunction: rulefunction.LibraryPropertiesUrlFieldInvalid,
938+
RuleFunction: rulefunction.LibraryPropertiesURLFieldInvalid,
939939
},
940940
{
941941
ProjectType: projecttype.Library,
@@ -951,7 +951,7 @@ var configurations = []Type{
951951
InfoModes: nil,
952952
WarningModes: []rulemode.Type{rulemode.Default},
953953
ErrorModes: []rulemode.Type{rulemode.Strict},
954-
RuleFunction: rulefunction.LibraryPropertiesUrlFieldDeadLink,
954+
RuleFunction: rulefunction.LibraryPropertiesURLFieldDeadLink,
955955
},
956956
{
957957
ProjectType: projecttype.Library,
@@ -3703,7 +3703,7 @@ var configurations = []Type{
37033703
InfoModes: nil,
37043704
WarningModes: nil,
37053705
ErrorModes: []rulemode.Type{rulemode.Default},
3706-
RuleFunction: rulefunction.PackageIndexPackagesPlatformsUrlMissing,
3706+
RuleFunction: rulefunction.PackageIndexPackagesPlatformsURLMissing,
37073707
},
37083708
{
37093709
ProjectType: projecttype.PackageIndex,
@@ -3719,7 +3719,7 @@ var configurations = []Type{
37193719
InfoModes: nil,
37203720
WarningModes: nil,
37213721
ErrorModes: []rulemode.Type{rulemode.Default},
3722-
RuleFunction: rulefunction.PackageIndexPackagesPlatformsUrlIncorrectType,
3722+
RuleFunction: rulefunction.PackageIndexPackagesPlatformsURLIncorrectType,
37233723
},
37243724
{
37253725
ProjectType: projecttype.PackageIndex,
@@ -3735,7 +3735,7 @@ var configurations = []Type{
37353735
InfoModes: nil,
37363736
WarningModes: nil,
37373737
ErrorModes: []rulemode.Type{rulemode.Default},
3738-
RuleFunction: rulefunction.PackageIndexPackagesPlatformsUrlInvalidFormat,
3738+
RuleFunction: rulefunction.PackageIndexPackagesPlatformsURLInvalidFormat,
37393739
},
37403740
{
37413741
ProjectType: projecttype.PackageIndex,
@@ -4631,7 +4631,7 @@ var configurations = []Type{
46314631
InfoModes: nil,
46324632
WarningModes: nil,
46334633
ErrorModes: []rulemode.Type{rulemode.Default},
4634-
RuleFunction: rulefunction.PackageIndexPackagesToolsSystemsUrlMissing,
4634+
RuleFunction: rulefunction.PackageIndexPackagesToolsSystemsURLMissing,
46354635
},
46364636
{
46374637
ProjectType: projecttype.PackageIndex,
@@ -4647,7 +4647,7 @@ var configurations = []Type{
46474647
InfoModes: nil,
46484648
WarningModes: nil,
46494649
ErrorModes: []rulemode.Type{rulemode.Default},
4650-
RuleFunction: rulefunction.PackageIndexPackagesToolsSystemsUrlIncorrectType,
4650+
RuleFunction: rulefunction.PackageIndexPackagesToolsSystemsURLIncorrectType,
46514651
},
46524652
{
46534653
ProjectType: projecttype.PackageIndex,
@@ -4663,7 +4663,7 @@ var configurations = []Type{
46634663
InfoModes: nil,
46644664
WarningModes: nil,
46654665
ErrorModes: []rulemode.Type{rulemode.Default},
4666-
RuleFunction: rulefunction.PackageIndexPackagesToolsSystemsUrlInvalidFormat,
4666+
RuleFunction: rulefunction.PackageIndexPackagesToolsSystemsURLInvalidFormat,
46674667
},
46684668
{
46694669
ProjectType: projecttype.PackageIndex,

internal/rule/rulefunction/library.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -946,8 +946,8 @@ func LibraryPropertiesCategoryFieldUncategorized() (result ruleresult.Type, outp
946946
return ruleresult.Pass, ""
947947
}
948948

949-
// LibraryPropertiesUrlFieldMissing checks for missing library.properties "url" field.
950-
func LibraryPropertiesUrlFieldMissing() (result ruleresult.Type, output string) {
949+
// LibraryPropertiesURLFieldMissing checks for missing library.properties "url" field.
950+
func LibraryPropertiesURLFieldMissing() (result ruleresult.Type, output string) {
951951
if projectdata.LibraryPropertiesLoadError() != nil {
952952
return ruleresult.NotRun, "Couldn't load library.properties"
953953
}
@@ -962,8 +962,8 @@ func LibraryPropertiesUrlFieldMissing() (result ruleresult.Type, output string)
962962
return ruleresult.Pass, ""
963963
}
964964

965-
// LibraryPropertiesUrlFieldLTMinLength checks if the library.properties "url" value is less than the minimum length.
966-
func LibraryPropertiesUrlFieldLTMinLength() (result ruleresult.Type, output string) {
965+
// LibraryPropertiesURLFieldLTMinLength checks if the library.properties "url" value is less than the minimum length.
966+
func LibraryPropertiesURLFieldLTMinLength() (result ruleresult.Type, output string) {
967967
if projectdata.LibraryPropertiesLoadError() != nil {
968968
return ruleresult.NotRun, "Couldn't load library.properties"
969969
}
@@ -979,8 +979,8 @@ func LibraryPropertiesUrlFieldLTMinLength() (result ruleresult.Type, output stri
979979
return ruleresult.Pass, ""
980980
}
981981

982-
// LibraryPropertiesUrlFieldInvalid checks whether the library.properties "url" value has a valid URL format.
983-
func LibraryPropertiesUrlFieldInvalid() (result ruleresult.Type, output string) {
982+
// LibraryPropertiesURLFieldInvalid checks whether the library.properties "url" value has a valid URL format.
983+
func LibraryPropertiesURLFieldInvalid() (result ruleresult.Type, output string) {
984984
if projectdata.LibraryPropertiesLoadError() != nil {
985985
return ruleresult.NotRun, "Couldn't load library.properties"
986986
}
@@ -997,8 +997,8 @@ func LibraryPropertiesUrlFieldInvalid() (result ruleresult.Type, output string)
997997
return ruleresult.Pass, ""
998998
}
999999

1000-
// LibraryPropertiesUrlFieldDeadLink checks whether the URL in the library.properties `url` field can be loaded.
1001-
func LibraryPropertiesUrlFieldDeadLink() (result ruleresult.Type, output string) {
1000+
// LibraryPropertiesURLFieldDeadLink checks whether the URL in the library.properties `url` field can be loaded.
1001+
func LibraryPropertiesURLFieldDeadLink() (result ruleresult.Type, output string) {
10021002
if projectdata.LibraryPropertiesLoadError() != nil {
10031003
return ruleresult.NotRun, "Couldn't load library.properties"
10041004
}

internal/rule/rulefunction/library_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ func TestLibraryPropertiesUrlFieldMissing(t *testing.T) {
736736
{"Valid", "Recursive", ruleresult.Pass, ""},
737737
}
738738

739-
checkLibraryRuleFunction(LibraryPropertiesUrlFieldMissing, testTables, t)
739+
checkLibraryRuleFunction(LibraryPropertiesURLFieldMissing, testTables, t)
740740
}
741741

742742
func TestLibraryPropertiesUrlFieldLTMinLength(t *testing.T) {
@@ -747,7 +747,7 @@ func TestLibraryPropertiesUrlFieldLTMinLength(t *testing.T) {
747747
{"Valid", "Recursive", ruleresult.Pass, ""},
748748
}
749749

750-
checkLibraryRuleFunction(LibraryPropertiesUrlFieldLTMinLength, testTables, t)
750+
checkLibraryRuleFunction(LibraryPropertiesURLFieldLTMinLength, testTables, t)
751751
}
752752

753753
func TestLibraryPropertiesUrlFieldInvalid(t *testing.T) {
@@ -758,7 +758,7 @@ func TestLibraryPropertiesUrlFieldInvalid(t *testing.T) {
758758
{"Valid", "Recursive", ruleresult.Pass, ""},
759759
}
760760

761-
checkLibraryRuleFunction(LibraryPropertiesUrlFieldInvalid, testTables, t)
761+
checkLibraryRuleFunction(LibraryPropertiesURLFieldInvalid, testTables, t)
762762
}
763763

764764
func TestLibraryPropertiesUrlFieldDeadLink(t *testing.T) {
@@ -770,7 +770,7 @@ func TestLibraryPropertiesUrlFieldDeadLink(t *testing.T) {
770770
{"Good URL", "Recursive", ruleresult.Pass, ""},
771771
}
772772

773-
checkLibraryRuleFunction(LibraryPropertiesUrlFieldDeadLink, testTables, t)
773+
checkLibraryRuleFunction(LibraryPropertiesURLFieldDeadLink, testTables, t)
774774
}
775775

776776
func TestLibraryPropertiesArchitecturesFieldMissing(t *testing.T) {

internal/rule/rulefunction/packageindex.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -1084,8 +1084,8 @@ func PackageIndexPackagesPlatformsHelpOnlineDeadLink() (result ruleresult.Type,
10841084
return ruleresult.Pass, ""
10851085
}
10861086

1087-
// PackageIndexPackagesPlatformsUrlMissing checks for missing packages[].platforms[].url property.
1088-
func PackageIndexPackagesPlatformsUrlMissing() (result ruleresult.Type, output string) {
1087+
// PackageIndexPackagesPlatformsURLMissing checks for missing packages[].platforms[].url property.
1088+
func PackageIndexPackagesPlatformsURLMissing() (result ruleresult.Type, output string) {
10891089
if projectdata.PackageIndexLoadError() != nil {
10901090
return ruleresult.NotRun, "Error loading package index"
10911091
}
@@ -1104,8 +1104,8 @@ func PackageIndexPackagesPlatformsUrlMissing() (result ruleresult.Type, output s
11041104
return ruleresult.Pass, ""
11051105
}
11061106

1107-
// PackageIndexPackagesPlatformsUrlIncorrectType checks for incorrect type of the packages[].platforms[].url property.
1108-
func PackageIndexPackagesPlatformsUrlIncorrectType() (result ruleresult.Type, output string) {
1107+
// PackageIndexPackagesPlatformsURLIncorrectType checks for incorrect type of the packages[].platforms[].url property.
1108+
func PackageIndexPackagesPlatformsURLIncorrectType() (result ruleresult.Type, output string) {
11091109
if projectdata.PackageIndexLoadError() != nil {
11101110
return ruleresult.NotRun, "Error loading package index"
11111111
}
@@ -1124,8 +1124,8 @@ func PackageIndexPackagesPlatformsUrlIncorrectType() (result ruleresult.Type, ou
11241124
return ruleresult.Pass, ""
11251125
}
11261126

1127-
// PackageIndexPackagesPlatformsUrlInvalidFormat checks for incorrect format of the packages[].platforms[].url property.
1128-
func PackageIndexPackagesPlatformsUrlInvalidFormat() (result ruleresult.Type, output string) {
1127+
// PackageIndexPackagesPlatformsURLInvalidFormat checks for incorrect format of the packages[].platforms[].url property.
1128+
func PackageIndexPackagesPlatformsURLInvalidFormat() (result ruleresult.Type, output string) {
11291129
if projectdata.PackageIndexLoadError() != nil {
11301130
return ruleresult.NotRun, "Error loading package index"
11311131
}
@@ -2255,8 +2255,8 @@ func PackageIndexPackagesToolsSystemsHostInvalid() (result ruleresult.Type, outp
22552255
return ruleresult.Pass, ""
22562256
}
22572257

2258-
// PackageIndexPackagesToolsSystemsUrlMissing checks for missing packages[].tools[].systems[].url property.
2259-
func PackageIndexPackagesToolsSystemsUrlMissing() (result ruleresult.Type, output string) {
2258+
// PackageIndexPackagesToolsSystemsURLMissing checks for missing packages[].tools[].systems[].url property.
2259+
func PackageIndexPackagesToolsSystemsURLMissing() (result ruleresult.Type, output string) {
22602260
if projectdata.PackageIndexLoadError() != nil {
22612261
return ruleresult.NotRun, "Error loading package index"
22622262
}
@@ -2275,8 +2275,8 @@ func PackageIndexPackagesToolsSystemsUrlMissing() (result ruleresult.Type, outpu
22752275
return ruleresult.Pass, ""
22762276
}
22772277

2278-
// PackageIndexPackagesToolsSystemsUrlIncorrectType checks for incorrect type of the packages[].tools[].systems[].url property.
2279-
func PackageIndexPackagesToolsSystemsUrlIncorrectType() (result ruleresult.Type, output string) {
2278+
// PackageIndexPackagesToolsSystemsURLIncorrectType checks for incorrect type of the packages[].tools[].systems[].url property.
2279+
func PackageIndexPackagesToolsSystemsURLIncorrectType() (result ruleresult.Type, output string) {
22802280
if projectdata.PackageIndexLoadError() != nil {
22812281
return ruleresult.NotRun, "Error loading package index"
22822282
}
@@ -2295,8 +2295,8 @@ func PackageIndexPackagesToolsSystemsUrlIncorrectType() (result ruleresult.Type,
22952295
return ruleresult.Pass, ""
22962296
}
22972297

2298-
// PackageIndexPackagesToolsSystemsUrlInvalidFormat checks for incorrect format of the packages[].tools[].systems[].url property.
2299-
func PackageIndexPackagesToolsSystemsUrlInvalidFormat() (result ruleresult.Type, output string) {
2298+
// PackageIndexPackagesToolsSystemsURLInvalidFormat checks for incorrect format of the packages[].tools[].systems[].url property.
2299+
func PackageIndexPackagesToolsSystemsURLInvalidFormat() (result ruleresult.Type, output string) {
23002300
if projectdata.PackageIndexLoadError() != nil {
23012301
return ruleresult.NotRun, "Error loading package index"
23022302
}

internal/rule/rulefunction/packageindex_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ func TestPackageIndexPackagesPlatformsUrlMissing(t *testing.T) {
599599
{"Valid", "valid-package-index", ruleresult.Pass, ""},
600600
}
601601

602-
checkPackageIndexRuleFunction(PackageIndexPackagesPlatformsUrlMissing, testTables, t)
602+
checkPackageIndexRuleFunction(PackageIndexPackagesPlatformsURLMissing, testTables, t)
603603
}
604604

605605
func TestPackageIndexPackagesPlatformsUrlIncorrectType(t *testing.T) {
@@ -609,7 +609,7 @@ func TestPackageIndexPackagesPlatformsUrlIncorrectType(t *testing.T) {
609609
{"Valid", "valid-package-index", ruleresult.Pass, ""},
610610
}
611611

612-
checkPackageIndexRuleFunction(PackageIndexPackagesPlatformsUrlIncorrectType, testTables, t)
612+
checkPackageIndexRuleFunction(PackageIndexPackagesPlatformsURLIncorrectType, testTables, t)
613613
}
614614

615615
func TestPackageIndexPackagesPlatformsUrlInvalidFormat(t *testing.T) {
@@ -619,7 +619,7 @@ func TestPackageIndexPackagesPlatformsUrlInvalidFormat(t *testing.T) {
619619
{"Valid", "valid-package-index", ruleresult.Pass, ""},
620620
}
621621

622-
checkPackageIndexRuleFunction(PackageIndexPackagesPlatformsUrlInvalidFormat, testTables, t)
622+
checkPackageIndexRuleFunction(PackageIndexPackagesPlatformsURLInvalidFormat, testTables, t)
623623
}
624624

625625
func TestPackageIndexPackagesPlatformsURLDeadLink(t *testing.T) {
@@ -1179,7 +1179,7 @@ func TestPackageIndexPackagesToolsSystemsUrlMissing(t *testing.T) {
11791179
{"Valid", "valid-package-index", ruleresult.Pass, ""},
11801180
}
11811181

1182-
checkPackageIndexRuleFunction(PackageIndexPackagesToolsSystemsUrlMissing, testTables, t)
1182+
checkPackageIndexRuleFunction(PackageIndexPackagesToolsSystemsURLMissing, testTables, t)
11831183
}
11841184

11851185
func TestPackageIndexPackagesToolsSystemsUrlIncorrectType(t *testing.T) {
@@ -1189,7 +1189,7 @@ func TestPackageIndexPackagesToolsSystemsUrlIncorrectType(t *testing.T) {
11891189
{"Valid", "valid-package-index", ruleresult.Pass, ""},
11901190
}
11911191

1192-
checkPackageIndexRuleFunction(PackageIndexPackagesToolsSystemsUrlIncorrectType, testTables, t)
1192+
checkPackageIndexRuleFunction(PackageIndexPackagesToolsSystemsURLIncorrectType, testTables, t)
11931193
}
11941194

11951195
func TestPackageIndexPackagesToolsSystemsUrlInvalidFormat(t *testing.T) {
@@ -1199,7 +1199,7 @@ func TestPackageIndexPackagesToolsSystemsUrlInvalidFormat(t *testing.T) {
11991199
{"Valid", "valid-package-index", ruleresult.Pass, ""},
12001200
}
12011201

1202-
checkPackageIndexRuleFunction(PackageIndexPackagesToolsSystemsUrlInvalidFormat, testTables, t)
1202+
checkPackageIndexRuleFunction(PackageIndexPackagesToolsSystemsURLInvalidFormat, testTables, t)
12031203
}
12041204

12051205
func TestPackageIndexPackagesToolsSystemsURLDeadLink(t *testing.T) {

internal/rule/rulefunction/platform.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ func PlatformTxtCompilerCElfExtraFlagsMissing() (result ruleresult.Type, output
10481048
return ruleresult.Pass, ""
10491049
}
10501050

1051-
// PlatformTxtCompilerCExtraFlagsNotEmpty checks for non-empty compiler.c.extra_flags property in platform.txt.
1051+
// PlatformTxtCompilerCElfExtraFlagsNotEmpty checks for non-empty compiler.c.elf.extra_flags property in platform.txt.
10521052
func PlatformTxtCompilerCElfExtraFlagsNotEmpty() (result ruleresult.Type, output string) {
10531053
if !projectdata.PlatformTxtExists() {
10541054
return ruleresult.Skip, "Platform has no platform.txt"

internal/rule/ruleresult/ruleresult.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ package ruleresult
2121
type Type int
2222

2323
const (
24+
// Pass indicates rule compliance.
2425
Pass Type = iota // pass
25-
Fail // fail
26-
// The rule is configured to be skipped in the current tool configuration mode
26+
// Fail indicates a rule violation.
27+
Fail // fail
28+
// Skip indicates the rule is configured to be skipped in the current tool configuration mode.
2729
Skip // skipped
28-
// An unrelated error prevented the rule from running
30+
// NotRun indicates an unrelated error prevented the rule from running.
2931
NotRun // unable to run
3032
)

internal/rule/schema/parsevalidationresult.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func PropertyFormatMismatch(propertyName string, validationResult ValidationResu
6464
return ValidationErrorMatch("^#/?"+propertyName+"$", "/format$", "", "", validationResult)
6565
}
6666

67-
// ProhibitedAdditionalProperty returns whether the given property has prohibited additional subproperty(s).
67+
// ProhibitedAdditionalProperties returns whether the given property has prohibited additional subproperty(s).
6868
func ProhibitedAdditionalProperties(propertyName string, validationResult ValidationResult) bool {
6969
return ValidationErrorMatch("^#/?"+propertyName+"$", "/additionalProperties$", "", "", validationResult)
7070
}

0 commit comments

Comments
 (0)