Skip to content

Commit

Permalink
Fix and improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
ctjhoa committed May 18, 2015
1 parent 3b82a28 commit bac950b
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions README.md
@@ -1,14 +1,14 @@
rust-clippy
===========
#rust-clippy
[![Build Status](https://travis-ci.org/Manishearth/rust-clippy.svg?branch=master)](https://travis-ci.org/Manishearth/rust-clippy)

A collection of lints that give helpful tips to newbies and catch oversights.


##Lints
Lints included in this crate:

- `single_match`: Warns when a match statement with a single nontrivial arm (i.e, where the other arm is `_ => {}`) is used, and recommends `if let` instead.
- `box_vec`: Warns on usage of `Box<Vec<T>>`
- `dlist`: Warns on usage of `DList`
- `linkedlist`: Warns on usage of `LinkedList`
- `str_to_string`: Warns on usage of `str::to_string()`
- `toplevel_ref_arg`: Warns when a function argument is declared `ref` (i.e. `fn foo(ref x: u8)`, but not `fn foo((ref x, ref y): (u8, u8))`)
- `eq_op`: Warns on equal operands on both sides of a comparison or bitwise combination
Expand All @@ -31,10 +31,50 @@ To use, add the following lines to your Cargo.toml:
clippy = "*"
```

In your code, you may add `#![plugin(clippy)]` to use it (you may also need to include a `#![feature(plugin)]` line)
More to come, please [file an issue](https://github.com/Manishearth/rust-clippy/issues) if you have ideas!

You can allow/warn/deny the whole set using the `clippy` lint group (`#[allow(clippy)]`, etc)
##Usage
Add in your `Cargo.toml`:
```
[dependencies.clippy]
git = "https://github.com/Manishearth/rust-clippy"
```

More to come, please [file an issue](https://github.com/Manishearth/rust-clippy/issues) if you have ideas!
Sample `main.rs`:
```
#![feature(plugin)]
#![plugin(clippy)]
// OPTIONS GO HERE
fn main(){
let x = Some(1u8);
match x {
Some(y) => println!("{:?}", y),
_ => ()
}
}
```

Produce this warning:
```
src/main.rs:8:5: 11:6 warning: You seem to be trying to use match for destructuring a single type. Did you mean to use `if let`?, #[warn(single_match)] on by default
src/main.rs:8 match x {
src/main.rs:9 Some(y) => println!("{:?}", y),
src/main.rs:10 _ => ()
src/main.rs:11 }
src/main.rs:8:5: 11:6 note: Try if let Some(y) = x { ... }
src/main.rs:8 match x {
src/main.rs:9 Some(y) => println!("{:?}", y),
src/main.rs:10 _ => ()
src/main.rs:11 }
```

You can add `OPTIONS` to `allow`/`warn`/`deny`:
- the whole set using the `clippy` lint group (`#[deny(clippy)]`, etc)
- only some lints (`#[deny(single_match, box_vec)]`, etc)

*`deny` produce error instead of warnings*

##License
Licensed under [MPL](https://www.mozilla.org/MPL/2.0/). If you're having issues with the license, let me know and I'll try to change it to something more permissive.

0 comments on commit bac950b

Please sign in to comment.