Skip to content

Commit

Permalink
add local linter settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gen2thomas committed May 18, 2023
1 parent f930926 commit af7ae57
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
- v*
branches:
- dev
- release
pull_request:
permissions:
contents: read
Expand Down Expand Up @@ -44,4 +43,4 @@ jobs:
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
# skip-build-cache: true
43 changes: 43 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
run:
# Timeout for analysis, e.g. 30s, 5m.
# gobot is very expensive, on a machine with heavy load it takes some minutes
# for first run or after empty the cache by 'golangci-lint cache clean'
# Default: 1m
timeout: 5m

# If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
#
# Allowed values: readonly|vendor|mod
# By default, it isn't set.
modules-download-mode: readonly

# Enables skipping of directories:
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
# Default: true
skip-dirs-use-default: false

# note: examples will be currently omitted by the build tag
skip-dirs:
- platforms/opencv/

linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
# note: typecheck can not be disabled, it is used to check code compilation
#
# TODO: this default linters needs to be disabled to run successfully, we have to fix
# all issues step by step to enable at least the default linters
disable:
- errcheck
- gosimple
#- govet
- ineffassign
- staticcheck
- unused
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
ALL_EXAMPLES := $(shell grep -l -r --include "*.go" 'build example' ./)
# prevent examples with gocv (opencv) dependencies
EXAMPLES_NO_GOCV := $(shell grep -L 'gocv' $(ALL_EXAMPLES))
# prevent examples with joystick (sdl2) dependencies
EXAMPLES_NO_JOYSTICK := $(shell grep -L 'joystick' $(ALL_EXAMPLES))
# prevent examples with joystick (sdl2) and gocv (opencv) dependencies
EXAMPLES_NO_GOCV_JOYSTICK := $(shell grep -L 'joystick' $$(grep -L 'gocv' $(EXAMPLES_NO_GOCV)))
# used examples
EXAMPLES := $(EXAMPLES_NO_GOCV)
EXAMPLES := $(EXAMPLES_NO_GOCV_JOYSTICK)

.PHONY: test test_race test_cover robeaux version_check fmt_check fmt_fix examples examples_check $(EXAMPLES)

Expand Down Expand Up @@ -54,8 +56,8 @@ version_check:

# Check for bad code style and other issues
fmt_check:
gofmt -l ./
go vet ./...
gofmt -l ./
golangci-lint run -v

# Fix bad code style (will only be executed, on version match)
fmt_fix: version_check
Expand Down

0 comments on commit af7ae57

Please sign in to comment.