Repository: o0Ignition0o/cargo-scout (language: rust)

Issue:
pass --features to clippy
retrieve --features "foo bar baz" argument and pass it to clippy


A live stream on how to fix #11, which almost requires the same steps as fixing this issue is available here https://youtube.com/watch?v=vrCuCnHYep0 :)

If someone would like to work on it, please let me know and I'll do anything I can to ease the process 🎉 


Discussion / hints:
Hey, 
taking this one :-)
Hey \o/ help yourself  🎉 
If you have any questions please let me know :)

Fix patch:
diff --git a/cargo-scout-lib/src/linter/clippy.rs b/cargo-scout-lib/src/linter/clippy.rs
index 06d17b5..9c3d0b8 100644
--- a/cargo-scout-lib/src/linter/clippy.rs
+++ b/cargo-scout-lib/src/linter/clippy.rs
@@ -8,6 +8,7 @@ pub struct Clippy {
     verbose: bool,
     no_default_features: bool,
     all_features: bool,
+    features: Option<String>,
     preview: bool,
 }
 
@@ -38,6 +39,11 @@ impl Clippy {
         self
     }
 
+    pub fn set_features(&mut self, features: Option<String>) -> &mut Self {
+        self.features = features;
+        self
+    }
+
     pub fn set_preview(&mut self, preview: bool) -> &mut Self {
         self.preview = preview;
         self
@@ -65,6 +71,9 @@ impl Clippy {
         if self.all_features {
             params.push("--all-features");
         }
+        if let Some(features) = &self.features {
+            params.append(&mut vec!["--features", features]);
+        }
         params.append(&mut vec!["--", "-W", "clippy::pedantic"]);
         params
     }
@@ -187,7 +196,7 @@ mod tests {
         );
 
         let no_default_features_linter = linter.set_verbose(false).set_no_default_features(true);
-        let no_default_features_command_parameters = vec![
+        let no_default_features_expected_command_parameters = vec![
             "clippy",
             "--message-format",
             "json",
@@ -197,7 +206,7 @@ mod tests {
             "clippy::pedantic",
         ];
         assert_eq!(
-            no_default_features_command_parameters,
+            no_default_features_expected_command_parameters,
             no_default_features_linter.command_parameters()
         );
 
@@ -205,7 +214,7 @@ mod tests {
             .set_verbose(false)
             .set_no_default_features(false)
             .set_all_features(true);
-        let all_features_command_parameters = vec![
+        let all_features_expected_command_parameters = vec![
             "clippy",
             "--message-format",
             "json",
@@ -215,10 +224,28 @@ mod tests {
             "clippy::pedantic",
         ];
         assert_eq!(
-            all_features_command_parameters,
+            all_features_expected_command_parameters,
             all_features_linter.command_parameters()
         );
 
+        let features_linter = linter
+            .set_all_features(false)
+            .set_features(Some(String::from("foo bar baz")));
+        let features_expected_command_parameters = vec![
+            "clippy",
+            "--message-format",
+            "json",
+            "--features",
+            "foo bar baz",
+            "--",
+            "-W",
+            "clippy::pedantic",
+        ];
+        assert_eq!(
+            features_expected_command_parameters,
+            features_linter.command_parameters()
+        );
+
         let mut nightly_linter = Clippy::default();
         let nightly_linter = nightly_linter.set_preview(true);
         let expected_command_parameters = vec![
@@ -256,7 +283,7 @@ mod tests {
         );
 
         let nightly_all_features_linter = nightly_linter.set_verbose(false).set_all_features(true);
-        let all_features_command_nightly_parameters = vec![
+        let all_features_expected_command_nightly_parameters = vec![
             "+nightly",
             "clippy-preview",
             "-Z",
@@ -269,7 +296,7 @@ mod tests {
             "clippy::pedantic",
         ];
         assert_eq!(
-            all_features_command_nightly_parameters,
+            all_features_expected_command_nightly_parameters,
             nightly_all_features_linter.command_parameters()
         );
 
@@ -277,7 +304,7 @@ mod tests {
             .set_verbose(false)
             .set_all_features(false)
             .set_no_default_features(true);
-        let no_default_features_command_nightly_parameters = vec![
+        let no_default_features_expected_command_nightly_parameters = vec![
             "+nightly",
             "clippy-preview",
             "-Z",
@@ -290,9 +317,30 @@ mod tests {
             "clippy::pedantic",
         ];
         assert_eq!(
-            no_default_features_command_nightly_parameters,
+            no_default_features_expected_command_nightly_parameters,
             nightly_no_default_features_linter.command_parameters()
         );
+
+        let nightly_features_linter = nightly_linter
+            .set_no_default_features(false)
+            .set_features(Some(String::from("foo bar baz")));
+        let features_expected_command_nightly_parameters = vec![
+            "+nightly",
+            "clippy-preview",
+            "-Z",
+            "unstable-options",
+            "--message-format",
+            "json",
+            "--features",
+            "foo bar baz",
+            "--",
+            "-W",
+            "clippy::pedantic",
+        ];
+        assert_eq!(
+            features_expected_command_nightly_parameters,
+            nightly_features_linter.command_parameters()
+        );
     }
     #[test]
     fn test_lints() {
diff --git a/cargo-scout/src/main.rs b/cargo-scout/src/main.rs
index 0274300..266f820 100644
--- a/cargo-scout/src/main.rs
+++ b/cargo-scout/src/main.rs
@@ -22,6 +22,9 @@ struct Options {
     #[structopt(long = "all-features")]
     /// Pass the all features flag to clippy
     all_features: bool,
+    #[structopt(long = "features")]
+    /// Pass features to clippy
+    features: Option<String>,
     #[structopt(
         short = "b",
         long = "branch",
@@ -53,6 +56,7 @@ fn main() -> Result<(), Error> {
         .set_verbose(opts.verbose)
         .set_no_default_features(opts.no_default_features)
         .set_all_features(opts.all_features)
+        .set_features(opts.features)
         .set_preview(opts.preview);
 
     let scout = Scout::new(vcs, config, linter);


Test patch: