Skip to content

Commit

Permalink
chore: resolve warnings generated by cargo-clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Gaoyang Zhang <[email protected]>
  • Loading branch information
blurgyy committed Apr 5, 2022
1 parent b21ef29 commit 906b598
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions dt-core/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl Operate for PathBuf {
/// Reference: <https://stackoverflow.com/a/54817755/13482274>
fn absolute(self) -> Result<Self> {
let absolute_path = if self.is_absolute() {
self.to_owned()
self
} else {
std::env::current_dir()?.join(self)
}
Expand All @@ -165,7 +165,7 @@ impl Operate for PathBuf {
/// host-specific, returns `self` directly.
fn host_specific(self, hostname_sep: &str) -> Self {
if self.ends_with(utils::host_specific_suffix(hostname_sep)) {
self.into()
self
} else {
let hs_filename = self
.file_name()
Expand Down Expand Up @@ -417,7 +417,7 @@ impl Operate for PathBuf {
renaming_rules: Vec<RenamingRule>,
) -> Result<Self> {
// Get non-host-specific counterpart of `self`
let nhself = self.to_owned().non_host_specific(hostname_sep);
let nhself = self.non_host_specific(hostname_sep);

// Get non-host-specific counterpart of `base`
let base = base.to_owned().non_host_specific(hostname_sep);
Expand Down
1 change: 0 additions & 1 deletion dt-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ sources = ["{}"]
)?,
);

let test_username = "watson";
let config = expand(DTConfig::from_str(&format!(
r#"
[context.user]
Expand Down
12 changes: 6 additions & 6 deletions dt-core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ Block helper `#{0}`:
.unwrap()
.to_string_lossy()
.to_string();
if allowed_usernames.len() > 0 {
if !allowed_usernames.is_empty() {
if allowed_usernames.contains(&current_username) {
log::debug!(
"Current username '{}' matches allowed usernames '{:?}'",
Expand Down Expand Up @@ -472,7 +472,7 @@ Block helper `#{0}`:
.unwrap()
.to_string_lossy()
.to_string();
if disallowed_usernames.len() > 0 {
if !disallowed_usernames.is_empty() {
if disallowed_usernames.contains(&current_username) {
log::debug!(
"Current username '{}' matches disallowed usernames '{:?}'",
Expand Down Expand Up @@ -592,7 +592,7 @@ Block helper `#{0}`:
};

let current_uid = get_current_uid();
if allowed_uids.len() > 0 {
if !allowed_uids.is_empty() {
if allowed_uids.contains(&current_uid) {
log::debug!(
"Current uid '{}' matches allowed uids '{:?}'",
Expand Down Expand Up @@ -713,7 +713,7 @@ Block helper `#{0}`:
};

let current_uid = get_current_uid();
if disallowed_uids.len() > 0 {
if !disallowed_uids.is_empty() {
if disallowed_uids.contains(&current_uid) {
log::debug!(
"Current uid '{}' matches disallowed uids '{:?}'",
Expand Down Expand Up @@ -835,7 +835,7 @@ Block helper `#{0}`:
let current_hostname = gethostname();
let current_hostname: String =
current_hostname.to_string_lossy().to_string();
if allowed_hostnames.len() > 0 {
if !allowed_hostnames.is_empty() {
if allowed_hostnames.contains(&current_hostname) {
log::debug!(
"Current hostname '{}' matches allowed hostnames '{:?}'",
Expand Down Expand Up @@ -958,7 +958,7 @@ Block helper `#{0}`:
let current_hostname = gethostname();
let current_hostname: String =
current_hostname.to_string_lossy().to_string();
if disallowed_hostnames.len() > 0 {
if !disallowed_hostnames.is_empty() {
if disallowed_hostnames.contains(&current_hostname) {
log::debug!(
"Current hostname '{}' matches disallowed hostnames '{:?}'",
Expand Down
1 change: 1 addition & 0 deletions dt-core/src/syncing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ pub fn sync(config: DTConfig, dry_run: bool) -> Result<()> {
}
}
} else {
#[allow(clippy::collapsible_else_if)]
if let Err(e) = spath
.populate(Rc::clone(&group_ref), Rc::clone(&registry))
{
Expand Down

0 comments on commit 906b598

Please sign in to comment.