Skip to content

Commit ca45b7d

Browse files
committed
Improve/correct code comments
Various improvements and corrections to the comments in the code.
1 parent a58dfe9 commit ca45b7d

File tree

15 files changed

+27
-9
lines changed

15 files changed

+27
-9
lines changed

Diff for: docs/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#
4848
# In order to avoid unwanted changes to the public website hosting the arduino-lint documentation, only Mike is allowed
4949
# to push changes to the `gh-pages` branch, and this only happens from within the CI, in the "Publish documentation"
50-
# workflow: https://github.com/arduino/arduino-lint/blob/master/.github/workflows/publish-docs.yml
50+
# workflow: https://github.com/arduino/arduino-lint/blob/main/.github/workflows/publish-docs.yml
5151
#
5252
# The CI is responsible for guessing which version of arduino-lint we're building docs for, so that generated content
5353
# will be stored in the appropriate section of the documentation website. Because this guessing might be fairly complex,

Diff for: internal/configuration/configuration.go

+4
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,14 @@ func Verbose() bool {
195195

196196
var versionMode bool
197197

198+
// VersionMode returns the --version setting.
198199
func VersionMode() bool {
199200
return versionMode
200201
}
201202

202203
var version string
203204

205+
// Version returns the build version.
204206
func Version() string {
205207
return version
206208
}
@@ -214,6 +216,7 @@ func Commit() string {
214216

215217
var buildTimestamp string
216218

219+
// BuildTimestamp returns the timestamp of the build.
217220
func BuildTimestamp() string {
218221
return buildTimestamp
219222
}
@@ -225,6 +228,7 @@ func TargetPaths() paths.PathList {
225228
return targetPaths
226229
}
227230

231+
// EnableLogging enables or disables logging debug output.
228232
func EnableLogging(enable bool) {
229233
if enable {
230234
logrus.SetOutput(defaultLogOutput) // Enable log output.

Diff for: internal/configuration/rulemode/rulemode.go

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func Modes(defaultRuleModes map[projecttype.Type]map[Type]bool, customRuleModes
9696
return ruleModes
9797
}
9898

99+
// Compliance returns the tool configuration's compliance setting name.
99100
func Compliance(ruleModes map[Type]bool) string {
100101
for key, value := range ruleModes {
101102
if value && (key == Strict || key == Specification || key == Permissive) {

Diff for: internal/project/packageindex/packageindex.go

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func HasValidFilename(filePath *paths.Path, officialRuleMode bool) bool {
5353
return regex.MatchString(filename)
5454
}
5555

56+
// Find searches the provided path for a file that has a name resembling a package index and returns the path to that file.
5657
func Find(folderPath *paths.Path) (*paths.Path, error) {
5758
exist, err := folderPath.ExistCheck()
5859
if !exist {

Diff for: internal/project/platform/platform.go

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ var bundledLibrariesFolderNames = map[string]struct{}{
5555
"libraries": empty,
5656
}
5757

58+
// BundledLibrariesFolderNames returns a list of supported names for the platform bundled libraries folder.
5859
func BundledLibrariesFolderNames() []string {
5960
folderNames := make([]string, 0, len(bundledLibrariesFolderNames))
6061
for folderName := range bundledLibrariesFolderNames {

Diff for: internal/project/project.go

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func FindProjects() ([]Type, error) {
5151
return foundProjects, nil
5252
}
5353

54+
// findProjects handles the recursion for FindProjects().
5455
func findProjects(targetPath *paths.Path) ([]Type, error) {
5556
var foundProjects []Type
5657

Diff for: internal/project/projectdata/library.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ import (
3232
"github.com/sirupsen/logrus"
3333
)
3434

35-
// Initialize gathers the library rule data for the specified project.
35+
// InitializeForLibrary gathers the library rule data for the specified project.
3636
func InitializeForLibrary(project project.Type) {
3737
var err error
3838

3939
libraryProperties, libraryPropertiesLoadError = libraryproperties.Properties(project.Path)
4040
if libraryPropertiesLoadError != nil {
4141
logrus.Errorf("Error loading library.properties from %s: %s", project.Path, libraryPropertiesLoadError)
42-
// TODO: can I even do this?
4342
libraryPropertiesSchemaValidationResult = nil
4443
} else {
4544
libraryPropertiesSchemaValidationResult = libraryproperties.Validate(libraryProperties)

Diff for: internal/project/projectdata/platform.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/arduino/go-properties-orderedmap"
2222
)
2323

24-
// Initialize gathers the platform rule data for the specified project.
24+
// InitializeForPlatform gathers the platform rule data for the specified project.
2525
func InitializeForPlatform(project project.Type) {
2626
boardsTxt, boardsTxtLoadError = boardstxt.Properties(ProjectPath())
2727
}

Diff for: internal/result/result.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ type Type struct {
4141
Summary summaryReportType `json:"summary"`
4242
}
4343

44+
// toolConfigurationReportType is the type for the arduino-lint tool configuration.
4445
type toolConfigurationReportType struct {
4546
Paths paths.PathList `json:"paths"`
4647
ProjectType string `json:"projectType"`
4748
Recursive bool `json:"recursive"`
4849
}
4950

51+
// projectReportType is the type for the individual project reports.
5052
type projectReportType struct {
5153
Path *paths.Path `json:"path"`
5254
ProjectType string `json:"projectType"`
@@ -55,12 +57,14 @@ type projectReportType struct {
5557
Summary summaryReportType `json:"summary"`
5658
}
5759

60+
// projectConfigurationReportType is the type for the individual project tool configurations.
5861
type projectConfigurationReportType struct {
5962
Compliance string `json:"compliance"`
6063
LibraryManager string `json:"libraryManager"`
6164
Official bool `json:"official"`
6265
}
6366

67+
// ruleReportType is the type of the rule reports.
6468
type ruleReportType struct {
6569
Category string `json:"category"`
6670
Subcategory string `json:"subcategory"`
@@ -72,6 +76,7 @@ type ruleReportType struct {
7276
Message string `json:"message"`
7377
}
7478

79+
// summaryReportType is the type of the rule result summary reports.
7580
type summaryReportType struct {
7681
Pass bool `json:"pass"`
7782
WarningCount int `json:"warningCount"`
@@ -210,11 +215,12 @@ func (results Type) SummaryText() string {
210215
return fmt.Sprintf("Finished linting projects. Results:\nWarning count: %v\nError count: %v\nRules passed: %v", results.Summary.WarningCount, results.Summary.ErrorCount, results.Summary.Pass)
211216
}
212217

213-
// JSONReport returns a JSON formatted report of rules on all projects.
218+
// JSONReport returns a JSON formatted report of rules on all projects in string encoding.
214219
func (results Type) JSONReport() string {
215220
return string(results.jsonReportRaw())
216221
}
217222

223+
// jsonReportRaw returns the report marshalled into JSON format in byte encoding.
218224
func (results Type) jsonReportRaw() []byte {
219225
reportJSON, err := json.MarshalIndent(results, "", " ")
220226
if err != nil {
@@ -251,6 +257,7 @@ func (results Type) Passed() bool {
251257
return results.Summary.Pass
252258
}
253259

260+
// getProjectReportIndex returns the index of the existing entry in the results.Projects array for the given project, or the next available index if there is no existing entry.
254261
func (results Type) getProjectReportIndex(projectPath *paths.Path) (bool, int) {
255262
var index int
256263
var projectReport projectReportType

Diff for: internal/rule/rule.go

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func shouldRun(ruleConfiguration ruleconfiguration.Type, currentProject project.
6969
return IsEnabled(ruleConfiguration, configurationRuleModes)
7070
}
7171

72+
// IsEnabled returns whether a given rule is enabled under a given tool configuration.
7273
func IsEnabled(ruleConfiguration ruleconfiguration.Type, configurationRuleModes map[rulemode.Type]bool) (bool, error) {
7374
for _, disableMode := range ruleConfiguration.DisableModes {
7475
if configurationRuleModes[disableMode] {

Diff for: internal/rule/rulefunction/library.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ func LibraryPropertiesNameFieldContainsLibrary() (result ruleresult.Type, output
481481
return ruleresult.Pass, ""
482482
}
483483

484-
// LibraryPropertiesNameFieldDuplicate checks whether there is an existing entry in the Library Manager index using the the library.properties `name` value.
484+
// LibraryPropertiesNameFieldDuplicate checks whether there is an existing entry in the Library Manager index using the library.properties `name` value.
485485
func LibraryPropertiesNameFieldDuplicate() (result ruleresult.Type, output string) {
486486
if projectdata.LibraryPropertiesLoadError() != nil {
487487
return ruleresult.NotRun, "Couldn't load library.properties"
@@ -499,7 +499,7 @@ func LibraryPropertiesNameFieldDuplicate() (result ruleresult.Type, output strin
499499
return ruleresult.Pass, ""
500500
}
501501

502-
// LibraryPropertiesNameFieldNotInIndex checks whether there is no existing entry in the Library Manager index using the the library.properties `name` value.
502+
// LibraryPropertiesNameFieldNotInIndex checks whether there is no existing entry in the Library Manager index using the library.properties `name` value.
503503
func LibraryPropertiesNameFieldNotInIndex() (result ruleresult.Type, output string) {
504504
if projectdata.LibraryPropertiesLoadError() != nil {
505505
return ruleresult.NotRun, "Couldn't load library.properties"
@@ -1019,7 +1019,7 @@ func LibraryPropertiesArchitecturesFieldLTMinLength() (result ruleresult.Type, o
10191019
return ruleresult.Pass, ""
10201020
}
10211021

1022-
// LibraryPropertiesArchitecturesFieldAlias checks whether an alias architecture name is present, but not its true Arduino architecture name.
1022+
// LibraryPropertiesArchitecturesFieldSoloAlias checks whether an alias architecture name is present, but not its true Arduino architecture name.
10231023
func LibraryPropertiesArchitecturesFieldSoloAlias() (result ruleresult.Type, output string) {
10241024
if projectdata.LibraryPropertiesLoadError() != nil {
10251025
return ruleresult.NotRun, "Couldn't load library.properties"

Diff for: internal/rule/rulefunction/rulefunction.go

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func containsMisspelledPathBaseName(pathList paths.PathList, correctBaseName str
114114
return nil, false
115115
}
116116

117+
// containsIncorrectPathBaseCase checks whether the list of paths contains an element with base name matching the provided query in all bug case.
117118
func containsIncorrectPathBaseCase(pathList paths.PathList, correctBaseName string) (*paths.Path, bool) {
118119
for _, path := range pathList {
119120
if path.Base() == correctBaseName {

Diff for: internal/rule/ruleresult/ruleresult.go

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// Package ruleresult defines the possible result values returned by a rule.
1717
package ruleresult
1818

19+
// Type is the type for rule results.
1920
//go:generate stringer -type=Type -linecomment
2021
type Type int
2122

Diff for: internal/rule/schema/compliancelevel/compliancelevel.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Arduino software without disclosing the source code of your own applications.
1414
// To purchase a commercial license, send an email to [email protected].
1515

16-
// Package compliance level defines the levels of specification compliance.
16+
// Package compliancelevel defines the levels of specification compliance.
1717
package compliancelevel
1818

1919
// Type is the type for the compliance levels.

Diff for: internal/rule/schema/parsevalidationresult.go

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func ValidationErrorMatch(
8383
)
8484
}
8585

86+
// validationErrorMatch handles the recursion for ValidationErrorMatch().
8687
func validationErrorMatch(
8788
instancePointerRegexp,
8889
schemaPointerRegexp,

0 commit comments

Comments
 (0)