From bac950b4d63a3f04bbb6502d6d2f832e4d64dc77 Mon Sep 17 00:00:00 2001 From: Camille TJHOA Date: Tue, 28 Apr 2015 21:50:04 +0200 Subject: [PATCH 1/3] Fix and improve README --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ddc28a95f..419000517 100644 --- a/README.md +++ b/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>` - - `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 @@ -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) - -You can allow/warn/deny the whole set using the `clippy` lint group (`#[allow(clippy)]`, etc) - More to come, please [file an issue](https://github.com/Manishearth/rust-clippy/issues) if you have ideas! +##Usage +Add in your `Cargo.toml`: +``` +[dependencies.clippy] +git = "https://github.com/Manishearth/rust-clippy" +``` + +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. From b533b084f3abeabe6949cdaaff80f74ac22f7200 Mon Sep 17 00:00:00 2001 From: Camille TJHOA Date: Wed, 29 Apr 2015 14:18:02 +0200 Subject: [PATCH 2/3] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 419000517..de37d5e59 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ 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* +*`deny` produces 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. From 04f48455e5906c32e826d751f07fd6f635bc68e6 Mon Sep 17 00:00:00 2001 From: Camille TJHOA Date: Wed, 29 Apr 2015 16:17:30 +0200 Subject: [PATCH 3/3] Specify languages for examples --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de37d5e59..48289f042 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,13 @@ More to come, please [file an issue](https://github.com/Manishearth/rust-clippy/ ##Usage Add in your `Cargo.toml`: -``` +```toml [dependencies.clippy] git = "https://github.com/Manishearth/rust-clippy" ``` Sample `main.rs`: -``` +```rust #![feature(plugin)] #![plugin(clippy)]