Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Update golangci-lint to 1.49.0 #7114

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.48.0
version: v1.49.0
working-directory: ${{matrix.working-directory}}
24 changes: 1 addition & 23 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ linters:
- asciicheck
- bodyclose
- containedctx
- deadcode
- depguard
- dogsled
- errcheck
Expand All @@ -19,7 +18,6 @@ linters:
- gosec
- gosimple
- govet
- ifshort
- importas
- ineffassign
- misspell
Expand All @@ -32,14 +30,12 @@ linters:
- revive
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- thelper
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace

linters-settings:
Expand All @@ -51,9 +47,6 @@ linters-settings:
exclude:
- '^ \+.*'
- '^ ANCHOR.*'
ifshort:
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
max-decl-chars: 50
gci:
local-prefixes: "sigs.k8s.io/cluster-api"
importas:
Expand Down Expand Up @@ -215,13 +208,7 @@ issues:
- linters:
- gocritic
text: "appendAssign: append result not assigned to the same slice"
# ifshort flags variables that are only used in the if-statement even though there is
# already a SimpleStmt being used in the if-statement in question.
- linters:
- ifshort
text: "variable .* is only used in the if-statement"
path: controllers/mdutil/util.go
# Disable linters for conversion
# Disable linters for conversion
- linters:
- staticcheck
text: "SA1019: in.(.+) is deprecated"
Expand Down Expand Up @@ -251,15 +238,6 @@ issues:
- typecheck
text: import (".+") is a program, not an importable package
path: ^tools\.go$
# TODO(sbueringer) Ignore ifshort false positive: https://github.com/esimonov/ifshort/issues/23
- linters:
- ifshort
text: "variable 'isDeleteNodeAllowed' is only used in the if-statement.*"
path: ^internal/controllers/machine/machine_controller\.go$
- linters:
- ifshort
text: "variable 'kcpMachinesWithErrors' is only used in the if-statement.*"
path: ^controlplane/kubeadm/internal/workload_cluster_conditions\.go$
# We don't care about defer in for loops in test files.
- linters:
- gocritic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could also delete as a minor cleanup:

 skip-dirs:
  - third_party

skip-dirs:

Copy link
Member

@sbueringer sbueringer Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand Down
9 changes: 6 additions & 3 deletions bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for the Kubeadm Bootstrap provider.
package main

