Skip to content

Conversation

@jonathanKingston
Copy link

The clippy changes were:

warning: returning the result of a let binding from a block. Consider returning the expression directly.                                                                                                    
  --> src/lib.rs:38:5                                                                                                                                                                                       
   |                                                                                                                                                                                                        
38 |     context                                                                                                                                                                                            
   |     ^^^^^^^                                                                                                                                                                                            
   |                                                                                                                                                                                                        
   = note: #[warn(clippy::let_and_return)] on by default                                                                                                                                                    
note: this expression can be directly returned                                                                                                                                                              
  --> src/lib.rs:30:19                                                                                                                                                                                      
   |                                                                                                                                                                                                        
30 |       let context = match Context::from_host_config(host_config, opt) {                                                                                                                                
   |  ___________________^                                                                                                                                                                                  
31 | |         Ok(context) => context,                                                                                                                                                                      
32 | |         Err(message) => {                                                                                                                                                                            
33 | |             eprintln!("error: {:?}", message.description());                                                                                                                                         
34 | |             exit(1);                                                                                                                                                                                 
35 | |         }                                                                                                                                                                                            
36 | |     };                                                                                                                                                                                               
   | |_____^                                                                                                                                                                                                
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#let_and_return                                                                                 
                                                                                                                                                                                                            
warning: this argument is passed by value, but not consumed in the function body                                                                                                                            
  --> src/cmd.rs:45:20                                                                                                                                                                                      
   |                                                                                                                                                                                                        
45 |     resource_type: FSResourceType,                                                                                                                                                                     
   |                    ^^^^^^^^^^^^^^                                                                                                                                                                      
   |                                                                                                                                                                                                        
   = note: #[warn(clippy::needless_pass_by_value)] on by default                                                                                                                                            
help: consider marking this type as Copy                                                                                                                                                                    
  --> src/cmd.rs:9:1                                                                                                                                                                                        
   |                                                                                                                                                                                                        
9  | / pub enum FSResourceType {                                                                                                                                                                            
10 | |     File,                                                                                                                                                                                            
11 | |     Directory,                                                                                                                                                                                       
12 | |     Symlink,                                                                                                                                                                                         
13 | | }                                                                                                                                                                                                    
   | |_^                                                                                                                                                                                                    
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#needless_pass_by_value                                                                         
help: consider taking a reference instead                                                                                                                                                                   
   |                                                                                                                                                                                                        
