Skip to content

Commit cafc90a

Browse files
committed
Fixes #602 - Use https://staticcheck.io/ for linting
* previous solution, golangci-lint, does no longer seem to be actively maintained * staticcheck is natively integrated with VSCode IDE * it's easier to have one common and modern linting framework
1 parent 959cb7b commit cafc90a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+156
-197
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RUN \
5252
&& go get gotest.tools/gotestsum \
5353
# --> Go symbols and outline for go to symbol support and test support
5454
&& go get github.com/acroca/[email protected] && go get github.com/ramya-rao-a/go-outline@7182a932836a71948db4a81991a494751eccfe77 \
55-
# --> GolangCI-lint
56-
&& go get github.com/golangci/golangci-lint/cmd/[email protected] \
55+
# --> Static checker
56+
&& go install honnef.co/go/tools/cmd/staticcheck@latest \
5757

5858
USER developer

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
3838
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
3939
go get gotest.tools/gotestsum
40-
go get github.com/golangci/golangci-lint/cmd/[email protected]
40+
go install honnef.co/go/tools/cmd/staticcheck@latest
4141
4242
- name: Pull external libraries
4343
run: make vendor

.github/workflows/release.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ jobs:
2020
uses: actions/setup-go@v1
2121
with:
2222
go-version: 1.13.x
23-
- name: Download gotestsum and golangci
23+
- name: Download gotestsum and staticcheck
2424
run: |
25-
# Install
26-
curl -sSL "https://github.com/gotestyourself/gotestsum/releases/download/v0.4.2/gotestsum_0.4.2_linux_amd64.tar.gz" | sudo tar -xz -C /usr/local/bin gotestsum
27-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.25.0
25+
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
26+
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
27+
go get gotest.tools/gotestsum
28+
go install honnef.co/go/tools/cmd/staticcheck@latest
2829
- name: Import GPG key
2930
id: import_gpg
3031
uses: crazy-max/ghaction-import-gpg@v2

.golangci.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.goreleaser.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# This is an example goreleaser.yaml file with some sane defaults.
2-
# Make sure to check the documentation at http://goreleaser.com
31
before:
42
hooks:
5-
# You may remove this if you don't use go modules.
63
- go mod download
74
builds:
85
- env:

CONTRIBUTING.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,16 @@ Most likely, `terraform init -upgrade -verify-plugins=false -lock=false` would b
4141

4242
## Developing provider
4343

44-
After installing necessary software for building provider from sources, you should install `golangci-lint` and `gotestsum` in order to run `make test`.
44+
After installing necessary software for building provider from sources, you should install `staticcheck` and `gotestsum` in order to run `make test`.
4545

4646
Make sure you have `$GOPATH/bin` in your `$PATH`:
4747
```
4848
echo "export PATH=\$PATH:$(go env GOPATH)/bin" >> ~/.bash_profile
4949
```
5050

51-
Installing `golangci-lint`:
51+
Installing `staticcheck`:
5252
```bash
53-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
54-
$(go env GOPATH)/bin/golangci-lint
53+
go install honnef.co/go/tools/cmd/staticcheck@latest
5554
```
5655

