aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/blizzy78/varnamelen/README.md
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2022-09-05 14:27:54 +0200
committerGitHub <noreply@github.com>2022-09-05 12:27:54 +0000
commitb2f2446b46bf02821d90ebedadae2bf7ae0e880e (patch)
tree923cf42842918d6bebca1d6bbdc08abed54d274d /vendor/github.com/blizzy78/varnamelen/README.md
parente6654faff4bcca4be92e9a8596fd4b77f747c39e (diff)
go.mod, vendor: update (#3358)
* go.mod, vendor: remove unnecessary dependencies Commands: 1. go mod tidy 2. go mod vendor * go.mod, vendor: update cloud.google.com/go Commands: 1. go get -u cloud.google.com/go 2. go mod tidy 3. go mod vendor * go.mod, vendor: update cloud.google.com/* Commands: 1. go get -u cloud.google.com/storage cloud.google.com/logging 2. go mod tidy 3. go mod vendor * go.mod, .golangci.yml, vendor: update *lint* Commands: 1. go get -u golang.org/x/tools github.com/golangci/golangci-lint@v1.47.0 2. go mod tidy 3. go mod vendor 4. edit .golangci.yml to suppress new errors (resolved in the same PR later) * all: fix lint errors hash.go: copy() recommended by gosimple parse.go: ent is never nil verifier.go: signal.Notify() with unbuffered channel is bad. Have no idea why. * .golangci.yml: adjust godot rules check-all is deprecated, but still work if you're hesitating too - I'll remove this commit
Diffstat (limited to 'vendor/github.com/blizzy78/varnamelen/README.md')
-rw-r--r--vendor/github.com/blizzy78/varnamelen/README.md155
1 files changed, 155 insertions, 0 deletions
diff --git a/vendor/github.com/blizzy78/varnamelen/README.md b/vendor/github.com/blizzy78/varnamelen/README.md
new file mode 100644
index 000000000..02131ff29
--- /dev/null
+++ b/vendor/github.com/blizzy78/varnamelen/README.md
@@ -0,0 +1,155 @@
+[![GoDoc](https://pkg.go.dev/badge/github.com/blizzy78/varnamelen)](https://pkg.go.dev/github.com/blizzy78/varnamelen)
+
+
+varnamelen
+==========
+
+A Go Analyzer that checks that the length of a variable's name matches its usage scope:
+
+Variables with short names can be hard to use if the variable is used over a longer span of lines of code.
+A longer variable name may be easier to comprehend.
+
+The analyzer also checks method receiver names, named return values, and type parameter names.
+
+Arbitrary declarations such as `f *foo` can be ignored, as well as idiomatic `ok` variables.
+Conventional Go parameters such as `ctx context.Context` or `t *testing.T` will always be ignored.
+
+**Example output**
+
+```
+test.go:4:2: variable name 'x' is too short for the scope of its usage (varnamelen)
+ x := 123
+ ^
+test.go:6:2: variable name 'i' is too short for the scope of its usage (varnamelen)
+ i := 10
+ ^
+```
+
+
+golangci-lint Integration
+-------------------------
+
+varnamelen is integrated into [golangci-lint] (though it may not always be the most recent version.)
+
+Example configuration for golangci-lint:
+
+```yaml
+linters-settings:
+ varnamelen:
+ # The longest distance, in source lines, that is being considered a "small scope." (defaults to 5)
+ # Variables used in at most this many lines will be ignored.
+ max-distance: 5
+ # The minimum length of a variable's name that is considered "long." (defaults to 3)
+ # Variable names that are at least this long will be ignored.
+ min-name-length: 3
+ # Check method receiver. (defaults to false)
+ check-receiver: false
+ # Check named return values. (defaults to false)
+ check-return: false
+ # Check type parameters. (defaults to false)
+ check-type-param: false
+ # Ignore "ok" variables that hold the bool return value of a type assertion. (defaults to false)
+ ignore-type-assert-ok: false
+ # Ignore "ok" variables that hold the bool return value of a map index. (defaults to false)
+ ignore-map-index-ok: false
+ # Ignore "ok" variables that hold the bool return value of a channel receive. (defaults to false)
+ ignore-chan-recv-ok: false
+ # Optional list of variable names that should be ignored completely. (defaults to empty list)
+ ignore-names:
+ - err
+ # Optional list of variable declarations that should be ignored completely. (defaults to empty list)
+ # Entries must be in one of the following forms (see below for examples):
+ # - for variables, parameters, or named return values:
+ # - <name> <type>
+ # - <name> *<type>
+ # - for type parameters:
+ # - <name> <type>
+ # - for constants:
+ # - const <name>
+ ignore-decls:
+ - c echo.Context
+ - t testing.T
+ - f *foo.Bar
+ - e error
+ - i int
+ - const C
+ - T any
+```
+
+
+Standalone Usage
+----------------
+
+The `cmd/` folder provides a standalone command line utility. You can build it like this:
+
+```
+go build -o varnamelen ./cmd/
+```
+
+**Usage**
+
+```
+varnamelen: checks that the length of a variable's name matches its scope
+
+Usage: varnamelen [-flag] [package]
+
+A variable with a short name can be hard to use if the variable is used
+over a longer span of lines of code. A longer variable name may be easier
+to comprehend.
+
+Flags:
+ -V print version and exit
+ -all
+ no effect (deprecated)
+ -c int
+ display offending line with this many lines of context (default -1)
+ -checkReceiver
+ check method receiver names
+ -checkReturn
+ check named return values
+ -checkTypeParam
+ check type parameter names
+ -cpuprofile string
+ write CPU profile to this file
+ -debug string
+ debug flags, any subset of "fpstv"
+ -fix
+ apply all suggested fixes
+ -flags
+ print analyzer flags in JSON
+ -ignoreChanRecvOk
+ ignore 'ok' variables that hold the bool return value of a channel receive
+ -ignoreDecls value
+ comma-separated list of ignored variable declarations
+ -ignoreMapIndexOk
+ ignore 'ok' variables that hold the bool return value of a map index
+ -ignoreNames value
+ comma-separated list of ignored variable names
+ -ignoreTypeAssertOk
+ ignore 'ok' variables that hold the bool return value of a type assertion
+ -json
+ emit JSON output
+ -maxDistance int
+ maximum number of lines of variable usage scope considered 'short' (default 5)
+ -memprofile string
+ write memory profile to this file
+ -minNameLength int
+ minimum length of variable name considered 'long' (default 3)
+ -source
+ no effect (deprecated)
+ -tags string
+ no effect (deprecated)
+ -trace string
+ write trace log to this file
+ -v no effect (deprecated)
+```
+
+
+License
+-------
+
+This package is licensed under the MIT license.
+
+
+
+[golangci-lint]: https://github.com/golangci/golangci-lint