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

97 Commits

Author SHA1 Message Date
dshemin
a5c77eed9f Add check for argument length to "file-header" rule 2019-12-02 02:04:49 +07:00
dshemin
9bb943735e Fix review comments 2019-11-28 10:14:21 +07:00
dshemin
3c93b9c1a4 Fix #245 File header rule: index out of range [0] with length 0 2019-11-28 01:38:43 +07:00
SalvadorC
84deee4163 fixes issue #229 (#231) 2019-09-10 10:26:47 -07:00
SalvadorC
9649b1c2a1 fix 208 struct-tag linter false positive (#209) 2019-08-05 09:21:20 -07:00
SalvadorC
c967fd68ea struct-tag warns on private fields with tags (#131) 2019-06-01 10:34:43 +02:00
SalvadorC
c8ee35a500 adds blacklist to unhandled-error (#128)
* adds blacklist for unhandled-error

* uses ignoreList in place of blackList
2019-04-29 19:56:12 -07:00
SalvadorC
8aa0cd8bd4 unhandled-error (new rule) (#124)
* unhandled-error (new rule)

* better failure msg

* encapsulates error type detection
2019-04-27 19:23:17 -07:00
SalvadorC
e8c1baf8ac optimizes import-blacklist (#123) 2019-04-22 10:58:02 -07:00
SalvadorC
2474f6cecb simpler and more efficient implementation of unused-parameter (#121) 2019-04-21 10:13:03 -07:00
SalvadorC
00a86ae1fd new rule: unused-receiver (#119)
* new rule: unused-receiver

* unused-receiver: adds more test cases
2019-04-18 10:35:51 -07:00
SalvadorC
745bcf65aa bare-return (first working version) (#117)
New rule bare-return
2019-04-17 22:55:52 +02:00
SalvadorC
2ce440cf96 new rule: import shadowing (#114)
* 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

* clean master

* new ADS rule: newerr

* ADS-print working version

* ads-print final version

* ads-lost-err working version

* fix ads-print

* removes ads rules from master

* new rule: import-shadowing

* removes ads rules from master

* new rule: import-shadowing

* fix defaults

* adds explanations on the rule implementation
2019-03-27 11:46:20 -07:00
Dian
44eed7edb7 fix error return rule to allow multiple error return values (#110)
* fix error return rule to allow multiple error return values

please check golint related updates here: golang/lint@8379672

When returning multiple values with an error,
lint checks if the error is the last return value.
But the implementation actually is checking for all return values
except for the last one, and throw the alert if it found an error.

There is a (edge) case where some function returning more than one error
is getting a false positive even when the last return value is an error.

This patch adds an early check, to see if the last return value is an error
and if so, it will pass silently.

* Fix return error

* add test changes
2019-03-20 11:54:27 -07:00
SalvadorC
fbefad8558 New rule: duplicated-imports (#111)
* 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

* clean master

* new ADS rule: newerr

* ADS-print working version

* ads-print final version

* ads-lost-err working version

* adds duplicated-imports rule

* adds duplicated-imports rule
2019-03-20 11:54:03 -07:00
SalvadorC
55fe366696 call-to-gc (new rule) (#90) 2018-10-31 07:32:23 -07:00
mgechev
376425d517
refactor: remove URL field from the failure struct 2018-10-30 15:37:27 -07:00
xuri
3c177e2824 New rule: line-length-limit (#86)
* New rule: line-length-limit

* simplify the panic message of rule line-length-limit

* Refactors `line-length-limit` rule, use private `check` method instead of `Visit`
2018-10-19 08:18:33 -04:00
SalvadorC
3cae2fa6f9
Update empty-lines.go
removes warning on unused parameter
2018-10-13 20:13:29 +02:00
Genadi Samokovarov
b7d9bce0b6 Fix the same-line comments detection in the empty-lines rule
Fixes #84.
2018-10-13 09:47:29 -07:00
Genadi Samokovarov
04516d2f82 Handle multi-line statements edge-cases in the multi-line rule (#83)
There were many cases where the multi-line statements at the end of a
block were marked as containing empty lines, while they didn't. Or vice
versa.
2018-10-12 22:38:08 -07:00
Genadi Samokovarov
d2e0e5a0ed Introduce the empty-lines rule that verifies there are no {head,trail}ing lines (#81) 2018-10-11 14:52:46 -07:00
SalvadorC
da63d0a965 Refactors atomic rule code to move gofmt function to utils.go (issue #79) (#80)
* Refactoring on atomic rule:
-Main modification: move func gofmt to utils.go

* Refactoring on constant-logical-expr rule
Simplifies equality check of subexpressions by using gofmt function
2018-10-03 11:56:57 -07:00
xuri
7d2c43c827
Rename rule name waitgroup-by-copy to waitgroup-by-value 2018-10-03 16:01:41 +08:00
xuri
9545122d39 New rule: atomic (#77) 2018-10-01 12:24:17 -07:00
SalvadorC
6ebe5bbb1e waitgroup-by-value (new rule) (#76)
* waitgroup-by-value (new rule)

* code simplification
2018-09-30 12:29:11 -07:00
SalvadorC
f3834d0604
Removes linter warning
Renamed unused parameter `arguments` to `_`
2018-09-29 07:04:10 +02:00
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