Commit Graph

290 Commits

Author SHA1 Message Date
Florian Hartwig
e4fbeb4947 Don't trigger block_in_if_condition_expr lint if the block is unsafe 2015-12-23 02:12:08 +01:00
mcarton
3abdcd4709 Implement #364 2015-12-21 19:36:58 +01:00
Devon Hollowood
b6766a0dcf Add RustcEncodable test 2015-12-21 01:40:19 -08:00
Devon Hollowood
b190aa7deb Implement #507
Make `used_underscore_binding` lint compatible with MacroAttributes
expansions. TODO: Add a good test for this.
2015-12-21 01:03:12 -08:00
Manish Goregaokar
4a32445aa7 Add macro check to used_underscore 2015-12-20 04:53:29 +05:30
Manish Goregaokar
9dca15de3e Merge pull request #499 from devonhollowood/underscore_binding
Add used_underscore_binding lint
2015-12-19 19:02:06 +05:30
Devon Hollowood
bd82c082cb Add test for struct fields 2015-12-18 16:29:22 -08:00
Devon Hollowood
98d21f9fc5 Make compatible with unused_variables lint 2015-12-18 16:04:33 -08:00
Devon Hollowood
c8d78a70b3 Test that we do not lint for multiple underscores 2015-12-18 13:47:12 -08:00
Devon Hollowood
3533d3a223 Add more tests 2015-12-18 00:57:09 -08:00
Manish Goregaokar
b900e88910 Merge pull request #494 from sanxiyn/suggestion-2
Use suggestion for needless_return
2015-12-17 22:17:32 +05:30
Devon Hollowood
e620a1d57c Make suggested changes 2015-12-16 17:28:26 -08:00
Oliver Schneider
902c7d832b fix cc computation in the presence of diverging calls
CFG treats diverging calls as its completely own path out of the function.
While this makes sense, it should also mean that a panic should increase the cyclomatic
complexity. Instead it decreases it.

Minimal example:

```rust
if a {
    b
} else {
    panic!("cake");
}
d
```

creates the following graph

```dot
digraph G {
  "if a" -> "b"
  "if a" -> "panic!(\"cake\")"
  "b" -> c
}
```

which has a CC of 1 (3 - 4 + 2). A CC of 1 means there is one path through the program.
Obviously that is wrong. There are two paths. One returning normally, and one panicking.
2015-12-14 14:29:20 +01:00
Devon Hollowood
92fba6bd2c Make clippy tests compatible with new lint 2015-12-12 21:39:10 -08:00
Devon Hollowood
6091112698 Update tests 2015-12-12 21:39:10 -08:00
Devon Hollowood
6482840bc5 Add tests 2015-12-12 21:39:10 -08:00
Seo Sanghyeon
974ab43453 Use suggestion for needless_return 2015-12-11 16:28:05 +09:00
Manish Goregaokar
b9546599e3 Check for unused lifetimes in bounds (fixes #489) 2015-12-10 12:02:59 -05:00
Manish Goregaokar
b865e30b49 Upgrade rust to rustc 1.6.0-nightly (462ec0576 2015-12-09) 2015-12-09 15:56:49 -05:00
Seo Sanghyeon
35b5c3efdd Use suggestion for redundant_closure 2015-12-08 15:03:01 +09:00
Manish Goregaokar
c7b87a06d2 Add lint for unused lifetimes (fixes #459) 2015-12-07 06:55:14 -05:00
Manish Goregaokar
c4e9982dd7 Merge pull request #481 from fhartwig/lifetime-with-alias
Make unneeded_lifetimes lint work properly with type aliases
2015-12-06 09:08:40 +05:30
Florian Hartwig
62db392730 Make lifetimes lint work with type aliases and non-locally-defined structs 2015-12-06 02:04:13 +01:00
Robert Clipsham
978c41584f Fix clippy with latest Rust nightly. 2015-12-05 12:33:58 +00:00
Manish Goregaokar
18e81c1b59 Rudimentary escape analysis for Box<T> 2015-12-04 20:23:14 +05:30
Oliver Schneider
3d1b7e1957 high-speed-dogfood 2015-12-03 16:41:55 +01:00
Oliver Schneider
617c820e6b compute cyclomatic complexity (adjusted to not punish Rust's match) 2015-12-03 16:41:55 +01:00
Manish Goregaokar
409c0f0998 Merge pull request #468 from devonhollowood/option-methods
Lint `map(f).unwrap_or(a)` and `map(f).unwrap_or_else(g)`
2015-11-26 14:22:27 +05:30
Devon Hollowood
443e4556c2 Add lints suggesting map_or() and map_or_else()
In accordance with the latter lint, replace map().unwrap_or_else() in
src/mut_mut.rs with map_or_else()
2015-11-25 23:56:45 -08:00
Florian Hartwig
94dc2f567a Suppress explicit_counter_loop lint if loop variable is used after the loop 2015-11-26 00:09:01 +01:00
Seo Sanghyeon
746991572f Extend match_ref_pats to desugared matches 2015-11-25 02:47:17 +09:00
Manish Goregaokar
84ad2be1df Merge branch 'pr-462'
Conflicts:
	README.md
2015-11-22 21:58:13 +05:30
John Quigley
d4cf288b38 Add block_in_if lint, #434 2015-11-22 21:52:06 +05:30
Florian Hartwig
096c064d43 Simplify has_debug_impl 2015-11-19 20:13:36 +01:00
Florian Hartwig
cad88a9137 warn on use of ok().expect() 2015-11-19 17:15:21 +01:00
Seo Sanghyeon
b17e38782e Remove trailing commas in match arms with blocks 2015-11-17 13:39:42 +09:00
llogiq
1555eed5fb Merge pull request #452 from fhartwig/lifetime-false-positives
Fix some false positive in needless_lifetimes lint
2015-11-14 09:25:19 +01:00
Andrew Paseltiner
91763d7725 Match min and max functions using DefId
Closes #446.
2015-11-11 11:08:33 -05:00
Andrew Paseltiner
e8a239a1a2 Add lint for useless transmutes
Closes #441.
2015-11-11 10:53:11 -05:00
Florian Hartwig
6046edbc23 Add some tests for lifetime elision lint with types and traits with lifetimes 2015-11-11 00:26:22 +01:00
Andre Bogus
42ae1e6918 use rustc's eval_const, bail on (negative) infinity 2015-11-10 11:23:47 +01:00
Andrew Paseltiner
2801c1031d Remove executable permission from remaining source files 2015-11-09 08:04:41 -05:00
Manish Goregaokar
140c34f85e Tests shouldn't be executable (fixes #444) 2015-11-09 08:49:20 +05:30
llogiq
a0cd8fc943 match .map(Clone::clone) 2015-11-05 17:11:41 +01:00
Seo Sanghyeon
3322ffa8a0 New lint for assignment to temporary 2015-11-04 21:37:18 +09:00
wartman4404
764eedd050 check for Deref conversions 2015-11-03 21:11:40 -06:00
wartman4404
414c0d20f7 New lint for using .cloned() 2015-11-03 21:01:52 -06:00
Nathan Weston
d28b8e169f New lint for zip with array length instead of enumerate()
Fixes #11.
2015-11-03 15:55:20 -05:00
Manish Goregaokar
dbb8a872a3 Fix ptr-arg false positive for trait impls
Fixes #425
2015-10-31 05:18:05 +05:30
llogiq
555328cc7b Merge pull request #422 from sanxiyn/no-effect
New lint for statement with no effect
2015-10-29 12:05:28 +01:00
Seo Sanghyeon
0fe5981870 New lint for statement with no effect 2015-10-29 15:50:35 +09:00
wartman4404
8e4c2171d2 Don't show single_match if match_bool also applies 2015-10-28 22:26:48 -05:00
Florian Hartwig
5ca7ebb6d2 Fix false positives when iterator variable is used after the loop 2015-10-26 23:57:55 +01:00
Florian Hartwig
8626ac1fd4 Fixes for code review comments
* remove weird infinite loops from compile-tests
* remove call to Option::unwrap
* in the lint message, show while-let loop rewritten as for loop
2015-10-26 23:57:55 +01:00
Florian Hartwig
659e7c1d5e Don't suggest using a for loop if the iterator is used in the loop body
Due to https://github.com/rust-lang/rust/issues/8372, we have to use while-let
in these cases.
2015-10-26 23:57:55 +01:00
Florian Hartwig
f6163fce61 Suggest for loop instead of while-let when looping over iterators 2015-10-26 23:57:50 +01:00
Georg Brandl
a91c618fed Fix reverse_range_loop not taking sign into account (fixes #409)
Adds a Display impl for Constant, because that might come in handy
elsewhere as well.
2015-10-26 08:05:01 +01:00
Kevin Yap
70e3277bf9 Compare float literals to stringified constants
- Convert constants to strings and compare directly with float literal.
- Return immediately after positive match for constant.
- Fix value of `my_log10_e` in `approx_const` tests.
2015-10-24 16:00:22 -07:00
Kevin Yap
546eb14b7e Change implementation of approx_const lint
- Replace epsilon with lower and upper bounds for each constant.
- Warn on use of "3.14", and update tests accordingly.
2015-10-22 23:07:27 -07:00
Seo Sanghyeon
d843257643 New lint for struct update that has no effect 2015-10-22 18:19:06 +09:00
Andre Bogus
da82e2d3ba added code snippet help to match_bool 2015-10-21 08:24:56 +02:00
Vikas Kumar
2951b70d15 Match on bool should be replaced with if..else block
1. Added another conditional in `check_expr` impl to lint if match expr
is a bool.
2. Test cases.
2015-10-20 10:18:48 -07:00
Florian Gilcher
8063916477 Cleanup as discussed in PR 2015-10-17 20:16:54 +02:00
Florian Gilcher
1bd023d3e0 New lint for needless use of nightly features 2015-10-15 21:33:47 +02:00
Manish Goregaokar
b2f4550654 Fix type complexity lint 2015-10-15 19:55:14 +05:30
Andre Bogus
be66322886 workaround for failing test 2015-10-15 16:18:40 +02:00
Andre Bogus
cf1e83b6dc Merged #365 2015-10-14 12:22:57 +02:00
Andre Bogus
949c3545ce Merged #366 2015-10-14 12:06:28 +02:00
Andre Bogus
b3d035d252 Merge PR #374 2015-10-14 11:44:09 +02:00
Andre Bogus
bed29a017b new lint to detect 2015-10-13 18:38:08 +05:30
Manish Goregaokar
567d5a7293 Improve cmp_owned suggestions (fixes #386) 2015-10-13 04:16:05 +05:30
Ravi Shankar
fb5fdb61fa whup the while_let_loop for ignoring expressions! 2015-10-12 19:12:59 +05:30
swgillespie
b02e80c012 implement 0.0/0.0 -> NaN lint as described in #370
casing of NaN
2015-10-11 19:26:23 -07:00
Manish Goregaokar
4e2b09831b Rust upgrade to rustc 1.5.0-nightly (9d3e79ad3 2015-10-10) 2015-10-12 02:42:59 +05:30
Florian Hartwig
26b2733b15 Add a lint for sized integer types in a mutex 2015-10-07 22:58:34 +02:00
Pyriphlegethon
7644f8e2a1 Add "nonsensical OpenOptions" lint 2015-10-07 13:46:51 +02:00
Florian Hartwig
f8aa0431bd Suggest using an atomic value instead of a Mutex where possible 2015-10-07 01:35:14 +02:00
Manish Goregaokar
3e475e9588 Merge pull request #354 from Pyriphlegethon/master
Add "unnecessary mut passed" lint
2015-10-07 04:18:02 +05:30
Manish Goregaokar
431c391818 Fix a panic caused by while let 2015-10-02 13:37:41 +05:30
Manish Goregaokar
7eb0896271 Merge pull request #351 from Wafflespeanut/while_let
Training the `while_let` detector...
2015-10-01 01:14:45 +05:30
Pyriphlegethon
390168cc0f Well, fix them again 2015-09-30 18:17:55 +02:00
Pyriphlegethon
c5ab8d62e3 Fix tests 2015-09-30 18:00:14 +02:00
Manish Goregaokar
f76f4d52c2 Fix rustup fallout: lifetimes false positives 2015-09-30 20:10:54 +05:30
Pyriphlegethon
52aee99f6d Add test for unnecessary mut passed lint 2015-09-30 13:28:23 +02:00
Ravi Shankar
185da55263 extending while_let to warn for more statements 2015-09-29 20:26:34 +05:30
Georg Brandl
e8f875813d all: remove trailing spaces 2015-09-28 07:11:03 +02:00
llogiq
4838e8a3b4 Merge pull request #344 from Manishearth/reflet
Handle let ref in toplevel_ref_arg as well
2015-09-22 09:18:45 +02:00
Manish Goregaokar
3609a2211a Handle let ref in toplevel_ref_arg as well 2015-09-22 12:46:51 +05:30
Georg Brandl
7cc291d02e generalize let_and_return for any block (closes #340) 2015-09-20 13:57:31 +02:00
Manish Goregaokar
f4da7d09d2 Upgrade Rust to rustc 1.5.0-nightly (cff041170 2015-09-17)
LintPass was split and ExprParen was removed from the HIR

Fixes #338
2015-09-19 08:23:04 +05:30
llogiq
acc83c0b02 Merge pull request #336 from Manishearth/issue335
ref matches: false positive with only wildcard pattern match
2015-09-17 07:43:26 +02:00
Georg Brandl
e3ee87965e ref matches: false positive with only wildcard pattern match (fixes #335) 2015-09-17 07:25:08 +02:00
Manish Goregaokar
3124d2b8df Rustup to rustc 1.5.0-nightly (fc4d566b4 2015-09-16)
fixes #334
2015-09-17 05:32:29 +05:30
Nathan Weston
8a5b4f19fd Check for mutable borrow of counter variable 2015-09-15 09:41:25 -04:00
Nathan Weston
f87dd31f30 New lint: loop with explicit counter variable (fixes #159)
Avoiding false positives here turns out to be fairly complicated.
2015-09-15 09:41:25 -04:00
llogiq
5c5d103405 added fp test against negative .step_by(_) 2015-09-15 09:12:58 +02:00
swgillespie
bc7d252856 use the constant folder to generalize the lint a little bit and clean up the code. Add additional tests for things that should not be linted 2015-09-14 22:20:56 -07:00
swgillespie
82c524b774 implement empty range lint as described in #330 2015-09-14 17:19:05 -07:00
llogiq
0e1bc74683 additional macro check + more tests 2015-09-10 08:51:14 +02:00
llogiq
4835372df5 made shadow_unrelated allow, added previous binding span note, fixed #319 2015-09-08 11:50:04 +02:00