Skip to content

Commit

Permalink
INTMDB-233: Update linter version (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai Bojin authored Aug 5, 2021
1 parent 22469a2 commit a80e62e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
40 changes: 35 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -89,10 +89,6 @@ const (
alphaNum = alphabet + numeric
)

var (
seeder = rand.New(rand.NewSource(time.Now().UnixNano()))
)

type thirdPartyConfig struct {
Name string
ProjectID string
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit a80e62e

Please sign in to comment.