mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-22 20:53:21 +00:00
Add environment variable to deactivate wiki links
This commit is contained in:
parent
24dc8377df
commit
a7a6c0461d
6 changed files with 27 additions and 27 deletions
|
@ -1,6 +1,10 @@
|
|||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 0.0.74 — TBR
|
||||
* Add the `CLIPPY_DISABLE_WIKI_LINKS` environment variable to deactivate the
|
||||
“for further information visit *wiki-link*” message.
|
||||
|
||||
## 0.0.73 — 2016-06-05
|
||||
* Fix false positives in [`useless_let_if_seq`]
|
||||
|
||||
|
|
|
@ -318,6 +318,9 @@ You can also specify the path to the configuration file with:
|
|||
#![plugin(clippy(conf_file="path/to/clippy's/configuration"))]
|
||||
```
|
||||
|
||||
To deactivate the “for further information visit *wiki-link*” message you can
|
||||
define the `CLIPPY_DISABLE_WIKI_LINKS` environment variable.
|
||||
|
||||
## Link with clippy service
|
||||
|
||||
`clippy-service` is a rust web initiative providing `rust-clippy` as a web service.
|
||||
|
|
|
@ -10,6 +10,7 @@ use rustc::traits;
|
|||
use rustc::ty::subst::Subst;
|
||||
use rustc::ty;
|
||||
use std::borrow::Cow;
|
||||
use std::env;
|
||||
use std::mem;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::str::FromStr;
|
||||
|
@ -473,9 +474,11 @@ impl<'a> Deref for DiagnosticWrapper<'a> {
|
|||
|
||||
impl<'a> DiagnosticWrapper<'a> {
|
||||
fn wiki_link(&mut self, lint: &'static Lint) {
|
||||
if env::var("CLIPPY_DISABLE_WIKI_LINKS").is_err() {
|
||||
self.help(&format!("for further information visit https://github.com/Manishearth/rust-clippy/wiki#{}",
|
||||
lint.name_lower()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn span_lint<'a, T: LintContext>(cx: &'a T, lint: &'static Lint, sp: Span, msg: &str) -> DiagnosticWrapper<'a> {
|
||||
|
|
|
@ -10,29 +10,27 @@ fn main() {
|
|||
let d: bool = unimplemented!();
|
||||
let e: bool = unimplemented!();
|
||||
let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP for further information visit
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = a;
|
||||
let _ = !(a && b);
|
||||
let _ = !true; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP for further information visit
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = false;
|
||||
let _ = !false; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP for further information visit
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = true;
|
||||
let _ = !!a; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP for further information visit
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = a;
|
||||
|
||||
let _ = false && a; //~ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP for further information visit
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = false;
|
||||
|
||||
let _ = false || a; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP for further information visit
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = a;
|
||||
|
||||
// don't lint on cfgs
|
||||
|
@ -43,7 +41,7 @@ fn main() {
|
|||
let _ = !(a && b || c);
|
||||
|
||||
let _ = !(!a && b); //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP for further information visit
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = !b || a;
|
||||
}
|
||||
|
||||
|
@ -55,32 +53,29 @@ fn equality_stuff() {
|
|||
let d: i32 = unimplemented!();
|
||||
let e: i32 = unimplemented!();
|
||||
let _ = a == b && a != b; //~ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP for further information visit
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = false;
|
||||
let _ = a == b && c == 5 && a == b; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP for further information visit
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = a == b && c == 5;
|
||||
let _ = a == b && c == 5 && b == a; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP for further information visit
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = a == b && c == 5;
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = !(c != 5 || a != b);
|
||||
let _ = a < b && a >= b; //~ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP for further information visit
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = false;
|
||||
let _ = a > b && a <= b; //~ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP for further information visit
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = false;
|
||||
let _ = a > b && a == b;
|
||||
|
||||
let _ = a != b || !(a != b || c == d); //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP for further information visit
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = c != d || a != b;
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = !(a == b && c == d);
|
||||
|
|
|
@ -28,10 +28,8 @@ fn main() {
|
|||
//~^ NOTE: existing binding defined here
|
||||
let bpple: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: separate the discriminating character by an underscore like: `b_pple`
|
||||
//~| HELP: for further information visit
|
||||
let cpple: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: separate the discriminating character by an underscore like: `c_pple`
|
||||
//~| HELP: for further information visit
|
||||
|
||||
let a_bar: i32;
|
||||
let b_bar: i32;
|
||||
|
@ -56,13 +54,11 @@ fn main() {
|
|||
|
||||
let blubx: i32; //~ NOTE: existing binding defined here
|
||||
let bluby: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: for further information visit
|
||||
//~| HELP: separate the discriminating character by an underscore like: `blub_y`
|
||||
|
||||
let cake: i32; //~ NOTE: existing binding defined here
|
||||
let cakes: i32;
|
||||
let coke: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: for further information visit
|
||||
|
||||
match 5 {
|
||||
cheese @ 1 => {},
|
||||
|
@ -81,12 +77,10 @@ fn main() {
|
|||
let xyz1abc: i32; //~ NOTE: existing binding defined here
|
||||
let xyz2abc: i32;
|
||||
let xyzeabc: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: for further information visit
|
||||
|
||||
let parser: i32; //~ NOTE: existing binding defined here
|
||||
let parsed: i32;
|
||||
let parsee: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: for further information visit
|
||||
//~| HELP: separate the discriminating character by an underscore like: `parse_e`
|
||||
|
||||
let setter: i32;
|
||||
|
@ -101,7 +95,6 @@ fn foo() {
|
|||
let Foo { apple, bpple } = unimplemented!();
|
||||
let Foo { apple: spring, //~NOTE existing binding defined here
|
||||
bpple: sprang } = unimplemented!(); //~ ERROR: name is too similar
|
||||
//~^HELP for further information
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -136,18 +129,14 @@ fn bla() {
|
|||
}
|
||||
{
|
||||
let e: i32; //~ ERROR: 5th binding whose name is just one char
|
||||
//~| HELP: for further information visit
|
||||
}
|
||||
{
|
||||
let e: i32; //~ ERROR: 5th binding whose name is just one char
|
||||
//~| HELP: for further information visit
|
||||
let f: i32; //~ ERROR: 6th binding whose name is just one char
|
||||
//~| HELP: for further information visit
|
||||
}
|
||||
match 5 {
|
||||
1 => println!(""),
|
||||
e => panic!(), //~ ERROR: 5th binding whose name is just one char
|
||||
//~| HELP: for further information visit
|
||||
}
|
||||
match 5 {
|
||||
1 => println!(""),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
extern crate compiletest_rs as compiletest;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::env::{var, temp_dir};
|
||||
use std::env::{set_var, var, temp_dir};
|
||||
|
||||
fn run_mode(dir: &'static str, mode: &'static str) {
|
||||
let mut config = compiletest::default_config();
|
||||
|
@ -23,9 +23,14 @@ fn run_mode(dir: &'static str, mode: &'static str) {
|
|||
compiletest::run_tests(&config);
|
||||
}
|
||||
|
||||
fn prepare_env() {
|
||||
set_var("CLIPPY_DISABLE_WIKI_LINKS", "true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "test-regex_macros"))]
|
||||
fn compile_test() {
|
||||
prepare_env();
|
||||
run_mode("run-pass", "run-pass");
|
||||
run_mode("compile-fail", "compile-fail");
|
||||
}
|
||||
|
@ -33,6 +38,7 @@ fn compile_test() {
|
|||
#[test]
|
||||
#[cfg(feature = "test-regex_macros")]
|
||||
fn compile_test() {
|
||||
prepare_env();
|
||||
run_mode("run-pass-regex_macros", "run-pass");
|
||||
run_mode("compile-fail-regex_macros", "compile-fail");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue