Skip to content

Commit

Permalink
lint: Pass zapcore and zaptest packages
Browse files Browse the repository at this point in the history
golangci-lint running revive current fails on master. I've exempted the
dot import failures since these are used to reduce a large number of
qualifiers in the zapcore packages's _test package tests.

If also simplified a if/else statement as well with a logical equivalent and
standardized a test that imported a package and used it's dot import at
the same time.
  • Loading branch information
r-hang committed Nov 7, 2023
1 parent 87577d8 commit 1d12201
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions zapcore/console_encoder_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package zapcore_test
import (
"testing"

//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
)

Expand Down
1 change: 1 addition & 0 deletions zapcore/console_encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
)

Expand Down
1 change: 1 addition & 0 deletions zapcore/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"time"

"go.uber.org/zap/internal/ztest"
//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"

"github.com/stretchr/testify/assert"
Expand Down
1 change: 1 addition & 0 deletions zapcore/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"

//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
)

Expand Down
4 changes: 2 additions & 2 deletions zapcore/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/stretchr/testify/assert"

"go.uber.org/multierr"
"go.uber.org/zap/zapcore"
//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
)

Expand Down Expand Up @@ -205,6 +205,6 @@ func (enc brokenArrayObjectEncoder) AddArray(key string, marshaler ArrayMarshale
}))
}

func (enc brokenArrayObjectEncoder) AppendObject(zapcore.ObjectMarshaler) error {
func (enc brokenArrayObjectEncoder) AppendObject(ObjectMarshaler) error {
return enc.Err
}
5 changes: 3 additions & 2 deletions zapcore/field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"

//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
)

Expand Down Expand Up @@ -88,9 +90,8 @@ type errObj struct {
func (eobj *errObj) Error() string {
if eobj.kind == 1 {
panic("panic in Error() method")
} else {
return eobj.errMsg
}
return eobj.errMsg
}

func TestUnknownFieldType(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions zapcore/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package zapcore_test
import (
"testing"

//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"

Expand Down
2 changes: 2 additions & 0 deletions zapcore/increase_level_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"

//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"
)
Expand Down
1 change: 1 addition & 0 deletions zapcore/json_encoder_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"testing"
"time"

//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
)

Expand Down
2 changes: 2 additions & 0 deletions zapcore/sampler_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (

"github.com/stretchr/testify/assert"
"go.uber.org/zap/internal/ztest"

//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
)

Expand Down
1 change: 1 addition & 0 deletions zapcore/sampler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"time"

"go.uber.org/zap/internal/ztest"
//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"

Expand Down
1 change: 1 addition & 0 deletions zapcore/tee_logger_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"testing"

"go.uber.org/zap/internal/ztest"
//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
)

Expand Down
1 change: 1 addition & 0 deletions zapcore/tee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"testing"

"go.uber.org/zap/internal/ztest"
//revive:disable:dot-imports
. "go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"

Expand Down
2 changes: 2 additions & 0 deletions zaptest/observer/observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (

"go.uber.org/zap"
"go.uber.org/zap/zapcore"

//revive:disable:dot-imports
. "go.uber.org/zap/zaptest/observer"
)

Expand Down

0 comments on commit 1d12201

Please sign in to comment.