45 |     resource_type: &FSResourceType,                                                                                                                                                                    
46 | ) -> Result<bool, io::Error> {                                                                                                                                                                         
47 |     let type_key = *match resource_type {                                                                                                                                                              
48 |         FSResourceType::File => "f",                                                                                                                                                                   
49 |         FSResourceType::Directory => "d",                                                                                                                                                              
50 |         FSResourceType::Symlink => "L",                                                                                                                                                                
 ...                                                                                                                                                                                                        
                                                                                                                                                                                                            
warning: this argument is passed by value, but not consumed in the function body                                                                                                                            
  --> src/cmd.rs:64:17                                                                                                                                                                                      
   |                                                                                                                                                                                                        
64 |     sort_order: SortOrder,                                                                                                                                                                             
   |                 ^^^^^^^^^                                                                                                                                                                              
   |                                                                                                                                                                                                        
help: consider marking this type as Copy                                                                                                                                                                    
  --> src/cmd.rs:15:1                                                                                                                                                                                       
   |                                                                                                                                                                                                        
15 | / pub enum SortOrder {                                                                                                                                                                                 
16 | |     Asc,                                                                                                                                                                                             
17 | |     Des,                                                                                                                                                                                             
18 | | }                                                                                                                                                                                                    
   | |_^                                                                                                                                                                                                    
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#needless_pass_by_value                                                                         
help: consider taking a reference instead                                                                                                                                                                   
   |                                                                                                                                                                                                        
64 |     sort_order: &SortOrder,                                                                                                                                                                            
65 | ) -> Result<Vec<String>, io::Error> {                                                                                                                                                                  
66 |     let sort_cmd = *match sort_order {                                                                                                                                                                 
67 |         SortOrder::Asc => "sort",                                                                                                                                                                      
68 |         SortOrder::Des => "sort -r",                                                                                                                                                                   
69 |     };                                                                                                                                                                                                 
 ...                                                                                                                                                                                                        
                                                                                                                                                                                                            
warning: redundant closure found                                                                                                                                                                            
  --> src/cmd.rs:81:14                                                                                                                                                                                      
   |                                                                                                                                                                                                        
81 |         .map(|x| String::from(x))                                                                                                                                                                      
   |              ^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `String::from`                                                                                                                         
   |                                                                                                                                                                                                        
   = note: #[warn(clippy::redundant_closure)] on by default                                                                                                                                                 
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#redundant_closure                                                                              
                                                                                                                                                                                                            
warning: single-character string constant used as pattern                                                                                                                                                   
  --> src/cmd.rs:80:16                                                                                                                                                                                      
   |                                                                                                                                                                                                        
80 |         .split("\n")                                                                                                                                                                                   
   |                ^^^^ help: try using a char instead: `'\n'`                                                                                                                                             
   |                                                                                                                                                                                                        
   = note: #[warn(clippy::single_char_pattern)] on by default                                                                                                                                               
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#single_char_pattern                                                                            
                                                                                                                                                                                                            
warning: use of `unwrap_or` followed by a call to `new`                                                                                                                                                     
  --> src/config/stages/mod.rs:57:21                                                                                                                                                                        
   |                                                                                                                                                                                                        
57 |         link_files: parse_string_vector("linked-files", &config_map).unwrap_or(Vec::new()),                                                                                                            
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `parse_string_vector("linked-files", &config_map).unwrap_or_default()`                      
   |                                                                                                                                                                                                        
   = note: #[warn(clippy::or_fun_call)] on by default                                                                                                                                                       
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call                                                                                    
                                                                                                                                                                                                            
warning: use of `unwrap_or` followed by a call to `new`                                                                                                                                                     
  --> src/config/stages/mod.rs:58:20                                                                                                                                                                        
   |                                                                                                                                                                                                        
58 |         link_dirs: parse_string_vector("linked-dirs", &config_map).unwrap_or(Vec::new()),                                                                                                              
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `parse_string_vector("linked-dirs", &config_map).unwrap_or_default()`                         
   |                                                                                                                                                                                                        
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call                                                                                    
                                                                                                                                                                                                            
warning: use of `ok_or` followed by a function call                                                                                                                                                         
  --> src/config/steps/mod.rs:74:10                                                                                                                                                                         
   |                                                                                                                                                                                                        
74 |         .ok_or(BadType("name".into(), "string".into()))?                                                                                                                                               
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| BadType("name".into(), "string".into()))`                                                                       
   |                                                                                                                                                                                                        
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call                                                                                    
                                                                                                                                                                                                            
warning: use of `ok_or` followed by a function call                                                                                                                                                         
  --> src/config/steps/mod.rs:72:10                                                                                                                                                                         
   |                                                                                                                                                                                                        
72 |         .ok_or(MissingField("name".into()))?                                                                                                                                                           
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| MissingField("name".into()))`                                                                                               
   |                                                                                                                                                                                                        
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call                                                                                    
                                                                                                                                                                                                            
warning: use of `ok_or` followed by a function call                                                                                                                                                         
  --> src/config/steps/mod.rs:81:10                                                                                                                                                                         
   |                                                                                                                                                                                                        
81 |         .ok_or(BadType("command".into(), "string".into()))?                                                                                                                                            
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| BadType("command".into(), "string".into()))`                                                                 
   |                                                                                                                                                                                                        
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call                                                                                    
                                                                                                                                                                                                            
warning: use of `ok_or` followed by a function call                                                                                                                                                         
  --> src/config/steps/mod.rs:79:10                                                                                                                                                                         
   |                                                                                                                                                                                                        
79 |         .ok_or(MissingField("command".into()))?                                                                                                                                                        
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| MissingField("command".into()))`                                                                                         
   |                                                                                                                                                                                                        
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call                                                                                    
                                                                                                                                                                                                            
warning: use of `ok_or` followed by a function call                                                                                                                                                         
  --> src/config/steps/mod.rs:93:14                                                                                                                                                                         
   |                                                                                                                                                                                                        
93 |             .ok_or(BadType("before".into(), "string".into()))?                                                                                                                                         
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| BadType("before".into(), "string".into()))`                                                               
   |                                                                                                                                                                                                        
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call                                                                                    
                                                                                                                                                                                                            
warning: use of `ok_or` followed by a function call                                                                                                                                                         
   --> src/config/steps/mod.rs:101:14                                                                                                                                                                       
    |                                                                                                                                                                                                       
101 |             .ok_or(BadType("after".into(), "string".into()))?                                                                                                                                         
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| BadType("after".into(), "string".into()))`                                                                
    |                                                                                                                                                                                                       
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call                                                                                   
                                                                                                                                                                                                            
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.                                                                                      
  --> src/recipe/deployer.rs:32:25                                                                                                                                                                          
   |                                                                                                                                                                                                        
