diff --git a/.golangci.yml b/.golangci.yml index 4d21a53b57..22845ca352 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,8 +10,39 @@ linters-settings: - octalLiteral govet: check-shadowing: true - golint: - min-confidence: 0 + revive: + # see https://github.com/mgechev/revive#available-rules for details. + ignore-generated-header: true + severity: warning + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: errorf + - name: exported + - name: indent-error-flow + - name: if-return + - name: increment-decrement + - name: var-naming + - name: var-declaration + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: empty-block + - name: superfluous-else + - name: struct-tag + # Too many unusued parameters, skipping this check for now + #- name: unused-parameter + - name: unreachable-code + - name: redefines-builtin-id maligned: suggest-new: true depguard: @@ -54,20 +85,19 @@ linters: - gocritic - gofmt - goimports - - golint + - revive - gomnd - goprintffuncname - gosec - gosimple - govet - ineffassign - - interfacer - lll - misspell - nakedret - nolintlint - rowserrcheck - - scopelint + - exportloopref - staticcheck - structcheck - stylecheck diff --git a/GNUmakefile b/GNUmakefile index 693000fff5..a8b1f0db2c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -11,9 +11,10 @@ GITTAG=$(shell git describe --always --tags) VERSION=$(GITTAG:v%=%) LINKER_FLAGS=-s -w -X 'github.com/mongodb/terraform-provider-mongodbatlas/version.ProviderVersion=${VERSION}' -GOLANGCI_VERSION=v1.29.0 +GOLANGCI_VERSION=v1.41.1 -export PATH := ./bin:$(PATH) +export PATH := $(shell go env GOPATH)/bin:$(PATH) +export SHELL := env PATH=$(PATH) /bin/bash default: build @@ -42,12 +43,12 @@ websitefmtcheck: lint: @echo "==> Checking source code against linters..." # https://github.com/golangci/golangci-lint/issues/337 fixing error - bin/golangci-lint run ./$(PKG_NAME) -v --deadline=30m + golangci-lint run ./$(PKG_NAME) -v --deadline=30m tools: ## Install dev tools @echo "==> Installing dependencies..." GO111MODULE=on go install github.com/client9/misspell/cmd/misspell - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_VERSION) + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin $(GOLANGCI_VERSION) check: test lint diff --git a/mongodbatlas/data_source_mongodbatlas_third_party_integration_test.go b/mongodbatlas/data_source_mongodbatlas_third_party_integration_test.go index 026d4d3f61..325452194e 100644 --- a/mongodbatlas/data_source_mongodbatlas_third_party_integration_test.go +++ b/mongodbatlas/data_source_mongodbatlas_third_party_integration_test.go @@ -3,11 +3,11 @@ package mongodbatlas import ( "context" "fmt" + "math/big" "os" "testing" - "math/rand" - "time" + "crypto/rand" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -89,10 +89,6 @@ const ( alphaNum = alphabet + numeric ) -var ( - seeder = rand.New(rand.NewSource(time.Now().UnixNano())) -) - type thirdPartyConfig struct { Name string ProjectID string @@ -242,8 +238,10 @@ func testAccCreateThirdPartyIntegrationConfig() *matlas.ThirdPartyIntegration { func testGenString(length int, charSet string) string { sequence := make([]byte, length) + upperBound := big.NewInt(int64(len(charSet))) for i := range sequence { - sequence[i] = charSet[seeder.Intn(len(charSet))] + n, _ := rand.Int(rand.Reader, upperBound) + sequence[i] = charSet[int(n.Int64())] } return string(sequence) }