Skip to content

Commit

Permalink
fix linter (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangfu0 committed Apr 7, 2024
1 parent 6e00d5d commit 6fcbc7a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ jobs:
runs-on: ubuntu-latest
name: Linter
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19
cache: false

- name: Linter
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4

unit-tests:
runs-on: ubuntu-latest
name: Unit Tests
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19

Expand Down Expand Up @@ -65,10 +65,10 @@ jobs:
runs-on: ubuntu-latest
name: Integration Tests
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19

Expand Down
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ linters:
- gochecknoglobals

linters-settings:
govet:
shadow:
enable: true
# report about shadowed variables
check-shadowing: true

Expand Down
8 changes: 4 additions & 4 deletions pinot/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestSendingSQLWithMockServer(t *testing.T) {
}

func TestSendingQueryWithErrorResponse(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusBadRequest)
}))
defer ts.Close()
Expand All @@ -68,7 +68,7 @@ func TestSendingQueryWithErrorResponse(t *testing.T) {
}

func TestSendingQueryWithNonJsonResponse(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, `ProcessingException`)
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestConnectionWithControllerBasedBrokerSelector(t *testing.T) {
}

func TestSendingQueryWithTraceOpen(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
var request map[string]string
err := json.NewDecoder(r.Body).Decode(&request)
assert.Equal(t, request["trace"], "true")
Expand All @@ -130,7 +130,7 @@ func TestSendingQueryWithTraceOpen(t *testing.T) {
}

func TestSendingQueryWithTraceClose(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
var request map[string]string
err := json.NewDecoder(r.Body).Decode(&request)
assert.Nil(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pinot/dynamicBrokerSelector.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *dynamicBrokerSelector) init() error {
log.Errorf("Failed to connect to zookeeper: %v\n", s.zkConfig.ZookeeperPath)
return err
}
s.readZNode = func(path string) ([]byte, error) {
s.readZNode = func(_ string) ([]byte, error) {
node, _, err2 := s.zkConn.Get(s.externalViewZkPath)
if err2 != nil {
log.Errorf("Failed to read zk: %s, ExternalView path: %s\n", s.zkConfig.ZookeeperPath, s.externalViewZkPath)
Expand Down
8 changes: 4 additions & 4 deletions pinot/dynamicBrokerSelector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestErrorExternalViewUpdate(t *testing.T) {
func TestMockReadZNode(t *testing.T) {
evBytes := []byte(`{"id":"brokerResource","simpleFields":{"BATCH_MESSAGE_MODE":"false","BUCKET_SIZE":"0","IDEAL_STATE_MODE":"CUSTOMIZED","NUM_PARTITIONS":"1","REBALANCE_MODE":"CUSTOMIZED","REPLICAS":"0","STATE_MODEL_DEF_REF":"BrokerResourceOnlineOfflineStateModel","STATE_MODEL_FACTORY_NAME":"DEFAULT"},"mapFields":{"baseballStats_OFFLINE":{"Broker_127.0.0.1_8000":"ONLINE", "Broker_127.0.0.1_9000":"ONLINE"}},"listFields":{}}`)
selector := &dynamicBrokerSelector{
readZNode: func(path string) ([]byte, error) {
readZNode: func(_ string) ([]byte, error) {
return evBytes, nil
},
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestMockReadZNode(t *testing.T) {
evBytes = []byte(`abc`)
err = selector.refreshExternalView()
assert.NotNil(t, err)
selector.readZNode = func(path string) ([]byte, error) {
selector.readZNode = func(_ string) ([]byte, error) {
return nil, fmt.Errorf("erroReadZNode")
}
err = selector.refreshExternalView()
Expand All @@ -126,7 +126,7 @@ func TestMockUpdateEvent(t *testing.T) {
evBytes := []byte(`{"id":"brokerResource","simpleFields":{"BATCH_MESSAGE_MODE":"false","BUCKET_SIZE":"0","IDEAL_STATE_MODE":"CUSTOMIZED","NUM_PARTITIONS":"1","REBALANCE_MODE":"CUSTOMIZED","REPLICAS":"0","STATE_MODEL_DEF_REF":"BrokerResourceOnlineOfflineStateModel","STATE_MODEL_FACTORY_NAME":"DEFAULT"},"mapFields":{"baseballStats_OFFLINE":{"Broker_127.0.0.1_8000":"ONLINE", "Broker_127.0.0.1_9000":"ONLINE"}},"listFields":{}}`)
ch := make(chan zk.Event)
selector := &dynamicBrokerSelector{
readZNode: func(path string) ([]byte, error) {
readZNode: func(_ string) ([]byte, error) {
return evBytes, nil
},
externalViewZnodeWatch: ch,
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestMockUpdateEvent(t *testing.T) {
evBytes = []byte(`abc`)
err = selector.refreshExternalView()
assert.NotNil(t, err)
selector.readZNode = func(path string) ([]byte, error) {
selector.readZNode = func(_ string) ([]byte, error) {
return nil, fmt.Errorf("erroReadZNode")
}
err = selector.refreshExternalView()
Expand Down

0 comments on commit 6fcbc7a

Please sign in to comment.