Skip to content

Commit

Permalink
review cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
mfederowicz committed Dec 1, 2023
1 parent 1d89e03 commit 66e1d2a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 49 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ List of all available rules. The rules ported from `golint` are left unchanged a
| [`exported`](./RULES_DESCRIPTIONS.md#exported) | []string | Naming and commenting conventions on exported symbols. | yes | no |
| [`if-return`](./RULES_DESCRIPTIONS.md#if-return) | n/a | Redundant if when returning an error. | no | no |
| [`increment-decrement`](./RULES_DESCRIPTIONS.md#increment-decrement) | n/a | Use `i++` and `i--` instead of `i += 1` and `i -= 1`. | yes | no |
| [`var-naming`](./RULES_DESCRIPTIONS.md#var-naming) | allowlist & blocklist of initialisms | Naming rules. | yes | no |
| [`var-naming`](./RULES_DESCRIPTIONS.md#var-naming) | whitelist & blacklist of initialisms | Naming rules. | yes | no |
| [`package-comments`](./RULES_DESCRIPTIONS.md#package-comments) | n/a | Package commenting conventions. | yes | no |
| [`range`](./RULES_DESCRIPTIONS.md#range) | n/a | Prevents redundant variables when iterating over a collection. | yes | no |
| [`receiver-naming`](./RULES_DESCRIPTIONS.md#receiver-naming) | n/a | Conventions around the naming of receivers. | yes | no |
Expand All @@ -504,7 +504,7 @@ List of all available rules. The rules ported from `golint` are left unchanged a
| [`bool-literal-in-expr`](./RULES_DESCRIPTIONS.md#bool-literal-in-expr)| n/a | Suggests removing Boolean literals from logic expressions | no | no |
| [`redefines-builtin-id`](./RULES_DESCRIPTIONS.md#redefines-builtin-id)| n/a | Warns on redefinitions of builtin identifiers | no | no |
| [`function-result-limit`](./RULES_DESCRIPTIONS.md#function-result-limit) | int (defaults to 3)| Specifies the maximum number of results a function can return | no | no |
| [`imports-blocklist`](./RULES_DESCRIPTIONS.md#imports-blocklist) | []string | Disallows importing the specified packages | no | no |
| [`imports-blacklist`](./RULES_DESCRIPTIONS.md#imports-blacklist) | []string | Disallows importing the specified packages | no | no |
| [`range-val-in-closure`](./RULES_DESCRIPTIONS.md#range-val-in-closure)| n/a | Warns if range value is used in a closure dispatched as goroutine| no | no |
| [`range-val-address`](./RULES_DESCRIPTIONS.md#range-val-address)| n/a | Warns if address of range value is used dangerously | no | yes |
| [`waitgroup-by-value`](./RULES_DESCRIPTIONS.md#waitgroup-by-value) | n/a | Warns on functions taking sync.WaitGroup as a by-value parameter | no | no |
Expand Down Expand Up @@ -545,7 +545,7 @@ Here you can find how you can configure some existing rules:

### `var-naming`

This rule accepts two slices of strings, a allowlist and a blocklist of initialisms. By default, the rule behaves exactly as the alternative in `golint` but optionally, you can relax it (see [golint/lint/issues/89](https:/golang/lint/issues/89))
This rule accepts two slices of strings, a whitelist and a blacklist of initialisms. By default, the rule behaves exactly as the alternative in `golint` but optionally, you can relax it (see [golint/lint/issues/89](https:/golang/lint/issues/89))

```toml
[rule.var-naming]
Expand Down
12 changes: 6 additions & 6 deletions RULES_DESCRIPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ List of all available rules.
- [if-return](#if-return)
- [import-alias-naming](#import-alias-naming)
- [import-shadowing](#import-shadowing)
- [imports-blocklist](#imports-blocklist)
- [imports-blacklist](#imports-blacklist)
- [increment-decrement](#increment-decrement)
- [indent-error-flow](#indent-error-flow)
- [line-length-limit](#line-length-limit)
Expand Down Expand Up @@ -530,16 +530,16 @@ name of an imported package. This rule spots identifiers that shadow an import.

_Configuration_: N/A

## imports-blocklist
## imports-blacklist

_Description_: Warns when importing block-listed packages.
_Description_: Warns when importing black-listed packages.

_Configuration_: block-list of package names (or regular expression package names).
_Configuration_: black-list of package names (or regular expression package names).

Example:

```toml
[imports-blocklist]
[imports-blacklist]
arguments =["crypto/md5", "crypto/sha1", "crypto/**/pkix"]
```

Expand Down Expand Up @@ -875,7 +875,7 @@ _Description_: This rule warns when [initialism](https:/golang/go/wi

_Configuration_: This rule accepts two slices of strings and one optional slice with single map with named parameters.
(it's due to TOML hasn't "slice of any" and we keep backward compatibility with previous config version)
First slice is a allowlist and second one is a blocklist of initialisms.
First slice is a whitelist and second one is a blacklist of initialisms.
In map, you can add "upperCaseConst=true" parameter to allow `UPPER_CASE` for `const`
By default, the rule behaves exactly as the alternative in `golint` but optionally, you can relax it (see [golint/lint/issues/89](https:/golang/lint/issues/89))

Expand Down
8 changes: 4 additions & 4 deletions rule/add-constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r *AddConstantRule) Apply(file *lint.File, arguments lint.Arguments) []lin
onFailure: onFailure,
strLits: make(map[string]int),
strLitLimit: r.strLitLimit,
allowLst: r.allowList,
allowList: r.allowList,
ignoreFunctions: r.ignoreFunctions,
}

Expand All @@ -71,7 +71,7 @@ type lintAddConstantRule struct {
onFailure func(lint.Failure)
strLits map[string]int
strLitLimit int
allowLst allowList
allowList allowList
ignoreFunctions []*regexp.Regexp
}

Expand Down Expand Up @@ -139,7 +139,7 @@ func (w lintAddConstantRule) isIgnoredFunc(fName string) bool {
}

func (w lintAddConstantRule) checkStrLit(n *ast.BasicLit) {
if w.allowLst[kindSTRING][n.Value] {
if w.allowList[kindSTRING][n.Value] {
return
}

Expand All @@ -159,7 +159,7 @@ func (w lintAddConstantRule) checkStrLit(n *ast.BasicLit) {
}

func (w lintAddConstantRule) checkNumLit(kind string, n *ast.BasicLit) {
if w.allowLst[kind][n.Value] {
if w.allowList[kind][n.Value] {
return
}

Expand Down
4 changes: 2 additions & 2 deletions rule/var-naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func (r *VarNamingRule) configure(arguments lint.Arguments) {

r.configured = true
if len(arguments) >= 1 {
r.allowlist = getList(arguments[0], "allowlist")
r.allowlist = getList(arguments[0], "whitelist")
}

if len(arguments) >= 2 {
r.blocklist = getList(arguments[1], "blocklist")
r.blocklist = getList(arguments[1], "blacklist")
}

if len(arguments) >= 3 {
Expand Down
34 changes: 0 additions & 34 deletions test/import-blocklist_test.go

This file was deleted.

0 comments on commit 66e1d2a

Please sign in to comment.