Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
212 changes: 149 additions & 63 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,121 @@

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
# - asasalint
- asciicheck
# - bidichk
# - bodyclose
# - contextcheck
# - cyclop
# - decorder
- depguard
- dogsled
# - durationcheck
# - errcheck
# - errchkjson
# - errname
# - execinquery
# - exportloopref
# - forbidigo
# - forcetypeassert
- funlen
# - revive
- typecheck
# - dupl
# - dupword
# - errorlint
# - exhaustruct
# - gochecknoglobals
# - gochecknoinits
# - gocognit
- goconst
# - gocritic # probably should re-enable this
- gocyclo
# - godot
# - godox # disabling because we have WAY too many TODOs etc.
# - goerr113 # TODO: reenable
# - gofmt
# - gofumpt # not using this
- goheader
# - goimports
# - gomnd
# - gomoddirectives
# - gomodguard
# - goprintffuncname
# - gosec
# - gosimple
# - govet
# - grouper
# - ifshort
# - importas
# - ineffassign
# - interfacebloat
# - interfacer
# - ireturn
# - lll
# - loggercheck
# - maintidx
# - makezero
# - maligned
# - misspell
# - nakedret
# - nestif
# - nilerr
# - nilnil
# - nlreturn
# - noctx
# - nolintlint
# - nonamedreturns
# - nosnakecase
# - nosprintfhostport
# - paralleltest
# - prealloc
# - predeclared
# - promlinter
# - reassign
# - rowserrcheck
# - scopelint
# - sqlclosecheck
# - staticcheck
# - structcheck
# - stylecheck
# - tagliatelle
# - tenv
# - testableexamples
# - testpackage
# - thelper
# - tparallel
# - unconvert
# - unparam
# - unused
# - usestdlibvars
# - varcheck
# - varnamelen
# - wastedassign
# - whitespace
# - wrapcheck
# - wsl


linters-settings:
cyclop:
max-complexity: 30
skip-tests: true
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
# - github.com/sirupsen/logrus
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
# - github.com/sirupsen/logrus
packages-with-error-message:
# - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
# - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dupl:
threshold: 100
funlen:
lines: 200
lines: 250
statements: 100
goconst:
min-len: 2
Expand All @@ -33,10 +138,28 @@ linters-settings:
min-complexity: 36
gocyclo:
min-complexity: 36
godox:
# Report any comments starting with keywords, this is useful for TODO or FIXME comments that
# might be left in the code accidentally and should be resolved before merging.
# Default: ["TODO", "BUG", "FIXME"]
keywords:
- TODO
- BUG
- FIXME
gofmt:
# Simplify code: gofmt with `-s` option.
# Default: true
simplify: true
# Apply the rewrite rules to the source before reformatting.
# https://pkg.go.dev/cmd/gofmt
# Default: []
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
- pattern: 'a[b:len(a)]'
replacement: 'a[b:]'
goimports:
# local-prefixes: github.com/golangci/golangci-lint
golint:
min-confidence: 0
# local-prefixes: github.com/golangci/golangci-lint
gomnd:
settings:
mnd:
Expand All @@ -53,52 +176,18 @@ linters-settings:
suggest-new: true
misspell:
locale: US
nestif:
min-complexity: 10

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
# - dupl
- errcheck
- funlen
# - gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint
# - gomnd
- goprintffuncname
# - gosec
- gosimple
- govet
- ineffassign
- interfacer
- lll
# - misspell
- nakedret
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
# - gochecknoglobals
- gocognit
# - godox
# - maligned
- prealloc
varnamelen:
# The longest distance, in source lines, that is being considered a "small scope".
# Variables used in at most this many lines will be ignored.
# Default: 5
max-distance: 50
# The minimum length of a variable's name that is considered "long".
# Variable names that are at least this long will be ignored.
# Default: 3
min-name-length: 2

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
Expand All @@ -112,22 +201,19 @@ issues:
- dupl
- funlen

