Skip to content

Commit eb5d87c

Browse files
committed
Merge pull request #903 from oli-obk/master
use remark-lint to check README.md
2 parents 3c1d327 + 3ec1b9a commit eb5d87c

File tree

5 files changed

+75
-28
lines changed

5 files changed

+75
-28
lines changed

.remarkrc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"plugins": {
3+
"lint": {
4+
"table-pipes": false,
5+
"table-pipe-alignment": false,
6+
"maximum-line-length": 120
7+
}
8+
},
9+
"settings": {
10+
"commonmark": true
11+
}
12+
}

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ env:
77
# TRAVIS_TOKEN_CLIPPY_SERVICE
88
secure: dj8SwwuRGuzbo2wZq5z7qXIf7P3p7cbSGs1I3pvXQmB6a58gkLiRn/qBcIIegdt/nzXs+Z0Nug+DdesYVeUPxk1hIa/eeU8p6mpyTtZ+30H4QVgVzd0VCthB5F/NUiPVxTgpGpEgCM9/p72xMwTn7AAJfsGqk7AJ4FS5ZZKhqFI=
99

10+
install:
11+
- . $HOME/.nvm/nvm.sh
12+
- nvm install stable
13+
- nvm use stable
14+
- npm install remark remark-lint
15+
1016
script:
17+
- set -e
18+
- remark -f README.md > /dev/null
1119
- python util/update_lints.py -c
1220
- cargo build --features debugging
1321
- rm -rf target/ Cargo.lock

