Skip to content

Commit 100b2dd

Browse files
committed
Use more appropriate variable name for project type filter
The term "project type" is used both to refer to the type of the project filter, which may be "all", and to the specific project type (e.g., sketch, library, platform). This can result in some ambiguity in the code. The use of "filter" in variable names that are used exclusively for project type filters may make the code easier to follow.
1 parent 9f1b6aa commit 100b2dd

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

project/project.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ func FindProjects() ([]Type, error) {
6161
}
6262

6363
// findProjectsUnderPath finds projects of the given type and subprojects of those projects. It returns a slice containing the definitions of all found projects.
64-
func findProjectsUnderPath(targetPath *paths.Path, projectType projecttype.Type, recursive bool) []Type {
64+
func findProjectsUnderPath(targetPath *paths.Path, projectTypeFilter projecttype.Type, recursive bool) []Type {
6565
var foundProjects []Type
6666

67-
isProject, foundProjectType := isProject(targetPath, projectType)
67+
isProject, foundProjectType := isProject(targetPath, projectTypeFilter)
6868
if isProject {
6969
logrus.Tracef("%s is %s", targetPath, foundProjectType)
7070
foundProject := Type{
@@ -86,7 +86,7 @@ func findProjectsUnderPath(targetPath *paths.Path, projectType projecttype.Type,
8686
directoryListing, _ := targetPath.ReadDir()
8787
directoryListing.FilterDirs()
8888
for _, potentialProjectDirectory := range directoryListing {
89-
foundProjects = append(foundProjects, findProjectsUnderPath(potentialProjectDirectory, projectType, recursive)...)
89+
foundProjects = append(foundProjects, findProjectsUnderPath(potentialProjectDirectory, projectTypeFilter, recursive)...)
9090
}
9191
}
9292

@@ -141,37 +141,37 @@ func findSubprojects(superproject Type, apexSuperprojectType projecttype.Type) [
141141
}
142142

143143
// isProject determines if a path contains an Arduino project, and if so which type.
144-
func isProject(potentialProjectPath *paths.Path, projectType projecttype.Type) (bool, projecttype.Type) {
145-
logrus.Tracef("Checking if %s is %s", potentialProjectPath, projectType)
146-
if projectType.Matches(projecttype.Sketch) && isSketch(potentialProjectPath) {
144+
func isProject(potentialProjectPath *paths.Path, projectTypeFilter projecttype.Type) (bool, projecttype.Type) {
145+
logrus.Tracef("Checking if %s is %s", potentialProjectPath, projectTypeFilter)
146+
if projectTypeFilter.Matches(projecttype.Sketch) && isSketch(potentialProjectPath) {
147147
logrus.Tracef("%s is %s", potentialProjectPath, projecttype.Sketch)
148148
return true, projecttype.Sketch
149-
} else if projectType.Matches(projecttype.Library) && isLibrary(potentialProjectPath) {
149+
} else if projectTypeFilter.Matches(projecttype.Library) && isLibrary(potentialProjectPath) {
150150
logrus.Tracef("%s is %s", potentialProjectPath, projecttype.Library)
151151
return true, projecttype.Library
152-
} else if projectType.Matches(projecttype.Platform) && isPlatform(potentialProjectPath) {
152+
} else if projectTypeFilter.Matches(projecttype.Platform) && isPlatform(potentialProjectPath) {
153153
logrus.Tracef("%s is %s", potentialProjectPath, projecttype.Platform)
154154
return true, projecttype.Platform
155-
} else if projectType.Matches(projecttype.PackageIndex) && isPackageIndex(potentialProjectPath) {
155+
} else if projectTypeFilter.Matches(projecttype.PackageIndex) && isPackageIndex(potentialProjectPath) {
156156
logrus.Tracef("%s is %s", potentialProjectPath, projecttype.PackageIndex)
157157
return true, projecttype.PackageIndex
158158
}
159159
return false, projecttype.Not
160160
}
161161

162162
// isProject determines if a file is the indicator file for an Arduino project, and if so which type.
163-
func isProjectIndicatorFile(potentialProjectFilePath *paths.Path, projectType projecttype.Type) (bool, projecttype.Type) {
164-
logrus.Tracef("Checking if %s is %s indicator file", potentialProjectFilePath, projectType)
165-
if projectType.Matches(projecttype.Sketch) && isSketchIndicatorFile(potentialProjectFilePath) {
163+
func isProjectIndicatorFile(potentialProjectFilePath *paths.Path, projectTypeFilter projecttype.Type) (bool, projecttype.Type) {
164+
logrus.Tracef("Checking if %s is %s indicator file", potentialProjectFilePath, projectTypeFilter)
165+
if projectTypeFilter.Matches(projecttype.Sketch) && isSketchIndicatorFile(potentialProjectFilePath) {
166166
logrus.Tracef("%s is %s indicator file", potentialProjectFilePath, projecttype.Sketch)
167167
return true, projecttype.Sketch
168-
} else if projectType.Matches(projecttype.Library) && isLibraryIndicatorFile(potentialProjectFilePath) {
168+
} else if projectTypeFilter.Matches(projecttype.Library) && isLibraryIndicatorFile(potentialProjectFilePath) {
169169
logrus.Tracef("%s is %s indicator file", potentialProjectFilePath, projecttype.Library)
170170
return true, projecttype.Library
171-
} else if projectType.Matches(projecttype.Platform) && isPlatformIndicatorFile(potentialProjectFilePath) {
171+
} else if projectTypeFilter.Matches(projecttype.Platform) && isPlatformIndicatorFile(potentialProjectFilePath) {
172172
logrus.Tracef("%s is %s indicator file", potentialProjectFilePath, projecttype.Platform)
173173
return true, projecttype.Platform
174-
} else if projectType.Matches(projecttype.PackageIndex) && isPackageIndexIndicatorFile(potentialProjectFilePath) {
174+
} else if projectTypeFilter.Matches(projecttype.PackageIndex) && isPackageIndexIndicatorFile(potentialProjectFilePath) {
175175
logrus.Tracef("%s is %s indicator file", potentialProjectFilePath, projecttype.PackageIndex)
176176
return true, projecttype.PackageIndex
177177
}

0 commit comments

Comments
 (0)