diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..d096a453 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,27 @@ +run: + timeout: 3m +linters-settings: + gocritic: + enabled-checks: + - captLocal + - dupImport + - singleCaseSwitch + disabled-checks: + - appendAssign + enabled-tags: + - diagnostic + disabled-tags: + - performance + - style + - experimental + - opinionated +linters: + disable-all: true + enable: + - gocritic + - gosimple + - errcheck + - govet + - unused + - goconst + - godot diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 91884a80..50ca83f9 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -101,7 +101,7 @@ blocks: commands: - cd users - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Users commands: - cd users @@ -135,7 +135,7 @@ blocks: commands: - cd things - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Things commands: - cd things @@ -169,7 +169,7 @@ blocks: commands: - cd coap - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test CoAP commands: - cd coap @@ -203,7 +203,7 @@ blocks: commands: - cd http - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test HTTP commands: - cd http @@ -238,7 +238,7 @@ blocks: commands: - cd mqtt - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test MQTT commands: - cd mqtt @@ -273,7 +273,7 @@ blocks: commands: - cd ws - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test WS commands: - cd ws @@ -308,7 +308,7 @@ blocks: commands: - cd bootstrap - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Bootstrap commands: - cd bootstrap @@ -343,7 +343,7 @@ blocks: commands: - cd certs - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Certs commands: - cd certs @@ -378,7 +378,7 @@ blocks: commands: - cd provision - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Provision commands: - cd provision @@ -413,7 +413,7 @@ blocks: commands: - cd twins - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Twins commands: - cd twins @@ -448,7 +448,7 @@ blocks: commands: - cd readers - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Twins commands: - cd readers @@ -487,7 +487,7 @@ blocks: commands: - cd consumers - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Consumers commands: - cd consumers @@ -527,7 +527,7 @@ blocks: commands: - cd cli - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test CLI commands: - cd cli @@ -562,7 +562,7 @@ blocks: commands: - cd lora - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test LoRa commands: - cd lora @@ -597,7 +597,7 @@ blocks: commands: - cd opcua - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test OPC-UA commands: - cd opcua @@ -632,7 +632,7 @@ blocks: commands: - cd internal - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Internal commands: - cd internal @@ -652,7 +652,7 @@ blocks: commands: - cd logger - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Logger commands: - cd logger @@ -672,7 +672,7 @@ blocks: commands: - cd pkg - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test PKG commands: - cd pkg @@ -692,7 +692,7 @@ blocks: commands: - cd tools - cache restore linter - - './bin/golangci-lint run --no-config --disable-all --enable gosimple,errcheck,govet,unused,goconst,godot --timeout 3m' + - './bin/golangci-lint run' - name: Test Tools commands: - cd tools diff --git a/bootstrap/api/transport.go b/bootstrap/api/transport.go index 27d4f22b..a2643865 100644 --- a/bootstrap/api/transport.go +++ b/bootstrap/api/transport.go @@ -276,8 +276,7 @@ func encodeError(_ context.Context, err error, w http.ResponseWriter) { errors.Contains(err, apiutil.ErrBootstrapState), errors.Contains(err, apiutil.ErrLimitSize): w.WriteHeader(http.StatusBadRequest) - case errors.Contains(err, errors.ErrNotFound), - errors.Contains(err, bootstrap.ErrThings): + case errors.Contains(err, errors.ErrNotFound): w.WriteHeader(http.StatusNotFound) case errors.Contains(err, bootstrap.ErrExternalKey), errors.Contains(err, bootstrap.ErrExternalKeySecure), diff --git a/scripts/ci.sh b/scripts/ci.sh index 6b03905c..69be59a7 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -73,7 +73,6 @@ setup_mf() { setup_lint() { # binary will be $(go env GOBIN)/golangci-lint curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOBIN) $GOLANGCI_LINT_VERSION - } setup() { @@ -86,7 +85,7 @@ setup() { run_test() { echo "Running lint..." - golangci-lint run --no-config --disable-all --enable gosimple --enable errcheck --enable govet --enable unused --enable goconst --enable godot --timeout 3m + golangci-lint run echo "Running tests..." echo "" > coverage.txt for d in $(go list ./... | grep -v 'vendor\|cmd'); do