Skip to content

Commit 998dcba

Browse files
author
Mateus Oliveira
authored
🌱 fix: remove unused nolint comments (#4468)
fix: remove unused nolint comments Signed-off-by: Mateus Oliveira <[email protected]>
1 parent d741ec6 commit 998dcba

File tree

51 files changed

+56
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+56
-86
lines changed

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ linters-settings:
2222
disable:
2323
- fieldalignment
2424
- shadow
25+
nolintlint:
26+
allow-unused: false
2527
revive:
2628
rules:
2729
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
@@ -78,6 +80,7 @@ linters:
7880
- ineffassign
7981
- lll
8082
- misspell
83+
- nolintlint
8184
- nakedret
8285
- prealloc
8386
- revive

cmd/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import (
2525
"sigs.k8s.io/kubebuilder/v4/pkg/plugin"
2626
kustomizecommonv2 "sigs.k8s.io/kubebuilder/v4/pkg/plugins/common/kustomize/v2"
2727
"sigs.k8s.io/kubebuilder/v4/pkg/plugins/golang"
28-
29-
//nolint:staticcheck
3028
deployimagev1alpha1 "sigs.k8s.io/kubebuilder/v4/pkg/plugins/golang/deploy-image/v1alpha1"
3129
golangv4 "sigs.k8s.io/kubebuilder/v4/pkg/plugins/golang/v4"
3230
grafanav1alpha1 "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/grafana/v1alpha"

pkg/cli/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package cli //nolint:dupl
17+
package cli
1818

1919
import (
2020
"fmt"

pkg/cli/cli_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ func setBoolFlag(flag string) {
6060
os.Args = append(os.Args, "subcommand", "--"+flag)
6161
}
6262

63-
// nolint:unparam
6463
func setProjectVersionFlag(value string) {
6564
setFlag(projectVersionFlag, value)
6665
}

pkg/cli/cmd_helpers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func (factory *executionHooksFactory) preRunEFunc(
285285
}
286286

287287
// Pre-scaffold hook.
288-
// nolint:revive
288+
//nolint:revive
289289
if err := factory.forEach(func(subcommand plugin.Subcommand) error {
290290
if subcommand, hasPreScaffold := subcommand.(plugin.HasPreScaffold); hasPreScaffold {
291291
return subcommand.PreScaffold(factory.fs)
@@ -303,7 +303,7 @@ func (factory *executionHooksFactory) preRunEFunc(
303303
func (factory *executionHooksFactory) runEFunc() func(*cobra.Command, []string) error {
304304
return func(*cobra.Command, []string) error {
305305
// Scaffold hook.
306-
// nolint:revive
306+
//nolint:revive
307307
if err := factory.forEach(func(subcommand plugin.Subcommand) error {
308308
return subcommand.Scaffold(factory.fs)
309309
}, "unable to scaffold with"); err != nil {
@@ -323,7 +323,7 @@ func (factory *executionHooksFactory) postRunEFunc() func(*cobra.Command, []stri
323323
}
324324

325325
// Post-scaffold hook.
326-
// nolint:revive
326+
//nolint:revive
327327
if err := factory.forEach(func(subcommand plugin.Subcommand) error {
328328
if subcommand, hasPostScaffold := subcommand.(plugin.HasPostScaffold); hasPostScaffold {
329329
return subcommand.PostScaffold()

pkg/cli/edit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package cli //nolint:dupl
17+
package cli
1818

1919
import (
2020
"fmt"

pkg/cli/webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package cli //nolint:dupl
17+
package cli
1818

1919
import (
2020
"fmt"

pkg/model/resource/resource_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
. "github.com/onsi/gomega"
2222
)
2323

24-
//nolint:dupl
2524
var _ = Describe("Resource", func() {
2625
const (
2726
group = "group"

pkg/plugin/util/util.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ func GetNonEmptyLines(output string) []string {
6464

6565
// InsertCode searches target content in the file and insert `toInsert` after the target.
6666
func InsertCode(filename, target, code string) error {
67-
// false positive
68-
// nolint:gosec
67+
//nolint:gosec // false positive
6968
contents, err := os.ReadFile(filename)
7069
if err != nil {
7170
return err
@@ -75,15 +74,13 @@ func InsertCode(filename, target, code string) error {
7574
return fmt.Errorf("string %s not found in %s", target, string(contents))
7675
}
7776
out := string(contents[:idx+len(target)]) + code + string(contents[idx+len(target):])
78-
// false positive
79-
// nolint:gosec
77+
//nolint:gosec // false positive
8078
return os.WriteFile(filename, []byte(out), 0644)
8179
}
8280

8381
// InsertCodeIfNotExist insert code if it does not already exists
8482
func InsertCodeIfNotExist(filename, target, code string) error {
85-
// false positive
86-
// nolint:gosec
83+
//nolint:gosec // false positive
8784
contents, err := os.ReadFile(filename)
8885
if err != nil {
8986
return err
@@ -130,8 +127,7 @@ func AppendCodeAtTheEnd(filename, code string) error {
130127
// UncommentCode searches for target in the file and remove the comment prefix
131128
// of the target content. The target content may span multiple lines.
132129
func UncommentCode(filename, target, prefix string) error {
133-
// false positive
134-
// nolint:gosec
130+
//nolint:gosec // false positive
135131
content, err := os.ReadFile(filename)
136132
if err != nil {
137133
return err
@@ -171,8 +167,7 @@ func UncommentCode(filename, target, prefix string) error {
171167
if err != nil {
172168
return err
173169
}
174-
// false positive
175-
// nolint:gosec
170+
//nolint:gosec // false positive
176171
return os.WriteFile(filename, out.Bytes(), 0644)
177172
}
178173

@@ -232,8 +227,7 @@ func ReplaceInFile(path, oldValue, newValue string) error {
232227
if err != nil {
233228
return err
234229
}
235-
// false positive
236-
// nolint:gosec
230+
//nolint:gosec // false positive
237231
b, err := os.ReadFile(path)
238232
if err != nil {
239233
return err
@@ -260,8 +254,7 @@ func ReplaceRegexInFile(path, match, replace string) error {
260254
if err != nil {
261255
return err
262256
}
263-
// false positive
264-
// nolint:gosec
257+
//nolint:gosec // false positive
265258
b, err := os.ReadFile(path)
266259
if err != nil {
267260
return err
@@ -279,7 +272,7 @@ func ReplaceRegexInFile(path, match, replace string) error {
279272

280273
// HasFileContentWith check if given `text` can be found in file
281274
func HasFileContentWith(path, text string) (bool, error) {
282-
// nolint:gosec
275+
//nolint:gosec
283276
contents, err := os.ReadFile(path)
284277
if err != nil {
285278
return false, err

pkg/plugins/common/kustomize/v2/scaffolds/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (s *apiScaffolder) Scaffold() error {
9191
}
9292
}
9393

94-
// nolint:goconst
94+
//nolint:goconst
9595
kustomizeFilePath := "config/default/kustomization.yaml"
9696
err := pluginutil.UncommentCode(kustomizeFilePath, "#- ../crd", `#`)
9797
if err != nil {

0 commit comments

Comments
 (0)