Skip to content

Commit c465164

Browse files
committed
fix: fix golangci lint and travis
1 parent 70b45e3 commit c465164

File tree

6 files changed

+32
-35
lines changed

6 files changed

+32
-35
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ issues:
9898
- testpackage
9999
# part of the golangci govet package is picking up things that go vet doesn't. Seems flaky, shutting that specific error off
100100

101-
# Exclude some staticcheck messages
101+
# Exclude some staticcheck messages
102102
- linters:
103103
- staticcheck
104104
text: "SA1019:" # d.GetOkExists is deprecated: usage is discouraged due to undefined behaviors and may be removed in a future version of the SDK

.travis.yml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
1-
dist: xenial
2-
sudo: required
3-
services:
4-
- docker
51
language: go
62

7-
env:
8-
global:
9-
GOFLAGS=-mod=vendor
10-
GOGC=10
11-
GOOPTS="-p 2"
3+
go:
4+
- 1.14.x
5+
- tip
6+
127
matrix:
138
fast_finish: true
149
allow_failures:
1510
- go: tip
1611
include:
17-
- go: "1.14.x"
18-
name: "Code Lint"
19-
script: make lint
20-
- go: "1.14.x"
21-
name: "Code UnitTest"
22-
script: make test
23-
- go: "1.14.x"
24-
name: "Website"
25-
script:
26-
#- make website-test #commented until Terraform Provider Program Validation
27-
- make website-lint
28-
29-
install:
30-
- make tools
12+
- name: "Code Lint"
13+
before_install: make tools
14+
script: make lint
15+
- name: "Website"
16+
before_install: make tools
17+
script:
18+
#- make website-test #commented until Terraform Provider Program Validation
19+
- make website-lint
20+
script: make test

GNUmakefile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
33
PKG_NAME=mongodbatlas
44
WEBSITE_REPO=github.com/hashicorp/terraform-website
55

6+
GOFLAGS=-mod=vendor
7+
GOGC=10
8+
GOOPTS="-p 2"
9+
10+
GOLANGCI_VERSION=v1.29.0
11+
12+
export PATH := ./bin:$(PATH)
13+
614
default: build
715

816
build: fmtcheck
917
go install
1018

11-
1219
test: fmtcheck
1320
go test $(TEST) -timeout=30s -parallel=4
1421

@@ -29,12 +36,14 @@ websitefmtcheck:
2936

3037
lint:
3138
@echo "==> Checking source code against linters..."
32-
# https://github.com/golangci/golangci-lint/issues/337 fixing error
33-
golangci-lint run ./$(PKG_NAME) -v --deadline=30m
39+
golangci-lint run ./$(PKG_NAME)
3440

35-
tools:
41+
tools: ## Install dev tools
42+
@echo "==> Installing dependencies..."
3643
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
37-
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
44+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_VERSION)
45+
46+
check: test lint
3847

3948
test-compile:
4049
@if [ "$(TEST)" = "./..." ]; then \
@@ -62,4 +71,4 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
6271
endif
6372
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
6473

65-
.PHONY: build test testacc fmt fmtcheck lint tools test-compile website website-lint website-test
74+
.PHONY: build test testacc fmt fmtcheck lint check tools test-compile website website-lint website-test

mongodbatlas/resource_mongodbatlas_cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ func flattenBiConnector(biConnector *matlas.BiConnector) map[string]interface{}
10171017
}
10181018

10191019
func getInstanceSizeToInt(instanceSize string) int {
1020-
regex := regexp.MustCompile("[0-9]+")
1020+
regex := regexp.MustCompile(`\d+`)
10211021
num := regex.FindString(instanceSize)
10221022

10231023
return cast.ToInt(num) // if the string is empty it always return 0

mongodbatlas/resource_mongodbatlas_custom_db_role.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func resourceMongoDBAtlasCustomDBRole() *schema.Resource {
3737
Required: true,
3838
ForceNew: true,
3939
ValidateFunc: validation.All(
40-
validation.StringMatch(regexp.MustCompile(`[\w\d-]+`), "`role_name` can contain only letters, digits, underscores, and dashes"),
40+
validation.StringMatch(regexp.MustCompile(`[\w-]+`), "`role_name` can contain only letters, digits, underscores, and dashes"),
4141
func(v interface{}, k string) (ws []string, es []error) {
4242
value := v.(string)
4343
if strings.HasPrefix(value, "x-gen") {

tools.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@
33
package main
44

55
import (
6-
_ "github.com/client9/misspell/cmd/misspell"
7-
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
8-
)
6+
_ "github.com/client9/misspell/cmd/misspell")

0 commit comments

Comments
 (0)