Skip to content

Commit

Permalink
docs: golangci-lint related changes (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
  • Loading branch information
butuzov and alexandear authored Jun 3, 2023
1 parent bffce24 commit 5e9bc37
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func IsValidHostname(hostname string, fqdn bool) bool {
go install github.com/butuzov/mirror/cmd/mirror@latest
```

### `golangci-lint`
`golangci-lint` supports `mirror` since `v1.53.0`


## How to use

You run `mirror` with [`go vet`](https://pkg.go.dev/cmd/vet):
Expand All @@ -55,6 +59,47 @@ mirror ./...
/air/runner/util.go:173:14: avoid allocations with (*os.File).WriteString
```

With [`golangci-lint`](https://github.com/golangci/golangci-lint)

```
golangci-lint run --no-config --disable-all -Emirror
# github.com/argoproj/argo-cd
test/e2e/fixture/app/actions.go:83:11: avoid allocations with (*os.File).WriteString (mirror)
_, err = tmpFile.Write([]byte(data))
^
server/server.go:1166:9: avoid allocations with (*regexp.Regexp).MatchString (mirror)
return mainJsBundleRegex.Match([]byte(filename))
^
server/account/account.go:91:6: avoid allocations with (*regexp.Regexp).MatchString (mirror)
if !validPasswordRegexp.Match([]byte(q.NewPassword)) {
^
server/badge/badge.go:52:20: avoid allocations with (*regexp.Regexp).FindAllStringSubmatchIndex (mirror)
for _, v := range re.FindAllSubmatchIndex([]byte(str), -1) {
^
util/cert/cert.go:82:10: avoid allocations with (*regexp.Regexp).MatchString (mirror)
return validHostNameRegexp.Match([]byte(hostname)) || validIPv6Regexp.Match([]byte(hostname))
```

## Command line

- You can add checks for `_test.go` files with cli option `--with-tests`

### `golangci-lint`
With `golangci-lint` tests are checked by default and can be can be turned off by using the regular `golangci-lint` ways to do it:

- flag `--tests` (e.g. `--tests=false`)
- flag `--skip-files` (e.g. `--skip-files="_test.go"`)
- yaml confguration `run.skip-files`:
```yaml
run:
skip-files:
- '(.+)_test\.go'
```
- yaml confguration `issues.exclude-rules`:
```yaml
issues:
exclude-rules:
- path: '(.+)_test\.go'
linters:
- mirror
```

0 comments on commit 5e9bc37

Please sign in to comment.