Repository: Canop/bacon (language: rust)

Issue:
Difference between how cargo clippy and bacon clippy treat tests
When running ``cargo clippy``, by default, anything behind a ``#[cfg(test)]`` or in the ``tests`` directory will be ignored. ``bacon clippy`` doesn't seem to behave like this - instead, it will run the same lints on the tests too as it always passes the ``--all-targets`` option.

Expected behaviour (at least for me) would be that calling ``bacon clippy`` without further options behaves the same as ``cargo clippy`` does when called without options, and having it run with ``--all-targets`` would either be a custom job or a command line option.


Discussion / hints:
It's possible to overload the clippy job provided with bacon.

This being said, it seems reasonable to expect the default bacon clippy job to be made of the the default cargo clippy command.

I'll welcome other opinions before modifying the default jobs (or not).

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 65fd891..939167c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,5 @@
 ### next
+- default binding for 'c' in bacon.toml is now the new 'clippy-all' job which does what the old 'clippy' job was doing. 'clippy' job changed to not run on all targets. Default bacon.toml explain how to bind 'c' to clippy instead of 'clippy-all' - Fix #167
 - expand env vars in job command unless the job specifies `expand_env_vars = false` - Fix #181
 
 <a name="v2.16.0"></a>
diff --git a/bacon.toml b/bacon.toml
index 5243f54..38f61c6 100644
--- a/bacon.toml
+++ b/bacon.toml
@@ -44,7 +44,7 @@ command = ["cargo", "doc", "--color", "always", "--no-deps", "--open"]
 need_stdout = false
 on_success = "back" # so that we don't open the browser at each change
 
-[jobs.clippy]
+[jobs.clippy-all]
 command = [
 	"cargo", "clippy",
 	"--color", "always",
@@ -59,3 +59,5 @@ command = [
 ]
 need_stdout = false
 
+[keybindings]
+c = "job:clippy-all"
diff --git a/defaults/default-bacon.toml b/defaults/default-bacon.toml
index c3da77c..f70da24 100644
--- a/defaults/default-bacon.toml
+++ b/defaults/default-bacon.toml
@@ -15,7 +15,28 @@ need_stdout = false
 command = ["cargo", "check", "--all-targets", "--color", "always"]
 need_stdout = false
 
+# Run clippy on the default target
 [jobs.clippy]
+command = [
+    "cargo", "clippy",
+    "--color", "always",
+]
+need_stdout = false
+
+# Run clippy on all targets
+# To disable some lints, you may change the job this way:
+#    [jobs.clippy-all]
+#    command = [
+#        "cargo", "clippy",
+#        "--all-targets",
+#        "--color", "always",
+#    	 "--",
+#    	 "-A", "clippy::bool_to_int_with_if",
+#    	 "-A", "clippy::collapsible_if",
+#    	 "-A", "clippy::derive_partial_eq_without_eq",
+#    ]
+# need_stdout = false
+[jobs.clippy-all]
 command = [
     "cargo", "clippy",
     "--all-targets",
@@ -77,3 +98,4 @@ allow_warnings = true
 # should go in your personal global prefs.toml file instead.
 [keybindings]
 # alt-m = "job:my-job"
+c = "job:clippy-all" # comment this to have 'c' run clippy on only the default target
diff --git a/defaults/default-prefs.toml b/defaults/default-prefs.toml
index 218543a..465fef5 100644
--- a/defaults/default-prefs.toml
+++ b/defaults/default-prefs.toml
@@ -60,6 +60,7 @@ line_format = "{kind} {path}:{line}:{column} {message}"
 # a = "job:check-all"
 # i = "job:initial"
 # c = "job:clippy"
+# c = "job:clippy-all"
 # d = "job:doc-open"
 # t = "job:test"
 # r = "job:run"
diff --git a/src/app.rs b/src/app.rs
index d90f6ef..4c99d61 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -42,7 +42,9 @@ pub fn run(
                     EventKind::Modify(ModifyKind::Data(_)) => {}
                     EventKind::Create(_) => {} // just in case, not sure useful in Rust
                     EventKind::Remove(_) => {} // just in case, not sure useful in Rust
-                    _ => {}                    // useless event
+                    _ => {
+                        return; // useless event
+                    }
                 }
                 if let Some(ignorer) = ignorer.as_mut() {
                     match time!(Info, ignorer.excludes_all(&we.paths)) {


Test patch: