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

chore: pre-commit hooks #14

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This file contains configuration options for golangci-lint
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 5m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# include test files or not, default is true
tests: false

# list of build tags, all linters use it. Default is empty list.
# build-tags:
# - <tag_here>

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs:
- .github
- features

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: checkstyle

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true


# all available settings of specific linters
linters-settings:
govet:
# report about shadowed variables
check-shadowing: true
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
gocritic:
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
enabled-tags:
- performance
- diagnostic

linters:
disable-all: true
enable:
- govet
- gosec
- errcheck
- unused
- gosimple
- staticcheck
- structcheck
- varcheck
- ineffassign
- dupl
- goconst
- deadcode
- gocyclo
- unparam

issues:

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
# Default value for this option is true.
exclude-use-default: false

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-per-linter: 500

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 500
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: "https://github.com/alessandrojcm/commitlint-pre-commit-hook"
rev: "v9.7.0"
hooks:
- id: "commitlint"
stages: [commit-msg]
additional_dependencies:
- commitlint-plugin-function-rules
- '@commitlint/config-conventional'
- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v4.5.0"
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/golangci/golangci-lint
rev: v1.55.2
hooks:
- id: golangci-lint-full
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Go Reference](https://pkg.go.dev/badge/github.com/regen-network/gocuke.svg)](https://pkg.go.dev/github.com/regen-network/gocuke)

`gocuke` is a Gherkin-based BDD testing library for golang.
`gocuke` is a Gherkin-based BDD testing library for golang.

## Features

Expand Down Expand Up @@ -209,7 +209,7 @@ Scenario: any int64 value
```go
type suite struct {
TestingT

x, parsed int64
str string
}
Expand All @@ -231,3 +231,24 @@ func (s *suite) IGetBackTheOriginalValue() {
## Roadmap

* [Cucumber `message` based reporting](https://cucumber.io/docs/cucumber/reporting/)


## Contributing

### pre-commit hooks

- We have some steps as defined in [.pre-commit-config.yaml] (.pre-commit-config.yaml) that run before commit
- On mac, simply `brew install pre-commit` to install the library
- To install the hooks for this repo `pre-commit install && pre-commit install --hook-type commit-msg`
- There's a helper script to install the hooks locally [setup-hooks.sh](setup-hooks.sh)
- pre-commit config is held in [.pre-commit-config.yaml](.pre-commit-config.yaml)
- More docs: <https://pre-commit.com/>
- Standards Enforcement:
- Conventional Commits
- https://www.conventionalcommits.org/en/v1.0.0/
- prefix your commits with - fix:, feat:, BREAKING CHANGE:
- additionally- build:, chore:, ci:, docs:, style:, refactor:, perf:, test:
- misc file & convention linting
- golanglintci
- Runs various linting utilities
- https://github.com/golangci/golangci-lint
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']}
Loading