]> git.lizzy.rs Git - rust.git/commitdiff
Add environment variable to deactivate wiki links
authormcarton <cartonmartin+git@gmail.com>
Sun, 5 Jun 2016 19:05:28 +0000 (21:05 +0200)
committermcarton <cartonmartin+git@gmail.com>
Sun, 5 Jun 2016 20:03:02 +0000 (22:03 +0200)
CHANGELOG.md
README.md
clippy_lints/src/utils/mod.rs
tests/compile-fail/booleans.rs
tests/compile-fail/non_expressive_names.rs
tests/compile-test.rs

index 166990b3d3b925a98bc78efdb325cb711196d0c3..51bf4ad2c15c3a6ba038da678ac04ff9ae4e1d30 100644 (file)
@@ -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`]
 
index 3b5b6768c237eeff205fd3c75fcb71c53ca52229..8f699d2f74174b715e29551fc7f779206f6602b1 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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.
index 986462b37237b9045fa8056cb4022517b279e2eb..beec30b32de57062c7028690b8e2a5dafdbb9599 100644 (file)
@@ -10,6 +10,7 @@
 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,8 +474,10 @@ fn deref(&self) -> &DiagnosticBuilder<'a> {
 
 impl<'a> DiagnosticWrapper<'a> {
     fn wiki_link(&mut self, lint: &'static Lint) {
-        self.help(&format!("for further information visit https://github.com/Manishearth/rust-clippy/wiki#{}",
-                           lint.name_lower()));
+        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()));
+        }
     }
 }
 
index aba55f0b8b486f3dc73edf5aae1075a6030e1016..fc220d1ac22279dba26b796c2f7747d9d3d760a3 100644 (file)
@@ -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);
index d959507bcb2b002584e05cc7831e44bf49c22a26..212dc2a96d5058c6b0ea7337605936e08339220d 100644 (file)
@@ -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!(""),
index 66c5734cc11294150662adc3069601030bdaf7f8..42a7dd96ae293ae738b7f1999002e2228a8447f7 100644 (file)
@@ -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");
 }