Skip to content

Commit

Permalink
Merge pull request #606 from hashicorp/brandonc/TF-2774_fmt_ci
Browse files Browse the repository at this point in the history
[Chore] Add go fmt check to linter
  • Loading branch information
brandonc committed Dec 8, 2022
2 parents dbd41d5 + 7155a4d commit 3ac0491
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Expand Up @@ -11,6 +11,7 @@ linters:
- exportloopref #https://github.com/kyoh86/exportloopref
- bodyclose #https://github.com/timakin/bodyclose
- goconst #https://github.com/jgautheron/goconst
- gofmt
- errcheck #https://github.com/kisielk/errcheck
- stylecheck #https://github.com/dominikh/go-tools/tree/master/stylecheck
- revive #golint is deprecated and golangci-lint recommends to use revive instead https://github.com/mgechev/revive
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Expand Up @@ -6,13 +6,11 @@ generate: check-resource
go mod tidy; \
go run . $(RESOURCE) ;

fmt:

vet:
go vet

fmt:
go fmt ./...
gofmt -s -l -w .

lint:
golangci-lint run .
Expand Down
5 changes: 3 additions & 2 deletions docs/CONTRIBUTING.md
Expand Up @@ -18,10 +18,11 @@ There are instances where several new resources being added (i.e Workspace Run T

## Linting

Linting is not necessarily required for a change to be merged, but it helps smooth the review process and catch common mistakes early. If you'd like to run the linters manually, follow these steps:
After opening a PR, our CI system will perform a series of code checks, one of which is linting. Linting is not strictly required for a change to be merged, but it helps smooth the review process and catch common mistakes early. If you'd like to run the linters manually, follow these steps:

1. Ensure you have [installed golangci-lint](https://golangci-lint.run/usage/install/#local-installation)
2. From the CLI, run `make lint`
2. Format your code by running `make fmt`
3. Run lint checks using `make lint`

## Writing Tests

Expand Down
4 changes: 2 additions & 2 deletions tfe_test.go
Expand Up @@ -119,14 +119,14 @@ func Test_unmarshalResponse(t *testing.T) {
func Test_EncodeQueryParams(t *testing.T) {
t.Run("with no listOptions and therefore no include field defined", func(t *testing.T) {
urlVals := map[string][]string{
"include": []string{},
"include": {},
}
requestURLquery := encodeQueryParams(urlVals)
assert.Equal(t, requestURLquery, "")
})
t.Run("with listOptions setting multiple include options", func(t *testing.T) {
urlVals := map[string][]string{
"include": []string{"workspace", "cost_estimate"},
"include": {"workspace", "cost_estimate"},
}
requestURLquery := encodeQueryParams(urlVals)
assert.Equal(t, requestURLquery, "include=workspace%2Ccost_estimate")
Expand Down

0 comments on commit 3ac0491

Please sign in to comment.