1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-28 08:49:11 +02:00
Commit Graph

220 Commits

Author SHA1 Message Date
xuri
924e3db3ba
Rename rule range-loop-var to range-val-in-closure. 2018-09-29 11:32:32 +08:00
xuri
b34a6c053e
New rule: range-loop-var 2018-09-27 23:21:10 +08:00
SalvadorC
388baa3eeb Fix linter warnings (recommended config) in the code (#71) 2018-09-22 15:27:22 -07:00
Sylvain Kerkour
02575a7674 Add the imports-blacklist rule (#68)
* Add the imports-blacklist rule with tests

* Add the imports-blacklist rule to README.md

* Update the imports-blacklist rule to use map[string]bool so that we can have the algorithm in Visit below with O(n) instead of O(n*m)

* Fix the imports-blacklist rule to be case sensitive
2018-09-17 13:06:42 -07:00
SalvadorC
7240bd56d0
Merge pull request #62 from xuri/return-value-limit
New rule: return-result-limit
2018-09-17 21:56:59 +02:00
xuri
f02afab00f
Check max value and add more information about what the rule received as argument. 2018-09-17 20:17:21 +08:00
xuri
0c243f004c
Rename rule return-argument-limit to function-result-limit 2018-09-17 17:06:53 +08:00
xuri
f0ec17c8d5
New rule: return-argument-limit 2018-09-17 15:22:07 +08:00
mgechev
90f51530cc
Add white & black lists for var-naming
This PR introduces a white & black lists of initialisms for the
`var-naming` rule.

Now the rule can be configured with:

```toml
[rule.var-naming]
  arguments = [["ID"], ["VM", "BAR"]]
```

This way, the linter will ignore `customId` but will throw on `customVm` or `customBar`.

Fix #41
2018-09-15 15:05:31 -07:00
SalvadorC
f004425b6e redefines-builtin-id (new rule) (#60) 2018-09-13 19:19:49 -07:00
SalvadorC
eeabcb5376 removes debug trace (#57) 2018-09-09 08:33:45 -07:00
SalvadorC
81bdff4472 constant-logical-expr (new rule) (#55)
* suspicious-logical-expr (new rule)

* renames 'suspicious-logical-expression' to 'constant-logical-expression'
2018-08-23 11:45:10 -07:00
SalvadorC
771aa23069 bool-literal-in-expr (new rule) (#54)
* bool-literal-in-expr (new rule)

* bool-literal-in-expr: add test case and fix typo
2018-08-23 11:10:17 -07:00
SalvadorC
a2a52e398b Refactoring: removes unused function from modifies-param rule code (#50) 2018-08-13 15:19:00 -07:00
SalvadorC
613fd24a3b modifies-value-receiver (new rule) (#51) 2018-08-13 15:18:28 -07:00
SalvadorC
8ea88db68f struct-tag: add support for asn1 and bson (#49) 2018-08-07 11:28:45 -07:00
SalvadorC
6fa95fb6ba struct-tag (new rule) (#47) 2018-07-28 09:07:31 -07:00
SalvadorC
0404d66548 unnecessary-stmt (new rule) (#45)
* simpler (new rule)

* simpler: checks unitary switches

* unnecessary-stmt (new rule)
2018-07-27 22:38:39 -07:00
SalvadorC
3d8d46af0b flag-parameter (new rule) (#44)
* flag-parameter (new rule)

* fix failure confidence
2018-07-21 22:58:48 -07:00
chavacava
5248ad8ed9 add-constant (new rule) (#39) 2018-07-17 12:21:27 -07:00
chavacava
db6c522a37 New rule: unreachable-code (#38)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Adds confusing-naming rule

* adds multifile test

* [WIP] fix multiple file test

* draft solution for detecting confusing-names through multiple files

* [WIP] confusing-name multiple files

* clean-up

* draft working version

* cleaner version + more informative messages

* adds check on struct field names

* fix config.go

* clean master

* new ADS rule: newerr

* ADS-print working version

* ads-print final version

* ads-lost-err working version

* confusing-namming: fix tests

* removes ads-* rules

* rule unreachable-code

* unreachable-code refactored version

* skip corner case of mandatory return
2018-07-16 14:23:47 -07:00
chavacava
d95910df55 Refactoring: move pick function to rule/utils.go (#30)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Adds confusing-naming rule

* adds multifile test

* [WIP] fix multiple file test

* draft solution for detecting confusing-names through multiple files

* [WIP] confusing-name multiple files

* clean-up

* draft working version

* cleaner version + more informative messages

* adds check on struct field names

* fix config.go

* clean master

* new ADS rule: newerr

* ADS-print working version

* ads-print final version

* ads-lost-err working version

* confusing-namming: fix tests

* moves pick to rule/utils for better reusability
2018-07-09 03:00:44 +10:00
Minko Gechev
f966283f3e
Fix rule for documentation of exported types (#29)
* Fix rule for documentation of exported types

The rule was failing in the following case:

```go
// A is an awesome type
type A = int
```

Because revive was skipping the leading `A`, considering it as an article.

* Add "This" article and update Makefile
2018-07-08 08:14:15 +10:00
chavacava
c2e2dbac85 New rule: unused-parameter (#28)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Adds confusing-naming rule

* adds multifile test

* [WIP] fix multiple file test

* draft solution for detecting confusing-names through multiple files

* [WIP] confusing-name multiple files

* clean-up

* draft working version

* cleaner version + more informative messages

* adds check on struct field names

* fix config.go

* clean master

* new ADS rule: newerr

* ADS-print working version

* ads-print final version

* ads-lost-err working version

* confusing-namming: fix tests

* unused-parameter: working version

* WIP adds scopes - still imprecise ( eg a:=a is not detected as use)

* w/scopes and more precise

* adds test on structs

* adds test w/ var shadowing

* more precise handling of for/switch statements

* fix check of +=, -=, *= and the like. Adds better support for slices and switchs
2018-07-07 18:40:02 +10:00
chavacava
b8eababb0d New rule: confusing-results (#27)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Adds confusing-naming rule

* adds multifile test

* clean-up

* fix config.go

* confusing-results working version
2018-07-02 12:09:58 +10:00
chavacava
443bfc9e0b New rule: Confusing naming (#16)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Adds confusing-naming rule

* adds multifile test

* [WIP] fix multiple file test

* draft solution for detecting confusing-names through multiple files

* [WIP] confusing-name multiple files

* draft working version

* cleaner version + more informative messages

* adds check on struct field names

* confusing-namming: fix tests
2018-07-02 12:05:20 +10:00
chavacava
68deb55492 New rule deep-exit (#26)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Adds confusing-naming rule

* adds multifile test

* clean-up

* fix config.go

* deep-exit: first working version

* fix pbs from  @mgechev review

* deep-exit: modifies failure message
2018-06-27 06:21:03 +10:00
chavacava
b2532b3c33 New rule: modifies-parameter (#25)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Adds confusing-naming rule

* adds multifile test

* clean-up

* fix config.go

* working version
2018-06-24 17:26:21 +10:00
chavacava
7e89359269 superfuous-else handles more cases (#24)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Adds confusing-naming rule

* adds multifile test

* clean-up

* fix config.go

* superflous-else now detects "jumps" caused by functions like os.Exit and log.Fatal
2018-06-24 17:24:50 +10:00
chavacava
f8c1094ecd New rule: get-return (#23)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Adds confusing-naming rule

* adds multifile test

* clean-up

* clean master

* running version

* isGetter now checks for non lowercase characters
2018-06-22 21:21:09 +10:00
chavacava
4e19174270 Fix issue19 (#20)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* fix issue 19
2018-06-13 07:01:31 -07:00
chavacava
c9bde6c503 empty-block: ignore checking blocks of funcs and func literals (#17)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table

* Modifies empty-block rule to ignore bodies of
func literals and funcs

* add test cases on functions with a receiver for completeness
2018-06-11 12:08:58 -07:00
Tamir Duberstein
32df8ca880 Avoid false positives when returning interface values (#6)
* Use subtests

* Make unexported-return type check

* Avoid false positives when returning interface values

Fixes #5.
2018-06-11 11:22:33 -07:00
chavacava
1fa5046357 Adds new rule empty-block (#14)
* Adds rule superfluous-else (an extension of indent-error-flow)

* initial (non functional) version

* empty-block working version

* adds tests for empty-block rule

* Adds empty-block to the rules table

* code clean-up
2018-06-08 12:41:49 -07:00
chavacava
cbe45ffc79 Adds rule superfluous-else (an extension of indent-error-flow) (#13)
* Adds rule superfluous-else (an extension of indent-error-flow)

* Fix superfluous-else rule struct namming.

* Adds superfuous-else rule to the rules table
2018-06-08 07:06:29 -07:00
mgechev
1686f0b237
Introduce optional type checking
Enable optional type checking.
2018-05-31 21:43:02 -07:00
mgechev
55145d7427
Run var-naming on test files 2018-05-30 17:41:02 -07:00
mgechev
6c9ea8cf2d
Refactoring and renaming 2018-05-26 21:28:31 -07:00
mgechev
8c53dad5ec
Rename and docs 2018-05-26 16:14:36 -07:00
mgechev
655402f527 Add tests for the arguments limit 2018-02-04 15:10:35 -08:00
mgechev
b5fc0eaffc Add extra rule 2018-02-04 14:51:19 -08:00
mgechev
2ff1cccfd2 Add new rule 2018-02-02 13:32:03 -05:00
mgechev
deb72d6238 Add default formatter 2018-01-27 17:01:18 -08:00
mgechev
5ec3daa762 API improvements 2018-01-26 20:45:17 -08:00
mgechev
466e9339e4 Fix issues and add improvements 2018-01-26 20:34:20 -08:00
mgechev
9f437c09a5 Basic configuration 2018-01-26 20:20:49 -08:00
mgechev
e2e5db7203 Add cyclomatic complexity and improve tests 2018-01-26 19:48:44 -08:00
mgechev
3c3a6b538d Add all built-in rules 2018-01-25 11:34:38 -08:00
mgechev
a3c28563b7 Add increment decrement 2018-01-25 11:16:28 -08:00
mgechev
d6a6d6290d Add receiver name 2018-01-25 11:12:27 -08:00
mgechev
f9a08cd60f Add error rules 2018-01-25 11:06:56 -08:00
mgechev
f35fad066d Add errorf rule 2018-01-25 10:42:39 -08:00
mgechev
7d066071ce Add rules 2018-01-25 10:35:27 -08:00
mgechev
f926547659 Refactoring 2018-01-24 15:44:03 -08:00
mgechev
4f31c1639f Implement severity 2018-01-24 15:41:40 -08:00
mgechev
b2e276ddf8 Add names 2018-01-24 15:17:19 -08:00
mgechev
cc249b6cfa Add extra rule 2018-01-23 23:01:49 -08:00
mgechev
cac7f0e036 Add extra rules and tests 2018-01-23 19:13:02 -08:00
mgechev
1dc6e7cabd Remove useless getter 2018-01-21 18:48:51 -08:00
mgechev
9c979ed65f Implement proper var declaration rule 2018-01-21 18:41:38 -08:00
mgechev
98dce265c6 Refactoring 2018-01-21 18:04:41 -08:00
mgechev
f2e19894a1 Add extra rule 2017-11-26 18:48:07 -08:00
mgechev
8f8a8b5587 Implement extra rule 2017-11-19 18:23:01 -08:00
mgechev
836c184aaf Further refactoring 2017-11-19 17:58:28 -08:00
mgechev
af459bbef6 Refactor 2017-11-19 17:35:56 -08:00
mgechev
5d652029ae Refactor revive 2017-11-19 17:18:16 -08:00
mgechev
5bdfe48c09 Update disabled intervals 2017-09-01 21:46:54 -07:00
mgechev
7b970568f5 Implement initial basic version of enabling/disabling rules 2017-09-01 21:03:10 -07:00
mgechev
08c42c7475 Add extra primitives 2017-09-01 18:36:47 -07:00
mgechev
1cdf90891b Refactoring 2017-08-29 10:47:29 -07:00