Skip to content

Commit

Permalink
GH-15: Enable linter (#92)
Browse files Browse the repository at this point in the history
Fix GH-15

Related parts:
* https://github.com/apache/arrow/blob/58415d1fac50cb829b3dcf08526033d6db8c30db/.pre-commit-config.yaml#L151-L164
* https://github.com/apache/arrow/blob/main/.golangci.yaml

staticcheck is also used via golangci. We need to use
"nolint:staticcheck,XXX" instead of "lint:ignore XXX" for it.

See also: https://golangci-lint.run/usage/false-positives/#nolint
  • Loading branch information
kou authored Sep 7, 2024
1 parent dde8c4e commit 7550e50
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 16 deletions.
2 changes: 0 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@

# All of the following environment variables are required to set default values
# for the parameters in docker-compose.yml.

STATICCHECK=v0.5.1
4 changes: 0 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ jobs:
- name: Install bash via Homebrew
run: |
brew install bash
- name: Install staticcheck
run: |
. .env
go install honnef.co/go/tools/cmd/staticcheck@${STATICCHECK}
- name: Build
run: |
$(brew --prefix)/bin/bash ci/scripts/build.sh $(pwd)
Expand Down
30 changes: 30 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

linters:
# Disable all linters.
# Default: false
disable-all: true
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- gofmt
- goimports
- staticcheck

issues:
fix: true
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,17 @@ repos:
# The default args is "--write --simplify" but we don't use
# "--simplify". Because it's conflicted will ShellCheck.
- "--write"
- repo: https://github.com/golangci/golangci-lint
rev: v1.60.3
hooks:
# no built-in support for multiple go.mod
# https://github.com/golangci/golangci-lint/issues/828
- id: golangci-lint-full
name: golangci-lint-full-arrow
entry: bash -c 'cd arrow && golangci-lint run --timeout=5m'
- id: golangci-lint-full
name: golangci-lint-full-parquet
entry: bash -c 'cd parquet && golangci-lint run'
- id: golangci-lint-full
name: golangci-lint-full-internal
entry: bash -c 'cd internal && golangci-lint run'
4 changes: 2 additions & 2 deletions arrow/flight/flightsql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1177,9 +1177,9 @@ func (f *flightSqlServer) DoAction(cmd *flight.Action, stream flight.FlightServi
}

var (
//lint:ignore SA1019 for backward compatibility
//nolint:staticcheck,SA1019 for backward compatibility
request pb.ActionCancelQueryRequest
//lint:ignore SA1019 for backward compatibility
//nolint:staticcheck,SA1019 for backward compatibility
result pb.ActionCancelQueryResult
info flight.FlightInfo
err error
Expand Down
2 changes: 1 addition & 1 deletion arrow/internal/flight_integration/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@ func (m *flightSqlExtensionScenarioTester) ValidateStatementExecution(client *fl
return err
}

//lint:ignore SA1019 for backward compatibility
//nolint:staticcheck,SA1019 for backward compatibility
cancelResult, err := client.CancelQuery(ctx, info)
if err != nil {
return err
Expand Down
7 changes: 0 additions & 7 deletions ci/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ MINGW*)
;;
esac

# Go static check (skipped in MinGW)
if [[ -z "${MINGW_LINT:-}" ]]; then
pushd "${source_dir}"
"$(go env GOPATH)"/bin/staticcheck ./...
popd
fi

pushd "${source_dir}/arrow"

: "${ARROW_GO_TESTCGO:=}"
Expand Down

0 comments on commit 7550e50

Please sign in to comment.