Optimize RootAsRole sr program #70
clippy
87 warnings
Details
Results
| Message level | Amount |
|---|---|
| Internal compiler error | 0 |
| Error | 0 |
| Warning | 87 |
| Note | 0 |
| Help | 0 |
Versions
- rustc 1.87.0 (17067e9ac 2025-05-09)
- cargo 1.87.0 (99624be96 2025-05-06)
- clippy 0.1.87 (17067e9ac6 2025-05-09)
Annotations
Check warning on line 317 in src/sr/main.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> src/sr/main.rs:309:5
|
309 | / return Cred::builder()
310 | | .maybe_tty(stat::fstat(stdout().as_raw_fd()).ok().and_then(|s| {
311 | | if isatty(stdout().as_raw_fd()).ok().unwrap_or(false) {
312 | | Some(s.st_rdev)
... |
316 | | }))
317 | | .build();
| |________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
309 ~ Cred::builder()
310 + .maybe_tty(stat::fstat(stdout().as_raw_fd()).ok().and_then(|s| {
311 + if isatty(stdout().as_raw_fd()).ok().unwrap_or(false) {
312 + Some(s.st_rdev)
313 + } else {
314 + None
315 + }
316 + }))
317 ~ .build()
|
Check warning on line 154 in src/sr/main.rs
github-actions / clippy
useless conversion to the same type: `std::option::Option<rootasrole_core::database::actor::SGroups>`
warning: useless conversion to the same type: `std::option::Option<rootasrole_core::database::actor::SGroups>`
--> src/sr/main.rs:144:25
|
144 | group = iter
| _________________________^
145 | | .next()
146 | | .map(|s| {
147 | | SGroups::Multiple(
... |
153 | | })
154 | | .into();
| |___________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
help: consider removing `.into()`
|
144 ~ group = iter
145 + .next()
146 + .map(|s| {
147 + SGroups::Multiple(
148 + s.as_ref()
149 + .split(',')
150 + .map(|g| g.into())
151 + .collect::<Vec<SGroupType>>(),
152 + )
153 ~ });
|
Check warning on line 141 in src/sr/pam/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/pam/mod.rs:141:40
|
141 | timeout::update_cookie(user, user, &timeout)?;
| ^^^^^^^^ help: change this to: `timeout`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 132 in src/sr/pam/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/pam/mod.rs:132:50
|
132 | let is_valid = timeout::is_valid(user, user, &timeout);
| ^^^^^^^^ help: change this to: `timeout`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 82 in src/sr/pam/rpassword.rs
github-actions / clippy
calling .bytes() is very inefficient when data is not in memory
warning: calling .bytes() is very inefficient when data is not in memory
--> src/sr/pam/rpassword.rs:82:17
|
82 | let input = source.bytes().take_while(|x| x.as_ref().ok() != Some(&EOL));
| ^^^^^^^^^^^^^^
|
= help: consider using `BufReader`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unbuffered_bytes
= note: `#[warn(clippy::unbuffered_bytes)]` on by default
Check warning on line 237 in src/sr/finder/mod.rs
github-actions / clippy
using `clone` on type `Option<CapSet>` which implements the `Copy` trait
warning: using `clone` on type `Option<CapSet>` which implements the `Copy` trait
--> src/sr/finder/mod.rs:237:25
|
237 | self.caps = data.caps.clone();
| ^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `data.caps`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
= note: `#[warn(clippy::clone_on_copy)]` on by default
Check warning on line 236 in src/sr/finder/mod.rs
github-actions / clippy
using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
--> src/sr/finder/mod.rs:233:30
|
233 | self.setgroups = data.setgroups.clone().and_then(|g| match g {
| ______________________________^
234 | | DGroups::Single(g) => Some(vec![g.fetch_id()].into_iter().flatten().collect()),
235 | | DGroups::Multiple(g) => Some(g.iter().filter_map(|g| g.fetch_id()).collect()),
236 | | });
| |______________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map
= note: `#[warn(clippy::bind_instead_of_map)]` on by default
help: use `map` instead
|
233 ~ self.setgroups = data.setgroups.clone().map(|g| match g {
234 ~ DGroups::Single(g) => vec![g.fetch_id()].into_iter().flatten().collect(),
235 ~ DGroups::Multiple(g) => g.iter().filter_map(|g| g.fetch_id()).collect(),
|
Check warning on line 232 in src/sr/finder/mod.rs
github-actions / clippy
called `map(..).flatten()` on `Option`
warning: called `map(..).flatten()` on `Option`
--> src/sr/finder/mod.rs:232:47
|
232 | self.setuid = data.setuid.clone().map(|u| u.fetch_id()).flatten();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|u| u.fetch_id())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
Check warning on line 220 in src/sr/finder/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/finder/mod.rs:220:19
|
220 | &cli, &data, opt_stack, self, &mut score,
| ^^^^^ help: change this to: `data`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 220 in src/sr/finder/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/finder/mod.rs:220:13
|
220 | &cli, &data, opt_stack, self, &mut score,
| ^^^^ help: change this to: `cli`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 103 in src/sr/finder/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/finder/mod.rs:103:17
|
103 | &env_path,
| ^^^^^^^^^ help: change this to: `env_path`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 84 in src/sr/finder/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/finder/mod.rs:84:17
|
84 | &env_path,
| ^^^^^^^^^ help: change this to: `env_path`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 748 in src/sr/finder/options.rs
github-actions / clippy
unnecessarily eager cloning of iterator items
warning: unnecessarily eager cloning of iterator items
--> src/sr/finder/options.rs:745:17
|
745 | / o.check
746 | | .iter()
| | ____________________________-
747 | || .cloned()
748 | || .filter(|p| is_valid_env_name(p.as_ref()) || is_regex(p.as_ref()))
| ||______________________________________________________________________________________^
| |______________________________________________________________________________________|
| help: try: `.filter(|&p| is_valid_env_name(p.as_ref()) || is_regex(p.as_ref())).cloned()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_overeager_cloned
Check warning on line 741 in src/sr/finder/options.rs
github-actions / clippy
unnecessarily eager cloning of iterator items
warning: unnecessarily eager cloning of iterator items
--> src/sr/finder/options.rs:738:17
|
738 | / o.delete
739 | | .iter()
| | ____________________________-
740 | || .cloned()
741 | || .filter(|p| is_valid_env_name(p.as_ref()) || is_regex(p.as_ref()))
| ||______________________________________________________________________________________^
| |______________________________________________________________________________________|
| help: try: `.filter(|&p| is_valid_env_name(p.as_ref()) || is_regex(p.as_ref())).cloned()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_overeager_cloned
Check warning on line 734 in src/sr/finder/options.rs
github-actions / clippy
unnecessarily eager cloning of iterator items
warning: unnecessarily eager cloning of iterator items
--> src/sr/finder/options.rs:731:17
|
731 | / o.keep
732 | | .iter()
| | ____________________________-
733 | || .cloned()
734 | || .filter(|p| is_valid_env_name(p.as_ref()) || is_regex(p.as_ref()))
| ||______________________________________________________________________________________^
| |______________________________________________________________________________________|
| help: try: `.filter(|&p| is_valid_env_name(p.as_ref()) || is_regex(p.as_ref())).cloned()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_overeager_cloned
= note: `#[warn(clippy::iter_overeager_cloned)]` on by default
Check warning on line 713 in src/sr/finder/options.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/finder/options.rs:713:17
|
713 | &opt_filter,
| ^^^^^^^^^^^ help: change this to: `opt_filter`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 712 in src/sr/finder/options.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/finder/options.rs:712:17
|
712 | &override_behavior,
| ^^^^^^^^^^^^^^^^^^ help: change this to: `override_behavior`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 670 in src/sr/finder/options.rs
github-actions / clippy
this lifetime isn't used in the function definition
warning: this lifetime isn't used in the function definition
--> src/sr/finder/options.rs:670:37
|
670 | fn determine_final_behavior<'a>(
| ^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
Check warning on line 528 in src/sr/finder/options.rs
github-actions / clippy
this lifetime isn't used in the impl
warning: this lifetime isn't used in the impl
--> src/sr/finder/options.rs:528:10
|
528 | impl<'a, 'b, 'c, 't> BorrowedOptStack<'a> {
| ^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
= note: `#[warn(clippy::extra_unused_lifetimes)]` on by default
Check warning on line 506 in src/sr/finder/options.rs
github-actions / clippy
writing `&String` instead of `&str` involves a new object where a slice will do
warning: writing `&String` instead of `&str` involves a new object where a slice will do
--> src/sr/finder/options.rs:506:34
|
506 | fn convert_string_to_duration(s: &String) -> Result<Option<chrono::TimeDelta>, Box<dyn Error>> {
| ^^^^^^^ help: change this to: `&str`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
= note: `#[warn(clippy::ptr_arg)]` on by default
Check warning on line 413 in src/sr/finder/options.rs
github-actions / clippy
the borrowed expression implements the required traits
warning: the borrowed expression implements the required traits
--> src/sr/finder/options.rs:413:64
|
413 | set.contains(&needle) || set.iter().any(|key| test_pattern(&needle, key.as_ref()))
| ^^^^^^^ help: change this to: `needle`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
= note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default
Check warning on line 413 in src/sr/finder/options.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/finder/options.rs:413:18
|
413 | set.contains(&needle) || set.iter().any(|key| test_pattern(&needle, key.as_ref()))
| ^^^^^^^ help: change this to: `needle`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 389 in src/sr/finder/options.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/finder/options.rs:389:44
|
389 | .extend_from_slice(&sub);
| ^^^^ help: change this to: `sub`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 383 in src/sr/finder/options.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/sr/finder/options.rs:383:44
|
383 | .extend_from_slice(&add);
| ^^^^ help: change this to: `add`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 321 in src/sr/finder/options.rs
github-actions / clippy
this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
warning: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
--> src/sr/finder/options.rs:321:32
|
321 | .map(|v| v.into_iter().map(|s| s.to_string()).collect::<Vec<_>>()),
| ^^^^^^^^^ help: call directly: `iter`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref