Skip to content

Commit

Permalink
update linter config and fix issues
Browse files Browse the repository at this point in the history
Selecting linters in the workflow file has the disadvantage that a manual
"golangci-lint run" invocation uses different settings. It's better to do it in
a configuration file.

Several of the selected linters were deprecated and thus get removed:

    WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
    WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
    WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.

Some issues were reported with this configuration by golangci-lint 1.52.2 and get fixed.
  • Loading branch information
pohly committed Aug 4, 2023
1 parent 6e2be81 commit b34ac77
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,3 @@ jobs:
args:
-v
--max-same-issues 10
--disable-all
--exclude-use-default=false
-E asciicheck
-E deadcode
-E errcheck
-E forcetypeassert
-E gocritic
-E gofmt
-E goimports
-E gosimple
-E govet
-E ineffassign
-E misspell
-E revive
-E staticcheck
-E structcheck
-E typecheck
-E unused
-E varcheck
20 changes: 20 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
issues:
exclude-use-default: false

linters:
disable-all: true
enable:
- asciicheck
- errcheck
- forcetypeassert
- gocritic
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- revive
- staticcheck
- typecheck
- unused
2 changes: 2 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// This example shows how to instantiate a zap logger and what output
// looks like.
package main

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

// Package types holds a copy of the ObjectRef type from klog for
// use in the example.
package types

import (
Expand Down
6 changes: 3 additions & 3 deletions zapr.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ limitations under the License.
// Package zapr defines an implementation of the github.com/go-logr/logr
// interfaces built on top of Zap (go.uber.org/zap).
//
// Usage
// # Usage
//
// A new logr.Logger can be constructed from an existing zap.Logger using
// the NewLogger function:
//
// log := zapr.NewLogger(someZapLogger)
// log := zapr.NewLogger(someZapLogger)
//
// Implementation Details
// # Implementation Details
//
// For the most part, concepts in Zap correspond directly with those in
// logr.
Expand Down
2 changes: 1 addition & 1 deletion zapr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func fixedTimeEncoder(_ time.Time, enc zapcore.PrimitiveArrayEncoder) {
// discard is a replacement for io.Discard, needed for Go 1.14.
type discard struct{}

func (d discard) Write(p []byte) (n int, err error) { return n, nil }
func (d discard) Write(_ []byte) (int, error) { return 0, nil }

type marshaler struct {
msg string
Expand Down

0 comments on commit b34ac77

Please sign in to comment.