Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
Add linting while ignoring legacy issues for now
Browse files Browse the repository at this point in the history
Fixes #11
  • Loading branch information
javaducky committed Jul 20, 2022
1 parent 1316cc4 commit b7a5842
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Lint

on:
# Enable manually triggering this workflow via the API or web UI
workflow_dispatch:
push:
branches:
- main
tags:
- v*
pull_request:

jobs:
check-modules:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
- name: Check module dependencies
run: |
go version
test -z "$(go mod tidy && git status go.* --porcelain)"
go mod verify
run-golangci:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
# TODO up this to 1.18.x when we update teh version of golangci-lint to latest
go-version: 1.17.x
- name: Retrieve golangci-lint version
run: |
echo "::set-output name=Version::$(head -n 1 "${GITHUB_WORKSPACE}/.golangci.yml" | tr -d '# ')"
id: version
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: ${{ steps.version.outputs.Version }}
only-new-issues: true
77 changes: 77 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# v1.43.0
# Please don't remove the first line. It is used in CI to determine the golangci version
run:
deadline: 5m

issues:
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

# We want to try and improve the comments in the k6 codebase, so individual
# non-golint items from the default exclusion list will gradually be added
# to the exclude-rules below
exclude-use-default: false

exclude-rules:
# Exclude duplicate code and function length and complexity checking in test
# files (due to common repeats and long functions in test code)
- path: _(test|gen)\.go
linters:
- cyclop
- dupl
- funlen
- gocognit
- lll
- linters:
- paralleltest # false positive: https://github.com/kunwardeep/paralleltest/issues/8.
text: "does not use range value in test Run"

linters-settings:
cyclop:
max-complexity: 25
dupl:
threshold: 150
exhaustive:
default-signifies-exhaustive: true
funlen:
lines: 80
statements: 60
goconst:
min-len: 10
min-occurrences: 4
govet:
check-shadowing: true
maligned:
suggest-new: true
nolintlint:
# Disable to ensure that nolint directives don't have a leading space. Default is true.
allow-leading-space: false

linters:
enable-all: true
disable:
- exhaustivestruct
- gci
- gochecknoinits
- gocyclo # replaced by cyclop since it also calculates the package complexity
- godot
- godox
- goerr113 # most of the errors here are meant for humans
- goheader
- golint # this linter is deprecated
- gomnd
- gomodguard
- interfacer # deprecated
- ireturn
- maligned # replaced by govet 'fieldalignment'
- nlreturn
- scopelint # deprecated, replaced by exportloopref
- tagliatelle
- testpackage
- thelper
- varnamelen # disabled before the final decision in (https://github.com/grafana/k6/pull/2323)
- wrapcheck # a little bit too much for k6, maybe after https://github.com/tomarrell/wrapcheck/issues/2 is fixed
- wsl
fast: false

0 comments on commit b7a5842

Please sign in to comment.