Skip to content

Commit

Permalink
Ad golangci lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tobischo committed Mar 4, 2024
1 parent 3e42845 commit cebace1
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: golangci-lint
on:
push:
branches:
- master
- main
pull_request:

permissions:
contents: read
pull-requests: read
checks: write

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.56

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
81 changes: 81 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
run:
timeout: 5m

linters-settings:
errcheck:
check-type-assertions: true

funlen:
lines: 100
statements: 50

gci:
sections:
- standard # Standard section: captures all standard packages.
- prefix(github.com/tobischo/gokeepasslib) # Custom section: groups all imports with the specified Prefix.
- default # Default section: contains all imports that could not be matched to another section type.

skip-generated: false
custom-order: true

gocognit:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 10

gomnd:
ignored-functions:
- os.Chmod
- os.Mkdir
- os.MkdirAll
- os.OpenFile
- os.WriteFile

govet:
settings:
shadow:
strict: true
enable-all: true

nakedret:
max-func-lines: 0 # Do not use naked returns

lll:
line-length: 100
tab-width: 2

godot:
period: false

linters:
enable-all: true
disable:
- depguard
- goddox
- nlreturn
- paralleltest
- tagliatelle
- thelper
- wsl
- forbidigo
- varnamelen
- exhaustruct
- errname
- gochecknoglobals
- testpackage
- funlen
- cyclop
- gofumpt
- deadcode
- exhaustrivestruct
- golangci-lintifshort
- interfacer
- maligned
- nosnakecase
- scopelint
- structcheck
- varcheck

issues:
max-ame-issues: 50

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tobischo/gokeepasslib/v3

go 1.21.6
go 1.22.0

require (
github.com/google/go-cmp v0.6.0
Expand Down

0 comments on commit cebace1

Please sign in to comment.