Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Mar 20, 2024
1 parent bafa6d8 commit 19e2422
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
6 changes: 3 additions & 3 deletions internal/makefile/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ func FixRuleIndentation(in string) string {
var currentRecipeLines []string

for _, line := range strings.SplitAfter(in, "\n") {
//when inside a recipe, collect all lines belonging to it first
// when inside a recipe, collect all lines belonging to it first
if isRecipeRx.MatchString(line) {
currentRecipeLines = append(currentRecipeLines, line)
continue
}

//when not inside a recipe, return this line unchanged, but first transform
//the collected recipe (if any)
// when not inside a recipe, return this line unchanged, but first transform
// the collected recipe (if any)
if len(currentRecipeLines) > 0 {
for _, line := range fixRecipeIndentation(currentRecipeLines) {
out.WriteString(line)
Expand Down
16 changes: 8 additions & 8 deletions internal/makefile/makefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ endif
// Prepare
prepare := category{name: "prepare"}

//add target for installing dependencies for `make static-check`
// add target for installing dependencies for `make static-check`
prepareStaticRecipe := []string{
`@if ! hash golangci-lint 2>/dev/null; then` +
` printf "\e[1;36m>> Installing golangci-lint (this may take a while)...\e[0m\n";` +
Expand Down Expand Up @@ -217,7 +217,7 @@ endif
test.addDefinition(`space := $(null) $(null)`)
test.addDefinition(`comma := ,`)

//add main testing target
// add main testing target
checkPrerequisites := []string{"static-check", "build/cover.html"}
if hasBinaries {
checkPrerequisites = append(checkPrerequisites, "build-all")
Expand Down Expand Up @@ -257,7 +257,7 @@ endif
},
})

//add targets for test runner incl. coverage report
// add targets for test runner incl. coverage report
testRule := rule{
description: "Run tests and generate coverage report.",
phony: true,
Expand Down Expand Up @@ -302,13 +302,13 @@ endif
// Development
dev := category{name: "development"}

//ensure that build directory exists
// ensure that build directory exists
dev.addRule(rule{
target: "build",
recipe: []string{`@mkdir $@`},
})

//add tidy-deps or vendor target
// add tidy-deps or vendor target
if cfg.Golang.EnableVendoring {
dev.addRule(rule{
description: "Run go mod tidy, go mod verify, and go mod vendor.",
Expand Down Expand Up @@ -350,7 +350,7 @@ endif
ignoreOptions := []string{}
if cfg.GitHubWorkflow != nil {
for _, pattern := range cfg.GitHubWorkflow.License.IgnorePatterns {
//quoting avoids glob expansion
// quoting avoids glob expansion
ignoreOptions = append(ignoreOptions, fmt.Sprintf("-ignore %q", pattern))
}
}
Expand Down Expand Up @@ -401,7 +401,7 @@ endif
})
}

//add target for static code checks
// add target for static code checks
staticCheckPrerequisites := []string{"run-golangci-lint"}
if isSAPCC {
staticCheckPrerequisites = append(staticCheckPrerequisites, "check-dependency-licenses", "check-license-headers")
Expand All @@ -413,7 +413,7 @@ endif
prerequisites: staticCheckPrerequisites,
})

//add cleaning target
// add cleaning target
dev.addRule(rule{
description: "Run git clean.",
target: "clean",
Expand Down
8 changes: 4 additions & 4 deletions internal/makefile/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type makefile struct {
}

func (m *makefile) vars() *rule {
//collect all variable refs that look like $(THIS) or $(LIKE_THAT) from definitions and recipes
// collect all variable refs that look like $(THIS) or $(LIKE_THAT) from definitions and recipes
varRefRx := regexp.MustCompile(`\$\([A-Za-z_][A-Za-z0-9_]*\)`)
isVarRef := make(map[string]bool)
searchIn := func(inputs []string) {
Expand All @@ -100,12 +100,12 @@ func (m *makefile) vars() *rule {
}
}

//skip some variables that we only use internally to circumvent Makefile syntax limitations
// skip some variables that we only use internally to circumvent Makefile syntax limitations
delete(isVarRef, "$(comma)")
delete(isVarRef, "$(null)")
delete(isVarRef, "$(space)")

//compile a sorted list of variable names
// compile a sorted list of variable names
var varNames []string
for varRef := range isVarRef {
str := strings.TrimPrefix(varRef, "$(")
Expand All @@ -114,7 +114,7 @@ func (m *makefile) vars() *rule {
}
sort.Strings(varNames)

//generate a target printing their values (the output is not colorized to allow usage like `eval "$(make vars)"`)
// generate a target printing their values (the output is not colorized to allow usage like `eval "$(make vars)"`)
result := rule{
phony: true,
target: "vars",
Expand Down
3 changes: 1 addition & 2 deletions internal/renovate/renovate.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ func RenderConfig(cfgRenovate core.RenovateConfig, scanResult core.ScanResult, u
}
hasK8sIOPkgs := false
for _, v := range scanResult.GoDirectDependencies {
switch dep := v.Path; {
case strings.HasPrefix(dep, "k8s.io/"):
if strings.HasPrefix(v.Path, "k8s.io/") {
hasK8sIOPkgs = true
}
}
Expand Down

0 comments on commit 19e2422

Please sign in to comment.