Skip to content

Commit 9f56bf5

Browse files
committed
Enable and fix unused_qualifications lint
Improve code readability
1 parent 4559e97 commit 9f56bf5

File tree

44 files changed

+214
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+214
-237
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ pedantic = { level = "deny", priority = -1 }
589589
# Eventually the clippy settings from the `[lints]` section should be moved here.
590590
# In order to use these, all crates have `[lints] workspace = true` section.
591591
[workspace.lints.rust]
592-
# unused_qualifications = "warn"
592+
unused_qualifications = "warn"
593593

594594
[workspace.lints.clippy]
595595
all = { level = "deny", priority = -1 }

src/uu/base32/src/base_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
139139
.arg(
140140
Arg::new(options::FILE)
141141
.index(1)
142-
.action(clap::ArgAction::Append)
142+
.action(ArgAction::Append)
143143
.value_hint(clap::ValueHint::FilePath),
144144
)
145145
}

src/uu/basename/src/basename.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn uu_app() -> Command {
9090
)
9191
.arg(
9292
Arg::new(options::NAME)
93-
.action(clap::ArgAction::Append)
93+
.action(ArgAction::Append)
9494
.value_hint(clap::ValueHint::AnyPath)
9595
.hide(true)
9696
.trailing_var_arg(true),

src/uu/cat/src/cat.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl LineNumber {
8686
}
8787
}
8888