32 | fn execute_steps(steps: &Vec<Box<dyn Step>>, context: &Context) -> Result<(), String> {                                                                                                                
   |                         ^^^^^^^^^^^^^^^^^^^ help: change this to: `&[Box<dyn Step>]`                                                                                                                   
   |                                                                                                                                                                                                        
   = note: #[warn(clippy::ptr_arg)] on by default                                                                                                                                                           
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#ptr_arg                                                                                        
                                                                                                                                                                                                            
warning: useless use of `format!`                                                                                                                                                                           
  --> src/recipe/deployer.rs:44:35                                                                                                                                                                          
   |                                                                                                                                                                                                        
44 |                     render_error(&format!("Non-critical error, continuing"))                                                                                                                           
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"Non-critical error, continuing".to_string()`                                          
   |                                                                                                                                                                                                        
   = note: #[warn(clippy::useless_format)] on by default                                                                                                                                                    
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#useless_format                                                                                 
                                                                                                                                                                                                            
warning: the variable `index` is used as a loop counter. Consider using `for (index, item) in &self.steps.enumerate()` or similar iterators                                                                 
  --> src/recipe/mod.rs:24:21                                                                                                                                                                               
   |                                                                                                                                                                                                        
24 |         for step in &self.steps {                                                                                                                                                                      
   |                     ^^^^^^^^^^^                                                                                                                                                                        
   |                                                                                                                                                                                                        
   = note: #[warn(clippy::explicit_counter_loop)] on by default                                                                                                                                             
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#explicit_counter_loop                                                                          
                                                                                                                                                                                                            
warning: use of `expect` followed by a function call                                                                                                                                                        
   --> src/recipe/mod.rs:103:22                                                                                                                                                                             
    |                                                                                                                                                                                                       
103 |                       .expect(&format!(                                                                                                                                                               
    |  ______________________^                                                                                                                                                                              
104 | |                         "Step '{}' doesn't exist in the recipe",                                                                                                                                    
105 | |                         &step_config.ref_step                                                                                                                                                       
106 | |                     ));                                                                                                                                                                             
    | |______________________^ help: try this: `unwrap_or_else(|| panic!("Step '{}' doesn't exist in the recipe", &step_config.ref_step))`                                                                  
    |                                                                                                                                                                                                       
    = note: #[warn(clippy::expect_fun_call)] on by default                                                                                                                                                  
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#expect_fun_call                                                                               
                                                                                                                                                                                                            
warning: use of `expect` followed by a function call                                                                                                                                                        
   --> src/recipe/mod.rs:132:18                                                                                                                                                                             
    |                                                                                                                                                                                                       
132 |                   .expect(&format!(                                                                                                                                                                   
    |  __________________^                                                                                                                                                                                  
133 | |                     "Step '{}' doesn't exist in the recipe",                                                                                                                                        
134 | |                     subject_name                                                                                                                                                                    
135 | |                 ));                                                                                                                                                                                 
    | |__________________^ help: try this: `unwrap_or_else(|| panic!("Step '{}' doesn't exist in the recipe", subject_name))`                                                                               
    |                                                                                                                                                                                                       
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#expect_fun_call                                                                               
                                                                                                                                                                                                            
warning: use of `expect` followed by a function call                                                                                                                                                        
   --> src/recipe/mod.rs:158:18                                                                                                                                                                             
    |                                                                                                                                                                                                       
158 |                   .expect(&format!(                                                                                                                                                                   
    |  __________________^                                                                                                                                                                                  
159 | |                     "Step '{}' doesn't exist in the recipe",                                                                                                                                        
160 | |                     subject_name                                                                                                                                                                    
161 | |                 ));                                                                                                                                                                                 
    | |__________________^ help: try this: `unwrap_or_else(|| panic!("Step '{}' doesn't exist in the recipe", subject_name))`                                                                               
    |                                                                                                                                                                                                       
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#expect_fun_call                                                                               
                                                                                                                                                                                                            
warning: redundant closure found                                                                                                                                                                            
   --> src/steps/core.rs:218:19                                                                                                                                                                             
    |                                                                                                                                                                                                       
218 |         ).map_err(|e| StepError::non_critical_from_error(e))?;                                                                                                                                        
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `StepError::non_critical_from_error`                                                                       
    |                                                                                                                                                                                                       
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#redundant_closure                                                                             
                                                                                                                                                                                                            
warning: this argument is passed by value, but not consumed in the function body                                                                                                                            
  --> src/steps/error.rs:25:53                                                                                                                                                                              
   |                                                                                                                                                                                                        
25 |     pub fn non_critical_from_error<E: Error>(error: E) -> Self {                                                                                                                                       
   |                                                     ^ help: consider taking a reference instead: `&E`                                                                                                  
   |                                                                                                                                                                                                        
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#needless_pass_by_value                                                                         
                                                                                                                                                                                                            
warning: use of `ok_or` followed by a function call                                                                                                                                                         
  --> src/steps/rollback.rs:17:14                                                                                                                                                                           
   |                                                                                                                                                                                                        
17 |             .ok_or(StepError::Critical(NO_PREV_ERR_MSG.into()))                                                                                                                                        
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| StepError::Critical(NO_PREV_ERR_MSG.into()))`                                                           
   |                                                                                                                                                                                                        
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call                                                                                    
                                                                                                                                                                                                            
warning: you seem to be trying to match on a boolean expression                                                                                                                                             
  --> src/steps/rollback.rs:38:9                                                                                                                                                                            
   |                                                                                                                                                                                                        
38 | /         match output.status.success() {                                                                                                                                                              
39 | |             true => Ok(()),                                                                                                                                                                          
40 | |             false => {                                                                                                                                                                               
41 | |                 let err_msg = format!("Failed to remove current release at {}", release_path);                                                                                                       
42 | |                 Err(StepError::Critical(err_msg))                                                                                                                                                    
43 | |             }                                                                                                                                                                                        
44 | |         }                                                                                                                                                                                            
   | |_________^                                                                                                                                                                                            
   |                                                                                                                                                                                                        
   = note: #[warn(clippy::match_bool)] on by default                                                                                                                                                        
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#match_bool                                                                                     
help: consider using an if/else expression                                                                                                                                                                  
   |                                                                                                                                                                                                        
38 |         if output.status.success() { Ok(()) } else {                                                                                                                                                   
39 |     let err_msg = format!("Failed to remove current release at {}", release_path);                                                                                                                     
40 |     Err(StepError::Critical(err_msg))                                                                                                                                                                  
41 | }                                                                                                                                                                                                      
   |                                                                                                                                                                                                        
                                                                                                                                                                                                            
warning: this argument is passed by value, but not consumed in the function body                                                                                                                            
  --> src/steps/mod.rs:22:54                                                                                                                                                                                
   |                                                                                                                                                                                                        
22 |     pub fn from_host_config(config: HostConfig, opt: Operation) -> Result<Context, Error> {                                                                                                            
   |                                                      ^^^^^^^^^                                                                                                                                         
   |                                                                                                                                                                                                        
help: consider marking this type as Copy                                                                                                                                                                    
  --> src/lib.rs:16:1                                                                                                                                                                                       
   |                                                                                                                                                                                                        
16 | / pub enum Operation {                                                                                                                                                                                 
17 | |     Deploy,                                                                                                                                                                                          
18 | |     Rollback,                                                                                                                                                                                        
19 | | }                                                                                                                                                                                                    
   | |_^                                                                                                                                                                                                    
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#needless_pass_by_value                                                                         
help: consider taking a reference instead                                                                                                                                                                   
   |                                                                                                                                                                                                        
22 |     pub fn from_host_config(config: HostConfig, opt: &Operation) -> Result<Context, Error> {                                                                                                           
23 |         match *opt {                                                                                                                                                                                   
   |                                                                                                                                                                                                        
                                                                                                                                                                                                            
warning: Constants have by default a `'static` lifetime                                                                                                                                                     
 --> src/main.rs:9:15                                                                                                                                                                                       
  |                                                                                                                                                                                                         
9 | const USAGE: &'static str = "                                                                                                                                                                           
  |              -^^^^^^^---- help: consider removing `'static`: `&str`                                                                                                                                     
  |                                                                                                                                                                                                         
  = note: #[warn(clippy::const_static_lifetime)] on by default                                                                                                                                              
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#const_static_lifetime                                      

Looks like the code will work in the 2018 edition too cargo fix makes no changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant