sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugins/golang/v4/scaffolds/internal/templates/golangci.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package templates 18 19 import ( 20 "sigs.k8s.io/kubebuilder/v3/pkg/machinery" 21 ) 22 23 var _ machinery.Template = &Golangci{} 24 25 // Golangci scaffolds a file which define Golangci rules 26 type Golangci struct { 27 machinery.TemplateMixin 28 machinery.ProjectNameMixin 29 } 30 31 // SetTemplateDefaults implements file.Template 32 func (f *Golangci) SetTemplateDefaults() error { 33 if f.Path == "" { 34 f.Path = ".golangci.yml" 35 } 36 37 f.TemplateBody = golangciTemplate 38 39 f.IfExistsAction = machinery.SkipFile 40 41 return nil 42 } 43 44 //nolint:lll 45 const golangciTemplate = `run: 46 deadline: 5m 47 allow-parallel-runners: true 48 49 issues: 50 # don't skip warning about doc comments 51 # don't exclude the default set of lint 52 exclude-use-default: false 53 # restore some of the defaults 54 # (fill in the rest as needed) 55 exclude-rules: 56 - path: "api/*" 57 linters: 58 - lll 59 - path: "internal/*" 60 linters: 61 - dupl 62 - lll 63 linters: 64 disable-all: true 65 enable: 66 - dupl 67 - errcheck 68 - exportloopref 69 - goconst 70 - gocyclo 71 - gofmt 72 - goimports 73 - gosimple 74 - govet 75 - ineffassign 76 - lll 77 - misspell 78 - nakedret 79 - prealloc 80 - staticcheck 81 - typecheck 82 - unconvert 83 - unparam 84 - unused 85 `