README.md

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#rust-clippy
1+
# rust-clippy
2+
23
[![Build Status](https://travis-ci.org/Manishearth/rust-clippy.svg?branch=master)](https://travis-ci.org/Manishearth/rust-clippy)
34
[![Clippy Linting Result](http://clippy.bashy.io/github/Manishearth/rust-clippy/master/badge.svg)](http://clippy.bashy.io/github/Manishearth/rust-clippy/master/log)
45
[![Current Version](http://meritbadge.herokuapp.com/clippy)](https://crates.io/crates/clippy)
@@ -7,13 +8,15 @@
78
A collection of lints to catch common mistakes and improve your Rust code.
89

910
Table of contents:
10-
* [Lint list](#lints)
11-
* [Usage instructions](#usage)
12-
* [Configuration](#configuration)
13-
* [*clippy-service*](#link-with-clippy-service)
14-
* [License](#license)
1511

16-
##Lints
12+
* [Lint list](#lints)
13+
* [Usage instructions](#usage)
14+
* [Configuration](#configuration)
15+
* [*clippy-service*](#link-with-clippy-service)
16+
* [License](#license)
17+
18+
## Lints
19+
1720
There are 146 lints included in this crate:
1821

1922
name | default | meaning
@@ -27,7 +30,7 @@ name
2730
[block_in_if_condition_stmt](https://github.com/Manishearth/rust-clippy/wiki#block_in_if_condition_stmt) | warn | avoid complex blocks in conditions, instead move the block higher and bind it with 'let'; e.g: `if { let x = true; x } ...`
2831
[bool_comparison](https://github.com/Manishearth/rust-clippy/wiki#bool_comparison) | warn | comparing a variable to a boolean, e.g. `if x == true`
2932
[box_vec](https://github.com/Manishearth/rust-clippy/wiki#box_vec) | warn | usage of `Box<Vec<T>>`, vector elements are already on the heap
30-
[boxed_local](https://github.com/Manishearth/rust-clippy/wiki#boxed_local) | warn | using Box<T> where unnecessary
33+
[boxed_local](https://github.com/Manishearth/rust-clippy/wiki#boxed_local) | warn | using `Box<T>` where unnecessary
3134
[cast_possible_truncation](https://github.com/Manishearth/rust-clippy/wiki#cast_possible_truncation) | allow | casts that may cause truncation of the value, e.g `x as u8` where `x: u32`, or `x as i32` where `x: f32`
3235
[cast_possible_wrap](https://github.com/Manishearth/rust-clippy/wiki#cast_possible_wrap) | allow | casts that may cause wrapping around the value, e.g `x as i32` where `x: u32` and `x > i32::MAX`
3336
[cast_precision_loss](https://github.com/Manishearth/rust-clippy/wiki#cast_precision_loss) | allow | casts that cause loss of precision, e.g `x as f32` where `x: u64`
@@ -145,7 +148,7 @@ name
145148
[transmute_ptr_to_ref](https://github.com/Manishearth/rust-clippy/wiki#transmute_ptr_to_ref) | warn | transmutes from a pointer to a reference type
146149
[trivial_regex](https://github.com/Manishearth/rust-clippy/wiki#trivial_regex) | warn | finds trivial regular expressions in `Regex::new(_)` invocations
147150
[type_complexity](https://github.com/Manishearth/rust-clippy/wiki#type_complexity) | warn | usage of very complex types; recommends factoring out parts into `type` definitions
148-
[unicode_not_nfc](https://github.com/Manishearth/rust-clippy/wiki#unicode_not_nfc) | allow | using a unicode literal not in NFC normal form (see http://www.unicode.org/reports/tr15/ for further information)
151+
[unicode_not_nfc](https://github.com/Manishearth/rust-clippy/wiki#unicode_not_nfc) | allow | using a unicode literal not in NFC normal form (see [unicode tr15](http://www.unicode.org/reports/tr15/) for further information)
149152
[unit_cmp](https://github.com/Manishearth/rust-clippy/wiki#unit_cmp) | warn | comparing unit values (which is always `true` or `false`, respectively)
150153
[unnecessary_mut_passed](https://github.com/Manishearth/rust-clippy/wiki#unnecessary_mut_passed) | warn | an argument is passed as a mutable reference although the function/method only demands an immutable reference
151154
[unneeded_field_pattern](https://github.com/Manishearth/rust-clippy/wiki#unneeded_field_pattern) | warn | Struct fields are bound to a wildcard instead of using `..`
@@ -167,19 +170,25 @@ name
167170

168171
More to come, please [file an issue](https://github.com/Manishearth/rust-clippy/issues) if you have ideas!
169172

170-
##Usage
173+
## Usage
171174

172-
Compiler plugins are highly unstable and will only work with a nightly Rust for now. Since stable Rust is backwards compatible, you should be able to compile your stable programs with nightly Rust with clippy plugged in to circumvent this.
175+
Compiler plugins are highly unstable and will only work with a nightly Rust for now.
176+
Since stable Rust is backwards compatible, you should be able to compile
177+
your stable programs with nightly Rust with clippy plugged in to circumvent
178+
this.
173179

174180
Add in your `Cargo.toml`:
181+
175182
```toml
176183
[dependencies]
177184
clippy = "*"
178185
```
179186

180-
You then need to add `#![feature(plugin)]` and `#![plugin(clippy)]` to the top of your crate entry point (`main.rs` or `lib.rs`).
187+
You then need to add `#![feature(plugin)]` and `#![plugin(clippy)]` to the top
188+
of your crate entry point (`main.rs` or `lib.rs`).
181189

182190
Sample `main.rs`:
191+
183192
```rust
184193
#![feature(plugin)]
185194

@@ -196,7 +205,8 @@ fn main(){
196205
```
197206

198207
Produces this warning:
199-
```
208+
209+
```terminal
200210
src/main.rs:8:5: 11:6 warning: you seem to be trying to use match for destructuring a single type. Consider using `if let`, #[warn(single_match)] on by default
201211
src/main.rs:8 match x {
202212
src/main.rs:9 Some(y) => println!("{:?}", y),
@@ -206,29 +216,37 @@ src/main.rs:8:5: 11:6 help: Try
206216
if let Some(y) = x { println!("{:?}", y) }
207217
```
208218

209-
210-
An alternate way to use clippy is by compiling and using [`cargo clippy`](https://github.com/arcnmx/cargo-clippy), a custom cargo subcommand that runs clippy on a given project.
219+
An alternate way to use clippy is by compiling and using [`cargo clippy`](https://github.com/arcnmx/cargo-clippy),
220+
a custom cargo subcommand that runs clippy on a given project.
211221

212222
You can add options to `allow`/`warn`/`deny`:
213-
- the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy)]`)
214-
- all lints using both the `clippy` and `clippy_pedantic` lint groups (`#![deny(clippy)]`, `#![deny(clippy_pedantic)]`). Note that `clippy_pedantic` contains some very aggressive lints prone to false positives.
215-
- only some lints (`#![deny(single_match, box_vec)]`, etc)
216-
- `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc
223+
224+
* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy)]`)
225+
226+
* all lints using both the `clippy` and `clippy_pedantic` lint groups (`#![deny(clippy)]`,
227+
`#![deny(clippy_pedantic)]`). Note that `clippy_pedantic` contains some very aggressive
228+
lints prone to false positives.
229+
230+
* only some lints (`#![deny(single_match, box_vec)]`, etc)
231+
232+
* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc
217233

218234
Note: `deny` produces errors instead of warnings
219235

220236
To have cargo compile your crate with clippy without needing `#![plugin(clippy)]`
221237
in your code, you can use:
222238

223-
```
239+
```terminal
224240
cargo rustc -- -L /path/to/clippy_so -Z extra-plugins=clippy
225241
```
226242

227-
*[Note](https://github.com/Manishearth/rust-clippy/wiki#a-word-of-warning):* Be sure that clippy was compiled with the same version of rustc that cargo invokes here!
243+
*[Note](https://github.com/Manishearth/rust-clippy/wiki#a-word-of-warning):*
244+
Be sure that clippy was compiled with the same version of rustc that cargo invokes here!
228245

229246
If you want to make clippy an optional dependency, you can do the following:
230247

231248
In your `Cargo.toml`:
249+
232250
```toml
233251
[dependencies]
234252
clippy = {version = "*", optional = true}
@@ -245,9 +263,13 @@ And, in your `main.rs` or `lib.rs`:
245263
#![cfg_attr(feature="clippy", plugin(clippy))]
246264
```
247265

248-
Instead of adding the `cfg_attr` attributes you can also run clippy on demand: `cargo rustc --features clippy -- -Z no-trans -Z extra-plugins=clippy` (the `-Z no trans`, while not neccessary, will stop the compilation process after typechecking (and lints) have completed, which can significantly reduce the runtime).
266+
Instead of adding the `cfg_attr` attributes you can also run clippy on demand:
267+
`cargo rustc --features clippy -- -Z no-trans -Z extra-plugins=clippy`
268+
(the `-Z no trans`, while not neccessary, will stop the compilation process after
269+
typechecking (and lints) have completed, which can significantly reduce the runtime).
249270

250271
## Configuration
272+
251273
Some lints can be configured in a `clippy.toml` file. It contains basic `variable = value` mapping eg.
252274

253275
```toml
@@ -259,16 +281,21 @@ See the wiki for more information about which lints can be configured and the
259281
meaning of the variables.
260282

261283
You can also specify the path to the configuration file with:
284+
262285
```rust
263286
#![plugin(clippy(conf_file="path/to/clippy's/configuration"))]
264287
```
265288

266-
##Link with clippy service
289+
## Link with clippy service
290+
267291
`clippy-service` is a rust web initiative providing `rust-clippy` as a web service.
268292

269-
Both projects are independent and maintained by different people (even if some `clippy-service`'s contributions are authored by some `rust-clippy` members).
293+
Both projects are independent and maintained by different people
294+
(even if some `clippy-service`'s contributions are authored by some `rust-clippy` members).
270295

271296
You can check out this great service at [clippy.bashy.io](https://clippy.bashy.io/).
272297

273-
##License
274-
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.
298+
## License
299+
300+
Licensed under [MPL](https://www.mozilla.org/MPL/2.0/).
301+
If you're having issues with the license, let me know and I'll try to change it to something more permissive.

src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct EscapePass;
3131
/// }
3232
/// ```
3333
declare_lint! {
34-
pub BOXED_LOCAL, Warn, "using Box<T> where unnecessary"
34+
pub BOXED_LOCAL, Warn, "using `Box<T>` where unnecessary"
3535
}
3636

3737
fn is_non_trait_box(ty: ty::Ty) -> bool {

src/unicode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ declare_lint! {
4040
declare_lint! {
4141
pub UNICODE_NOT_NFC, Allow,
4242
"using a unicode literal not in NFC normal form (see \
43-
http://www.unicode.org/reports/tr15/ for further information)"
43+
[unicode tr15](http://www.unicode.org/reports/tr15/) for further information)"
4444
}
4545

4646

0 commit comments

Comments
 (0)