- linters:
- gosec
text: "G[202]"
text: "G[101]"


run:
skip-files:
- ".*_test.go"
- ".*rice-box.*"
modules-download-mode: vendor
# auto-generated
- ".*_test.go"




# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.31.x # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.50.1 # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"


45 changes: 16 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ REPORTS_DIR ?= reports
TEST_RESULTS ?= TEST-iofogctl.txt
TEST_REPORT ?= TEST-iofogctl.xml

# Go variables
export CGO_ENABLED ?= 0
export GOOS ?= $(OS)
export GOARCH ?= amd64
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./client/*")

.PHONY: all
all: bootstrap build install ## Bootstrap env, build and install binary

Expand All @@ -48,7 +42,7 @@ bootstrap: ## Bootstrap environment
@script/bootstrap.sh

.PHONY: build
build: GOARGS += -mod=vendor -tags "$(GOTAGS)" -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)
build: GOARGS += -tags "$(GOTAGS)" -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)
build: fmt ## Build the binary
@cd pkg/util && rice embed-go
@go build -v $(GOARGS) $(PACKAGE_DIR)/main.go
Expand All @@ -57,37 +51,30 @@ build: fmt ## Build the binary
install: ## Install the iofogctl binary to /usr/local/bin
@sudo cp $(BUILD_DIR)/$(BINARY_NAME) /usr/local/bin

.PHONY: modules
modules: ## Get modules
@for module in $(OPERATOR_MODULE) $(GO_SDK_MODULE) ; do \
go get github.com/eclipse-iofog/$$module; \
done
@go get github.com/eclipse-iofog/iofogctl@v1.3

.PHONY: get
get: export GOFLAGS=-mod=vendor
get: ## Pull modules

.PHONY: vendor
vendor: modules ## Vendor all modules
@go mod vendor
@for module in GeertJohan; do \
git checkout -- vendor/github.com/$$module; \
done

.PHONY: lint
lint: fmt ## Lint the source
@golangci-lint run --timeout 5m0s
lint: golangci-lint fmt ## Lint the source
@$(GOLANGCI_LINT) run --timeout 5m0s

golangci-lint: ## Install golangci
ifeq (, $(shell which golangci-lint))
@{ \
set -e ;\
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 ;\
}
GOLANGCI_LINT=$(GOBIN)/golangci-lint
else
GOLANGCI_LINT=$(shell which golangci-lint)
endif

.PHONY: fmt
fmt: ## Format the source
@gofmt -s -w $(GOFILES_NOVENDOR)
@gofmt -s -w .

.PHONY: test
test: ## Run unit tests
mkdir -p $(REPORTS_DIR)
rm -f $(REPORTS_DIR)/*
set -o pipefail; find ./internal ./pkg -name '*_test.go' -not -path vendor | sed -E "s|(/.*/).*_test.go|\1|g" | xargs -n1 go test -mod=vendor -ldflags "$(LDFLAGS)" -coverprofile=$(REPORTS_DIR)/coverage.txt -v -parallel 1 2>&1 | tee $(REPORTS_DIR)/$(TEST_RESULTS)
set -o pipefail; find ./internal ./pkg -name '*_test.go' -not -path vendor | sed -E "s|(/.*/).*_test.go|\1|g" | xargs -n1 go test -ldflags "$(LDFLAGS)" -coverprofile=$(REPORTS_DIR)/coverage.txt -v -parallel 1 2>&1 | tee $(REPORTS_DIR)/$(TEST_RESULTS)
cat $(REPORTS_DIR)/$(TEST_RESULTS) | go-junit-report -set-exit-code > $(REPORTS_DIR)/$(TEST_REPORT)

.PHONY: list
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/json-iterator/go v1.1.12
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/spf13/cobra v1.4.0
github.com/spf13/cobra v1.5.0
github.com/twmb/algoimpl v0.0.0-20170717182524-076353e90b94
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f
gopkg.in/yaml.v2 v2.4.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,9 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down
Loading