Skip to content

Commit

Permalink
Merge pull request #26 from Clarilab/v3
Browse files Browse the repository at this point in the history
V3
  • Loading branch information
nicoandrewss authored Jun 18, 2024
2 parents 4bb2de9 + 05eb810 commit b32c49a
Show file tree
Hide file tree
Showing 13 changed files with 831 additions and 455 deletions.
30 changes: 5 additions & 25 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,8 @@ on:
workflow_dispatch:

jobs:

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '>=1.21.0'

- name: Vet
run: go vet ./...

- name: Test
run: go test -short -v ./...

govulncheck:
runs-on: ubuntu-latest
name: Run govulncheck
steps:
- id: govulncheck
uses: golang/govulncheck-action@v1
with:
go-package: ./...
go-backend-workflow:
uses: Clarilab/workflows/.github/workflows/go-backend.yaml@main
with:
work_dir: .
go_version: ">=1.22.4"
326 changes: 326 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
linters:
enable-all: true
disable:
- contextcheck # Check whether the function uses a non-inherited context aka context.Background()
- depguard # not needed, does the same as gomodguard
- execinquery # sql linter, no need
- exhaustruct # very annoying, checks if all struct fields are filled
- ginkgolinter # not used libs
- godot # very noisy, don't see the need
- goheader # unused
- gosmopolitan # unnecessary i18n linter
- lll # should be disabled in CI, as this is a cosmetic only and is really shitty on struct fields
- misspell # will sometimes wrongly correct german strings ("Identifikation" -> "Identification", or "Nationalität" -> "Nationalistät", wtf)
- nakedret # no need
- rowserrcheck # disabled because sql
- sqlclosecheck # disabled because of generics
- tagliatelle # no need
- tparallel # does the same as paralleltest
- ireturn # noisy for libs
- interfacebloat # noisy for libs
- varnamelen # very noisy

linters-settings:
cyclop:
max-complexity: 20
package-average: 10.0
skip-tests: true

dupl:
threshold: 250

errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions: true
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
# Such cases aren't reported by default.
# Default: false
check-blank: true

errchkjson:
report-no-exported: true

exhaustive:
default-signifies-exhaustive: true

forbidigo:
forbid:
- ^(fmt\.Print(|f|ln)|print|println)$
- 'http\.Default(Client|Transport)'

funlen:
lines: 100 # default 60
statements: 40

gocognit:
min-complexity: 20

goconst:
min-occurences: 3

gocyclo:
min-complexity: 20

godot:
exclude:
- "^fixme:"
- "^todo:"

gofmt:
simplify: false # we use gofumpt for simplification
rewrite-rules:
- pattern: "interface{}"
replacement: "any"
- pattern: "a[b:len(a)]"
replacement: "a[b:]"
- pattern: "a[0:b]"
replacement: "a[:b]"

gofumpt:
extra-rules: true

mnd:
# List of function patterns to exclude from analysis.
# Values always ignored: `time.Date`,
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
# `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`.
# Default: []
ignored-functions:
- os.Chmod
- os.Mkdir
- os.MkdirAll
- os.OpenFile
- os.WriteFile
- prometheus.ExponentialBuckets
- prometheus.ExponentialBucketsRange
- prometheus.LinearBuckets

gomodguard:
blocked:
modules:
- github.com/golang/protobuf:
recommendations:
- google.golang.org/protobuf
reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules"
- github.com/satori/go.uuid:
recommendations:
- github.com/google/uuid
reason: "we only want to use the google uuid lib for consistency"
- github.com/gofrs/uuid:
recommendations:
- github.com/google/uuid
reason: "we only want to use the google uuid lib for consistency"
- github.com/twinj/uuid:
recommendations:
- github.com/google/uuid
reason: "we only want to use the google uuid lib for consistency"
- github.com/Clarilab/slacklogger:
recommendations:
- github.com/Clarilab/slacklogger/v2
reason: "we want to update this dependency"
# disabled for now as we are not sure how to deal with this yet
# - github.com/pkg/errors:
# recommendations:
# - stdlib
# reason: 'standard lib provides this functionality, aka fmt.Errorf(...)'
version:
- github.com/savsgio/atreugo/v11:
version: ">11.9.9"
reason: "introduced breaking changes"

