Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTMDB-233: Update linter version #506

Merged
merged 3 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ linters-settings:
- octalLiteral
govet:
check-shadowing: true
golint:
revive:
min-confidence: 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min-confidence is not a valid revive setting, https://github.com/mgechev/revive#configuration

Feel free to check the cli but we have some extra rules that don't come enabled by default

https://github.com/mongodb/mongocli/blob/6ac1f831b2a7d4ae60f4a7d025e4ab3c8da50d79/.golangci.yml#L22-L53

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

maligned:
suggest-new: true
Expand Down Expand Up @@ -54,20 +54,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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is required to use the PATH on MacOS


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 @@ -243,7 +239,8 @@ func testAccCreateThirdPartyIntegrationConfig() *matlas.ThirdPartyIntegration {
func testGenString(length int, charSet string) string {
sequence := make([]byte, length)
for i := range sequence {
sequence[i] = charSet[seeder.Intn(len(charSet))]
n, _ := rand.Int(rand.Reader, big.NewInt(int64(len(charSet))))
gssbzn marked this conversation as resolved.
Show resolved Hide resolved
sequence[i] = charSet[int(n.Int64())]
}
return string(sequence)
}
Expand Down