-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable golangci-lint and specify the Go version in a .go-version file.
- Loading branch information
1 parent
5b1e227
commit 8694db5
Showing
4 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: golangci-lint | ||
on: | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Read .go-version file | ||
id: goversion | ||
run: echo "::set-output name=version::$(cat .go-version)" | ||
|
||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: "${{ steps.goversion.outputs.version }}" | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.44.2 | ||
args: --timeout=5m | ||
|
||
# Ignore pre-existing issues. | ||
only-new-issues: true | ||
|
||
# Use the Go version specified in .go-version for consistency. | ||
skip-go-installation: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.17.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
|
||
run: | ||
issues-exit-code: 1 | ||
modules-download-mode: readonly | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- deadcode | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unused | ||
- varcheck | ||
- depguard | ||
- errorlint | ||
- gofumpt | ||
- goimports | ||
- godox | ||
- goheader | ||
- ifshort | ||
- misspell | ||
- prealloc | ||
- unconvert | ||
- revive | ||
fast: false | ||
|
||
linters-settings: | ||
goimports: | ||
local-prefixes: github.com/elastic/go-libaudit | ||
gofumpt: | ||
extra-rules: true | ||
goheader: | ||
# Use https://github.com/elastic/go-licenser to automatically add headers. | ||
template: |- | ||
Licensed to Elasticsearch B.V. under one or more contributor | ||
license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright | ||
ownership. Elasticsearch B.V. 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. | ||
revive: | ||
enable-all-rules: false | ||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md | ||
rules: | ||
- name: bare-return | ||
- name: call-to-gc | ||
- name: confusing-results | ||
- name: constant-logical-expr | ||
- name: context-as-argument | ||
- name: deep-exit | ||
- name: defer | ||
- name: duplicated-imports | ||
- name: early-return | ||
- name: empty-block | ||
- name: error-strings | ||
- name: errorf | ||
- name: exported | ||
arguments: | ||
- checkPrivateReceivers | ||
- name: imports-blacklist | ||
arguments: | ||
- github.com/pkg/errors | ||
- name: increment-decrement | ||
- name: range | ||
- name: range-val-address | ||
- name: range-val-in-closure | ||
- name: receiver-naming | ||
- name: struct-tag | ||
- name: time-naming | ||
- name: unconditional-recursion | ||
- name: unexported-naming | ||
- name: unexported-return | ||
- name: unnecessary-stmt | ||
- name: unreachable-code | ||
- name: unused-parameter | ||
- name: unused-receiver | ||
- name: var-declaration | ||
- name: waitgroup-by-value | ||
stylecheck: | ||
checks: | ||
- all | ||
|
||
issues: | ||
include: | ||
# If you're going to write a comment follow the conventions. | ||
# https://go.dev/doc/effective_go#commentary. | ||
# comment on exported (.+) should be of the form "(.+)..." | ||
- EXC0014 |