diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 51a98923e..d73e16997 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -28,7 +28,6 @@ jobs: - name: Lint package uses: golangci/golangci-lint-action@v3 with: - args: --exclude ".*, make it a constant (goconst)" version: latest - name: Test package diff --git a/.golangci.yml b/.golangci.yml index 2d4daeb22..2d74c0df5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,7 +6,6 @@ run: concurrency: 4 timeout: 10m issues-exit-code: 1 - # Include test files or not, default is true tests: true # Output configuration options @@ -19,19 +18,14 @@ linters-settings: locale: US ignore-words: - noteable - unused: - # Treat code as a program (not a library) and report unused exported identifiers - check-exported: false linters: enable: - asciicheck - - deadcode - dogsled - errorlint - exportloopref - goconst - - golint - gosimple - govet - ineffassign @@ -40,11 +34,9 @@ linters: - nakedret - nolintlint - staticcheck - - structcheck - typecheck - unconvert - unused - - varcheck - whitespace disable: - errcheck @@ -52,6 +44,10 @@ linters: fast: false issues: + # List of regexps of issue texts to exclude. + exclude: + - "^.*, make it a constant$" + # Maximum issues count per one linter (set to 0 to disable) max-issues-per-linter: 0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6bf99b2e..ec4ed485d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,18 +1,36 @@ # How to Contribute -We want to make contributing to this project as easy as possible. +We want to make contributing to this project as easy as possible. -## Reporting Issues and Enhancements +## Reporting Issues -If you have an issue, please report it on the [issue tracker](https://github.com/xanzy/go-gitlab/issues) +If you have an issue, please report it on the [issue tracker]( +https://github.com/xanzy/go-gitlab/issues). -If there is a documented feature within Gitlab +When you are up for writing a PR to solve the issue you encountered, it's not +needed to first open a separate issue. In that case only opening a PR with a +description of the issue you are trying to solve is just fine. ## Contributing Code -Pull requests are always welcome. If adding code that needs to be tested, try to add tests if there aren't any. +Pull requests are always welcome. When in doubt if your contribution fits in with +the rest of the project, free to first open an issue to discuss your idea. -We use [`gofumpt`](https://github.com/mvdan/gofumpt) to format this project. +This is not needed when fixing a bug or adding an enhancement, as long as the +enhancement you are trying to add can be found in the public GitLab API docs as +this project only supports what is in the public API docs. + +## Coding style + +We try to follow the Go best practices, where it makes sense, and use [`gofumpt`]( +https://github.com/mvdan/gofumpt) to format code in this project. + +Before making a PR, please look at the rest this package and try to make sure +your contribution is consistent with the rest of the coding style. + +New struct field or methods should be placed (as much as possible) in the same +order as the ordering used in the public API docs. The idea is that this makes it +easier to find things. ### Setting up your local development environment to Contribute to `go-gitlab` @@ -31,5 +49,4 @@ We use [`gofumpt`](https://github.com/mvdan/gofumpt) to format this project. ```sh make test && make fmt ``` -1. Open up your pull request - +1. Open up your pull request diff --git a/Makefile b/Makefile index 111faf26d..749cb2953 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,22 @@ -setup: - go mod tidy - @go install mvdan.cc/gofumpt@latest - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest -.PHONY: setup +##@ General + +.PHONY: help +help: ## Display this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -test: - go test ./... -race #-v?? -.PHONY: test +##@ Development -fmt: +fmt: ## Format code @gofumpt -l -w . -.PHONY: fmt -lint: - @golangci-lint run --config .golangci.yml -.PHONY: lint +lint: ## Run linter + @golangci-lint run + +setup: ## Setup your local environment + go mod tidy + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + @go install mvdan.cc/gofumpt@latest +.PHONY: setup + +test: ## Run tests + go test ./... -race diff --git a/go.sum b/go.sum index a3dbd73bd..227c040f1 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,6 @@ google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6 google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.29.0 h1:44S3JjaKmLEE4YIkjzexaP+NzZsudE3Zin5Njn/pYX0= -google.golang.org/protobuf v1.29.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM= google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=