Skip to content

Commit

Permalink
chore(*): auto fix some lint error (streamnative#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsytj0413 authored Feb 23, 2025
1 parent 899b456 commit f140dab
Show file tree
Hide file tree
Showing 61 changed files with 91 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr_build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
uses: golangci/golangci-lint-action@v6.1.0
with:
version: v1.61.0
args: --timeout=10m
args: --timeout=10m -v

- name: Test
run: make test
Expand Down
10 changes: 4 additions & 6 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

run:
skip-dirs:
- pkg/generated

linters:
enable:
- goimports
Expand All @@ -34,7 +30,7 @@ linters:
- contextcheck
- errname
- errorlint
- exportloopref
- copyloopvar
- gocritic
- godot
- gomoddirectives
Expand Down Expand Up @@ -85,7 +81,7 @@ linters-settings:
arguments:
- maxLitCount: "3"
allowStrs: '""'
allowInts: '0,1,2,3,4,5,6,7,8,9,10,11,16,17,20,22,32,64,100,128,1000,1024,0644,0755,0600'
allowInts: "0,1,2,3,4,5,6,7,8,9,10,11,16,17,20,22,32,64,100,128,1000,1024,0644,0755,0600"
allowFloats: "0.0,0.,0.5,0.50,0.95,0.99,0.999,1.0,1.,2.0,2.,80.0,100.0"
ignoreFuncs: 'slog\.*,metrics\.*,fmt\.*'
- name: cognitive-complexity
Expand Down Expand Up @@ -133,6 +129,8 @@ issues:
fix: true
max-same-issues: 3
max-issues-per-linter: 50
exclude-dirs:
- pkg/generated
# include:
# - "EXC0012"
# - "EXC0014"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test: build

lint:
#brew install golangci-lint
golangci-lint run
golangci-lint run -v

clean:
rm -f bin/oxia bin/oxia-maelstrom
Expand Down
6 changes: 2 additions & 4 deletions cmd/client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@ package client
import (
"fmt"

"github.com/streamnative/oxia/cmd/client/deleterange"

"github.com/spf13/cobra"

"github.com/streamnative/oxia/oxia"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/cmd/client/del"
"github.com/streamnative/oxia/cmd/client/deleterange"
"github.com/streamnative/oxia/cmd/client/get"
"github.com/streamnative/oxia/cmd/client/list"
"github.com/streamnative/oxia/cmd/client/notifications"
"github.com/streamnative/oxia/cmd/client/put"
"github.com/streamnative/oxia/cmd/client/rangescan"
oxiacommon "github.com/streamnative/oxia/common"
"github.com/streamnative/oxia/oxia"
)

var (
Expand Down
5 changes: 2 additions & 3 deletions cmd/client/del/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ import (
"testing"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"

"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
)

func runCmd(cmd *cobra.Command, args string) (string, error) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/deleterange/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import (

"github.com/spf13/cobra"

"github.com/streamnative/oxia/oxia"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/deleterange/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import (
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"

"github.com/streamnative/oxia/oxia"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

func runCmd(cmd *cobra.Command, args string, stdin string) (string, error) {
Expand Down
4 changes: 1 addition & 3 deletions cmd/client/get/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ import (
"time"

"github.com/pkg/errors"

"github.com/streamnative/oxia/oxia"

"github.com/spf13/cobra"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/get/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import (
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"

"github.com/streamnative/oxia/oxia"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

func runCmd(cmd *cobra.Command, args string, stdin string) (string, error) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/list/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import (

"github.com/spf13/cobra"

"github.com/streamnative/oxia/oxia"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/list/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import (
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"

"github.com/streamnative/oxia/oxia"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

func runCmd(cmd *cobra.Command, args string, stdin string) (string, error) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/notifications/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ package notifications
import (
"log/slog"

"github.com/streamnative/oxia/oxia"

"github.com/spf13/cobra"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

var Cmd = &cobra.Command{
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/put/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import (

"github.com/spf13/cobra"

"github.com/streamnative/oxia/oxia"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/rangescan/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import (
"context"
"time"

"github.com/streamnative/oxia/oxia"

"github.com/spf13/cobra"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions cmd/client/rangescan/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import (
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"

"github.com/streamnative/oxia/oxia"

"github.com/streamnative/oxia/cmd/client/common"
"github.com/streamnative/oxia/oxia"
)

func runCmd(cmd *cobra.Command, args string, stdin string) (string, error) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/coordinator/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import (
"log/slog"
"strings"

"github.com/fsnotify/fsnotify"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"

"github.com/fsnotify/fsnotify"
"github.com/spf13/cobra"
"github.com/spf13/viper"

Expand Down
3 changes: 1 addition & 2 deletions cmd/coordinator/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import (
"strings"
"testing"

"github.com/spf13/viper"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"

Expand Down
3 changes: 1 addition & 2 deletions cmd/health/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"fmt"
"testing"

"github.com/streamnative/oxia/server/auth"

"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand All @@ -28,6 +26,7 @@ import (
"google.golang.org/grpc/status"

"github.com/streamnative/oxia/common/container"
"github.com/streamnative/oxia/server/auth"
)

func TestHealthCmd(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"fmt"
"os"

"github.com/streamnative/oxia/cmd/wal"

"github.com/spf13/cobra"
"go.uber.org/automaxprocs/maxprocs"

Expand All @@ -31,6 +29,7 @@ import (
"github.com/streamnative/oxia/cmd/perf"
"github.com/streamnative/oxia/cmd/server"
"github.com/streamnative/oxia/cmd/standalone"
"github.com/streamnative/oxia/cmd/wal"
"github.com/streamnative/oxia/common"
)

Expand Down
3 changes: 1 addition & 2 deletions cmd/perf/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ import (
"fmt"
"io"

"github.com/streamnative/oxia/oxia"

"github.com/spf13/cobra"

"github.com/streamnative/oxia/common"
"github.com/streamnative/oxia/oxia"
"github.com/streamnative/oxia/perf"
)

Expand Down
5 changes: 3 additions & 2 deletions common/callback/once_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
package callback

import (
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"sync"
"sync/atomic"
"testing"

"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)

func Test_Once_Complete_Concurrent(t *testing.T) {
Expand Down
10 changes: 4 additions & 6 deletions common/client_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@ package common
import (
"context"
"crypto/tls"
"google.golang.org/grpc/keepalive"
"io"
"log/slog"
"strings"
"sync"
"time"

"github.com/streamnative/oxia/oxia/auth"

"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"

grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/peer"

"github.com/streamnative/oxia/oxia/auth"
"github.com/streamnative/oxia/proto"
)

Expand Down
3 changes: 2 additions & 1 deletion common/client_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package common

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestClientPool_GetActualAddress(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion common/collection/visible_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package collection

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestVisibleMap(t *testing.T) {
Expand Down
10 changes: 4 additions & 6 deletions common/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@ package container
import (
"context"
"crypto/tls"
"google.golang.org/grpc/keepalive"
"io"
"log/slog"
"net"
"os"
"time"

"github.com/streamnative/oxia/server/auth"

"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"

grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"

"github.com/streamnative/oxia/common"
"github.com/streamnative/oxia/server/auth"
)

const (
Expand Down
1 change: 0 additions & 1 deletion common/opt_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"reflect"

"github.com/mitchellh/mapstructure"

"github.com/pkg/errors"
)

Expand Down
3 changes: 1 addition & 2 deletions coordinator/coordinator_rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ package coordinator
import (
"crypto/tls"

"github.com/streamnative/oxia/server/auth"

"google.golang.org/grpc"
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"

"github.com/streamnative/oxia/common/container"
"github.com/streamnative/oxia/server/auth"
)

type rpcServer struct {
Expand Down
Loading

0 comments on commit f140dab

Please sign in to comment.