89-
fn write(&self, writer: &mut impl Write) -> std::io::Result<()> {
89+
fn write(&self, writer: &mut impl Write) -> io::Result<()> {
9090
writer.write_all(&self.buf)
9191
}
9292
}
@@ -288,7 +288,7 @@ pub fn uu_app() -> Command {
288288
.arg(
289289
Arg::new(options::FILE)
290290
.hide(true)
291-
.action(clap::ArgAction::Append)
291+
.action(ArgAction::Append)
292292
.value_hint(clap::ValueHint::FilePath),
293293
)
294294
.arg(
@@ -377,7 +377,7 @@ fn cat_handle<R: FdReadable>(
377377
/// Whether this process is appending to stdout.
378378
#[cfg(unix)]
379379
fn is_appending() -> bool {
380-
let stdout = std::io::stdout();
380+
let stdout = io::stdout();
381381
let flags = match fcntl(stdout.as_raw_fd(), FcntlArg::F_GETFL) {
382382
Ok(flags) => flags,
383383
Err(_) => return false,
@@ -404,7 +404,7 @@ fn cat_path(
404404
let in_info = FileInformation::from_file(&stdin)?;
405405
let mut handle = InputHandle {
406406
reader: stdin,
407-
is_interactive: std::io::stdin().is_terminal(),
407+
is_interactive: io::stdin().is_terminal(),
408408
};
409409
if let Some(out_info) = out_info {
410410
if in_info == *out_info && is_appending() {
@@ -445,7 +445,7 @@ fn cat_path(
445445
}
446446

447447
fn cat_files(files: &[String], options: &OutputOptions) -> UResult<()> {
448-
let out_info = FileInformation::from_file(&std::io::stdout()).ok();
448+
let out_info = FileInformation::from_file(&io::stdout()).ok();
449449

450450
let mut state = OutputState {
451451
line_number: LineNumber::new(),

src/uu/chcon/src/chcon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ struct Options {
312312
files: Vec<PathBuf>,
313313
}
314314

315-
fn parse_command_line(config: clap::Command, args: impl uucore::Args) -> Result<Options> {
315+
fn parse_command_line(config: Command, args: impl uucore::Args) -> Result<Options> {
316316
let matches = config.try_get_matches_from(args)?;
317317

318318
let verbose = matches.get_flag(options::VERBOSE);

src/uu/chcon/src/fts.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use crate::os_str_to_c_string;
1616

1717
#[derive(Debug)]
1818
pub(crate) struct FTS {
19-
fts: ptr::NonNull<fts_sys::FTS>,
19+
fts: NonNull<fts_sys::FTS>,
2020

21-
entry: Option<ptr::NonNull<fts_sys::FTSENT>>,
21+
entry: Option<NonNull<fts_sys::FTSENT>>,
2222
_phantom_data: PhantomData<fts_sys::FTSENT>,
2323
}
2424

@@ -52,7 +52,7 @@ impl FTS {
5252
// - `compar` is None.
5353
let fts = unsafe { fts_sys::fts_open(path_argv.as_ptr().cast(), options, None) };
5454

55-
let fts = ptr::NonNull::new(fts)
55+
let fts = NonNull::new(fts)
5656
.ok_or_else(|| Error::from_io("fts_open()", io::Error::last_os_error()))?;
5757

5858
Ok(Self {
@@ -110,14 +110,14 @@ impl Drop for FTS {
110110

111111
#[derive(Debug)]
112112
pub(crate) struct EntryRef<'fts> {
113-
pub(crate) pointer: ptr::NonNull<fts_sys::FTSENT>,
113+
pub(crate) pointer: NonNull<fts_sys::FTSENT>,
114114

115115
_fts: PhantomData<&'fts FTS>,
116116
_phantom_data: PhantomData<fts_sys::FTSENT>,
117117
}
118118

119119
impl<'fts> EntryRef<'fts> {
120-
fn new(_fts: &'fts FTS, entry: ptr::NonNull<fts_sys::FTSENT>) -> Self {
120+
fn new(_fts: &'fts FTS, entry: NonNull<fts_sys::FTSENT>) -> Self {
121121
Self {
122122
pointer: entry,
123123
_fts: PhantomData,
@@ -174,7 +174,7 @@ impl<'fts> EntryRef<'fts> {
174174
}
175175

176176
pub(crate) fn access_path(&self) -> Option<&Path> {
177-
ptr::NonNull::new(self.as_ref().fts_accpath)
177+
NonNull::new(self.as_ref().fts_accpath)
178178
.map(|path_ptr| {
179179
// SAFETY: `entry.fts_accpath` is a non-null pointer that is assumed to be valid.
180180
unsafe { CStr::from_ptr(path_ptr.as_ptr()) }
@@ -184,7 +184,7 @@ impl<'fts> EntryRef<'fts> {
184184
}
185185

186186
pub(crate) fn stat(&self) -> Option<&libc::stat> {
187-
ptr::NonNull::new(self.as_ref().fts_statp).map(|stat_ptr| {
187+
NonNull::new(self.as_ref().fts_statp).map(|stat_ptr| {
188188
// SAFETY: `entry.fts_statp` is a non-null pointer that is assumed to be valid.
189189
unsafe { stat_ptr.as_ref() }
190190
})

src/uu/cksum/src/cksum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ pub fn uu_app() -> Command {
350350
.arg(
351351
Arg::new(options::FILE)
352352
.hide(true)
353-
.action(clap::ArgAction::Append)
353+
.action(ArgAction::Append)
354354
.value_parser(ValueParser::os_string())
355355
.value_hint(clap::ValueHint::FilePath),
356356
)

src/uu/comm/src/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ impl OrderChecker {
118118
// Check if two files are identical by comparing their contents
119119
pub fn are_files_identical(path1: &str, path2: &str) -> io::Result<bool> {
120120
// First compare file sizes
121-
let metadata1 = std::fs::metadata(path1)?;
122-
let metadata2 = std::fs::metadata(path2)?;
121+
let metadata1 = metadata(path1)?;
122+
let metadata2 = metadata(path2)?;
123123

124124
if metadata1.len() != metadata2.len() {
125125
return Ok(false);

src/uu/cp/src/copydir.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct Context<'a> {
101101
}
102102

103103
impl<'a> Context<'a> {
104-
fn new(root: &'a Path, target: &'a Path) -> std::io::Result<Self> {
104+
fn new(root: &'a Path, target: &'a Path) -> io::Result<Self> {
105105
let current_dir = env::current_dir()?;
106106
let root_path = current_dir.join(root);
107107
let root_parent = if target.exists() && !root.to_str().unwrap().ends_with("/.") {
@@ -181,7 +181,7 @@ impl Entry {
181181
if no_target_dir {
182182
let source_is_dir = source.is_dir();
183183
if path_ends_with_terminator(context.target) && source_is_dir {
184-
if let Err(e) = std::fs::create_dir_all(context.target) {
184+
if let Err(e) = fs::create_dir_all(context.target) {
185185
eprintln!("Failed to create directory: {e}");
186186
}
187187
} else {
@@ -305,9 +305,7 @@ fn copy_direntry(
305305
false,
306306
) {
307307
Ok(_) => {}
308-
Err(Error::IoErrContext(e, _))
309-
if e.kind() == std::io::ErrorKind::PermissionDenied =>
310-
{
308+
Err(Error::IoErrContext(e, _)) if e.kind() == io::ErrorKind::PermissionDenied => {
311309
show!(uio_error!(
312310
e,
313311
"cannot open {} for reading",
@@ -580,14 +578,13 @@ fn build_dir(
580578
// we need to allow trivial casts here because some systems like linux have u32 constants in
581579
// in libc while others don't.
582580
#[allow(clippy::unnecessary_cast)]
583-
let mut excluded_perms =
584-
if matches!(options.attributes.ownership, crate::Preserve::Yes { .. }) {
585-
libc::S_IRWXG | libc::S_IRWXO // exclude rwx for group and other
586-
} else if matches!(options.attributes.mode, crate::Preserve::Yes { .. }) {
587-
libc::S_IWGRP | libc::S_IWOTH //exclude w for group and other
588-
} else {
589-
0
590-
} as u32;
581+
let mut excluded_perms = if matches!(options.attributes.ownership, Preserve::Yes { .. }) {
582+
libc::S_IRWXG | libc::S_IRWXO // exclude rwx for group and other
583+
} else if matches!(options.attributes.mode, Preserve::Yes { .. }) {
584+
libc::S_IWGRP | libc::S_IWOTH //exclude w for group and other
585+
} else {
586+
0
587+
} as u32;
591588

592589
let umask = if copy_attributes_from.is_some()
593590
&& matches!(options.attributes.mode, Preserve::Yes { .. })

src/uu/cp/src/cp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ pub fn uu_app() -> Command {
737737
Arg::new(options::PROGRESS_BAR)
738738
.long(options::PROGRESS_BAR)
739739
.short('g')
740-
.action(clap::ArgAction::SetTrue)
740+
.action(ArgAction::SetTrue)
741741
.help(
742742
"Display a progress bar. \n\
743743
Note: this feature is not supported by GNU coreutils.",
@@ -2081,7 +2081,7 @@ fn handle_copy_mode(
20812081
CopyMode::Update => {
20822082
if dest.exists() {
20832083
match options.update {
2084-
update_control::UpdateMode::ReplaceAll => {
2084+
UpdateMode::ReplaceAll => {
20852085
copy_helper(
20862086
source,
20872087
dest,
@@ -2094,17 +2094,17 @@ fn handle_copy_mode(
20942094
source_is_stream,
20952095
)?;
20962096
}
2097-
update_control::UpdateMode::ReplaceNone => {
2097+
UpdateMode::ReplaceNone => {
20982098
if options.debug {
20992099
println!("skipped {}", dest.quote());
21002100
}
21012101

21022102
return Ok(PerformedAction::Skipped);
21032103
}
2104-
update_control::UpdateMode::ReplaceNoneFail => {
2104+
UpdateMode::ReplaceNoneFail => {
21052105
return Err(Error::Error(format!("not replacing '{}'", dest.display())));
21062106
}
2107-
update_control::UpdateMode::ReplaceIfOlder => {
2107+
UpdateMode::ReplaceIfOlder => {
21082108
let dest_metadata = fs::symlink_metadata(dest)?;
21092109

21102110
let src_time = source_metadata.modified()?;
@@ -2335,7 +2335,7 @@ fn copy_file(
23352335
&FileInformation::from_path(source, options.dereference(source_in_command_line))
23362336
.context(format!("cannot stat {}", source.quote()))?,
23372337
) {
2338-
std::fs::hard_link(new_source, dest)?;
2338+
fs::hard_link(new_source, dest)?;
23392339

23402340
if options.verbose {
23412341
print_verbose_output(options.parents, progress_bar, source, dest);

0 commit comments

Comments
 (0)