import (
Expand Down Expand Up @@ -151,11 +152,13 @@ func main() {

// klog.Background will automatically use the right logger.
ctrl.SetLogger(klog.Background())

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
setupLog.Info(fmt.Sprintf("Profiler listening for requests at %s", profilerAddress))
go func() {
klog.Info(http.ListenAndServe(profilerAddress, nil))
srv := http.Server{Addr: profilerAddress, ReadHeaderTimeout: 2 * time.Second}
if err := srv.ListenAndServe(); err != nil {
setupLog.Error(err, "problem running profiler server")
sbueringer marked this conversation as resolved.
Show resolved Hide resolved
}
}()
}

Expand Down
1 change: 1 addition & 0 deletions cmd/clusterctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for clusterctl.
package main

import (
Expand Down
8 changes: 6 additions & 2 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for the Kubeadm Control Plane provider.
package main

import (
Expand Down Expand Up @@ -156,9 +157,12 @@ func main() {
ctrl.SetLogger(klog.Background())

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
setupLog.Info(fmt.Sprintf("Profiler listening for requests at %s", profilerAddress))
go func() {
klog.Info(http.ListenAndServe(profilerAddress, nil))
srv := http.Server{Addr: profilerAddress, ReadHeaderTimeout: 2 * time.Second}
killianmuldoon marked this conversation as resolved.
Show resolved Hide resolved
if err := srv.ListenAndServe(); err != nil {
setupLog.Error(err, "problem running profiler server")
}
}()
}

Expand Down
4 changes: 2 additions & 2 deletions exp/runtime/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func (s *Server) validateHandler(handler ExtensionHandler) error {
}

// Get hook and handler request and response types.
hookRequestType := hookFuncType.In(0) //nolint:ifshort
hookResponseType := hookFuncType.In(1) //nolint:ifshort
hookRequestType := hookFuncType.In(0)
hookResponseType := hookFuncType.In(1)
handlerContextType := handlerFuncType.In(0)
handlerRequestType := handlerFuncType.In(1)
handlerResponseType := handlerFuncType.In(2)
Expand Down
2 changes: 2 additions & 0 deletions hack/tools/conversion-verifier/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ limitations under the License.
// the type MUST have a Hub() method.
// - For each type with multiple versions, that has a Hub() and storage version,
// the type MUST have ConvertFrom() and ConvertTo() methods.

// main is the main package for the conversion-verifier.
package main
1 change: 1 addition & 0 deletions hack/tools/log-push/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for Log Push.
package main

import (
Expand Down
1 change: 1 addition & 0 deletions hack/tools/mdbook/embed/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for mdbook-embed.
package main

import (
Expand Down
1 change: 1 addition & 0 deletions hack/tools/mdbook/releaselink/releaselink.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for mdbook-releaselink.
package main

import (
Expand Down
1 change: 1 addition & 0 deletions hack/tools/mdbook/tabulate/tabulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for mdbook-tabulate.
package main

import (
Expand Down
1 change: 1 addition & 0 deletions hack/tools/release/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for the release notes generator.
package main

import (
Expand Down
1 change: 1 addition & 0 deletions hack/tools/runtime-openapi-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for openapi-gen.
package main

import (
Expand Down
1 change: 1 addition & 0 deletions hack/tools/tilt-prepare/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for Tilt Prepare.
package main

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/machine/machine_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var (
)

func (r *Reconciler) reconcilePhase(_ context.Context, m *clusterv1.Machine) {
originalPhase := m.Status.Phase //nolint:ifshort // Cannot be inlined because m.Status.Phase might be changed before it is used in the if.
originalPhase := m.Status.Phase

// Set the phase to "pending" if nil.
if m.Status.Phase == "" {
Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for the Cluster API Core Provider.
package main

import (
Expand Down Expand Up @@ -216,9 +217,12 @@ func main() {
ctrl.SetLogger(klog.Background())

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
setupLog.Info(fmt.Sprintf("Profiler listening for requests at %s", profilerAddress))
go func() {
klog.Info(http.ListenAndServe(profilerAddress, nil))
srv := http.Server{Addr: profilerAddress, ReadHeaderTimeout: 2 * time.Second}
if err := srv.ListenAndServe(); err != nil {
setupLog.Error(err, "problem running profiler server")
}
}()
}

Expand Down
10 changes: 8 additions & 2 deletions test/extension/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for the Test Extension.
package main

import (
"flag"
"fmt"
"net/http"
"os"
"time"

"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -89,9 +92,12 @@ func main() {
ctrl.SetLogger(klog.Background())

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
setupLog.Info(fmt.Sprintf("Profiler listening for requests at %s", profilerAddress))
go func() {
klog.Info(http.ListenAndServe(profilerAddress, nil))
srv := http.Server{Addr: profilerAddress, ReadHeaderTimeout: 2 * time.Second}
if err := srv.ListenAndServe(); err != nil {
setupLog.Error(err, "problem running profiler server")
}
}()
}

Expand Down
9 changes: 7 additions & 2 deletions test/infrastructure/docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// main is the main package for the Docker Infrastructure Provider.
package main

import (
"context"
"flag"
"fmt"
"math/rand"
"net/http"
"os"
Expand Down Expand Up @@ -126,9 +128,12 @@ func main() {
ctrl.SetLogger(klog.Background())

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
setupLog.Info(fmt.Sprintf("Profiler listening for requests at %s", profilerAddress))
go func() {
klog.Info(http.ListenAndServe(profilerAddress, nil))
srv := http.Server{Addr: profilerAddress, ReadHeaderTimeout: 2 * time.Second}
if err := srv.ListenAndServe(); err != nil {
setupLog.Error(err, "problem running profiler server")
}
}()
}

Expand Down