5756
Installing `gotestsum`:
@@ -298,7 +297,7 @@ func TestPreviewAccPipelineResource_CreatePipeline(t *testing.T) {
298297

299298
## Linting
300299

301-
Please use makefile for linting. If you run `golangci-lint` by itself it will fail due to different tags containing same functions.
300+
Please use makefile for linting. If you run `staticcheck` by itself it will fail due to different tags containing same functions.
302301
So please run `make lint` instead.
303302

304303
## Unit testing resources

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ fmt:
77
@gofmt -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
88

99
lint: vendor
10-
@echo "✓ Linting source code with golangci-lint make sure you run make fmt ..."
11-
@golangci-lint run --skip-dirs-use-default --timeout 5m
10+
@echo "✓ Linting source code with https://staticcheck.io/ ..."
11+
@staticcheck ./...
1212

1313
test: lint
1414
@echo "✓ Running tests ..."

access/resource_permissions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (a PermissionsAPI) put(objectID string, objectACL AccessControlChangeList)
140140

141141
// Update updates object permissions. Technically, it's using method named SetOrDelete, but here we do more
142142
func (a PermissionsAPI) Update(objectID string, objectACL AccessControlChangeList) error {
143-
if "/authorization/tokens" == objectID {
143+
if objectID == "/authorization/tokens" {
144144
// Cannot remove admins's CAN_MANAGE permission on tokens
145145
objectACL.AccessControlList = append(objectACL.AccessControlList, AccessControlChange{
146146
GroupName: "admins",
@@ -279,7 +279,7 @@ func (oa *ObjectACL) ToPermissionsEntity(ctx context.Context, d *schema.Resource
279279
}
280280
return entity, nil
281281
}
282-
return entity, fmt.Errorf("Unknown object type %s", oa.ObjectType)
282+
return entity, fmt.Errorf("unknown object type %s", oa.ObjectType)
283283
}
284284

285285
// ResourcePermissions definition
@@ -304,7 +304,7 @@ func ResourcePermissions() *schema.Resource {
304304
"access_control", "group_name"); err == nil {
305305
groupNameSchema.ValidateDiagFunc = func(i interface{}, p cty.Path) diag.Diagnostics {
306306
if v, ok := i.(string); ok {
307-
if "admins" == strings.ToLower(v) {
307+
if strings.ToLower(v) == "admins" {
308308
return diag.Diagnostics{
309309
{
310310
Summary: "It is not possible to restrict any permissions from `admins`.",

access/resource_permissions_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func TestResourcePermissionsCreate_no_access_control(t *testing.T) {
319319
State: map[string]interface{}{
320320
"cluster_id": "abc",
321321
},
322-
}.ExpectError(t, "Invalid config supplied. [access_control] Missing required argument")
322+
}.ExpectError(t, "invalid config supplied. [access_control] Missing required argument")
323323
}
324324

325325
func TestResourcePermissionsCreate_conflicting_fields(t *testing.T) {
@@ -338,7 +338,7 @@ func TestResourcePermissionsCreate_conflicting_fields(t *testing.T) {
338338
},
339339
},
340340
}.Apply(t)
341-
qa.AssertErrorStartsWith(t, err, "Invalid config supplied. cluster_id: conflicts with notebook_path. notebook_path: conflicts with cluster_id")
341+
qa.AssertErrorStartsWith(t, err, "invalid config supplied. cluster_id: conflicts with notebook_path. notebook_path: conflicts with cluster_id")
342342
}
343343

344344
func TestResourcePermissionsCreate_AdminsThrowError(t *testing.T) {
@@ -354,7 +354,7 @@ func TestResourcePermissionsCreate_AdminsThrowError(t *testing.T) {
354354
}
355355
`,
356356
}.Apply(t)
357-
assert.EqualError(t, err, "Invalid config supplied. [access_control] "+
357+
assert.EqualError(t, err, "invalid config supplied. [access_control] "+
358358
"It is not possible to restrict any permissions from `admins`.")
359359
}
360360

@@ -716,7 +716,7 @@ func TestResourcePermissionsUpdate(t *testing.T) {
716716
func permissionsTestHelper(t *testing.T,
717717
cb func(permissionsAPI PermissionsAPI, user, group string,
718718
ef func(string) PermissionsEntity)) {
719-
if "" == os.Getenv("CLOUD_ENV") {
719+
if os.Getenv("CLOUD_ENV") == "" {
720720
t.Skip("Acceptance tests skipped unless env 'CLOUD_ENV' is set")
721721
}
722722
randomName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

access/resource_secret_scope.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ func (a SecretScopesAPI) Create(s SecretScope) error {
6363
return err
6464
}
6565
if !a.client.IsAzure() {
66+
//lint:ignore ST1005 Azure is a valid capitalized string
6667
return fmt.Errorf("Azure KeyVault is not available")
6768
}
6869
if a.client.AzureAuth.IsClientSecretSet() {
70+
//lint:ignore ST1005 Azure is a valid capitalized string
6971
return fmt.Errorf("Azure KeyVault cannot yet be configured for Service Principal authorization")
7072
}
7173
req.BackendType = "AZURE_KEYVAULT"

0 commit comments

Comments
 (0)