Skip to content

Commit

Permalink
chore: pre-commit hooks (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xste authored Nov 10, 2023
1 parent 72dc136 commit cd806b2
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 2 deletions.
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']}

0 comments on commit cd806b2

Please sign in to comment.