govet:
enable-all: true
disable: # those are pretty noisy for no real benefit
- shadow
- fieldalignment
- loopclosure

grouper:
import-require-single-import: true

lll:
line-length: 160

nolintlint:
allow-no-explanation: [funlen, lll, wrapcheck]
require-explanation: true
require-specific: true

nonamedreturns:
report-error-in-defer: true

paralleltest:
ignore-missing: true # with this setting it will only point out incorrect usage of t.Parallel()

predeclared:
q: true

revive:
enable-all-rules: true
rules:
# Provided by mnd linter
- name: add-constant
disabled: true
- name: argument-limit
disabled: true
# Provided by bidichk
- name: banned-characters
disabled: true
- name: bare-return
disabled: true
- name: cognitive-complexity
disabled: true
- name: confusing-results
disabled: true
- name: cyclomatic
disabled: true
- name: early-return
severity: warning
disabled: true
- name: exported
disabled: true
- name: file-header
disabled: true
- name: function-result-limit
disabled: true
- name: function-length
disabled: true
- name: line-length-limit
disabled: true
- name: max-public-structs
disabled: true
- name: modifies-parameter
disabled: true
- name: nested-structs
disabled: true
- name: package-comments
disabled: true
- name: unhandled-error
disabled: true
- name: unused-receiver
disabled: true

stylecheck:
checks:
- all
- -ST1000
- -ST1020
- -ST1021
- -ST1022

tagalign:
align: false
order:
- json
- bson
- validate

varnamelen:
min-name-length: 2
ignore-names:
- "i" # loop variable
- "j" # loop variable
- "k" # loop variable
ignore-decls:
- c echo.Context
- t testing.T
- T any
- m map[string]int

wrapcheck:
# An array of strings that specify globs of packages to ignore.
# Default: []
ignorePackageGlobs:
- github.com/savsgio/atreugo/*

wsl:
# Allow declarations (var) to be cuddled.
allow-cuddle-declarations: true

issues:
fix: true
# 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
exclude-rules:
- source: "^//\\s*go:generate\\s"
linters:
# restrict autofix linters on generated files
- dupword
- godot
- gofmt
- gofumpt
- goimports
- misspell
- tagalign
- whitespace
- lll
- source: "(noinspection|TODO)"
linters:
- godot
- source: "//noinspection"
linters:
- gocritic
- source: "jsoniter"
linters:
- gochecknoglobals
- path: "_test\\.go"
linters:
- bodyclose
- gochecknoglobals
- containedctx
- cyclop
- dupl
- errcheck
- forbidigo
- funlen
- goconst
- gocyclo
- gosec
- nlreturn
- noctx
- varnamelen
- wrapcheck

output:
sort-results: true

run:
exclude-dirs:
- cmd
- config
# tests: false
timeout: 3m

severity:
default-severity: warning
rules:
- linters:
- asciicheck
- bidichk
- containedctx
- durationcheck
- errchkjson
- errorlint
- exportloopref
- gocheckcompilerdirectives
- gochecknoinits
- goerr113
- ineffassign
- loggercheck
- makezero
- unused
- unparam
severity: error
- linters:
- dupword
- gci
- goconst
- godot
- gofmt
- goimports
- nakedret
severity: info
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ This client is a wrapper around [minio-go](https://github.com/minio/minio-go).

## Installation
```shell
go get github.com/Clarilab/s3-client/v2
go get github.com/Clarilab/s3-client/v3
```

## Importing
```go
import "github.com/Clarilab/s3-client/v2"
import "github.com/Clarilab/s3-client/v3"
```

## Features
Expand Down
Loading

0 comments on commit b32c49a

Please sign in to comment.