mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-28 02:35:03 +00:00
Fix Clippy lints
This commit is contained in:
parent
5a84953b4e
commit
dba3f37b0a
7
build.rs
7
build.rs
@ -50,9 +50,10 @@ fn write_statics() -> IOResult<()> {
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
let ver = match is_development_version() {
|
let ver = if is_development_version() {
|
||||||
true => format!("exa v{} ({} built on {})", cargo_version(), git_hash(), build_date()),
|
format!("exa v{} ({} built on {})", cargo_version(), git_hash(), build_date())
|
||||||
false => format!("exa v{}", cargo_version()),
|
} else {
|
||||||
|
format!("exa v{}", cargo_version())
|
||||||
};
|
};
|
||||||
|
|
||||||
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use git2;
|
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
|
|
||||||
use crate::fs::fields as f;
|
use crate::fs::fields as f;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#![allow(trivial_casts)] // for ARM
|
#![allow(trivial_casts)] // for ARM
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
|
use std::cmp::Ordering;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
@ -58,20 +59,23 @@ pub fn list_attrs(lister: &lister::Lister, path: &Path) -> io::Result<Vec<Attrib
|
|||||||
None => return Err(io::Error::new(io::ErrorKind::Other, "Error: path somehow contained a NUL?")),
|
None => return Err(io::Error::new(io::ErrorKind::Other, "Error: path somehow contained a NUL?")),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut names = Vec::new();
|
|
||||||
let bufsize = lister.listxattr_first(&c_path);
|
let bufsize = lister.listxattr_first(&c_path);
|
||||||
|
match bufsize.cmp(&0) {
|
||||||
if bufsize < 0 {
|
Ordering::Less => return Err(io::Error::last_os_error()),
|
||||||
return Err(io::Error::last_os_error());
|
Ordering::Equal => return Ok(Vec::new()),
|
||||||
|
Ordering::Greater => {},
|
||||||
}
|
}
|
||||||
else if bufsize > 0 {
|
|
||||||
let mut buf = vec![0u8; bufsize as usize];
|
let mut buf = vec![0u8; bufsize as usize];
|
||||||
let err = lister.listxattr_second(&c_path, &mut buf, bufsize);
|
let err = lister.listxattr_second(&c_path, &mut buf, bufsize);
|
||||||
|
|
||||||
if err < 0 {
|
match err.cmp(&0) {
|
||||||
return Err(io::Error::last_os_error());
|
Ordering::Less => return Err(io::Error::last_os_error()),
|
||||||
|
Ordering::Equal => return Ok(Vec::new()),
|
||||||
|
Ordering::Greater => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut names = Vec::new();
|
||||||
if err > 0 {
|
if err > 0 {
|
||||||
// End indices of the attribute names
|
// End indices of the attribute names
|
||||||
// the buffer contains 0-terminated c-strings
|
// the buffer contains 0-terminated c-strings
|
||||||
@ -93,9 +97,6 @@ pub fn list_attrs(lister: &lister::Lister, path: &Path) -> io::Result<Vec<Attrib
|
|||||||
|
|
||||||
start = c_end;
|
start = c_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Ok(names)
|
Ok(names)
|
||||||
}
|
}
|
||||||
|
@ -474,8 +474,6 @@ impl<'dir> FileTarget<'dir> {
|
|||||||
/// More readable aliases for the permission bits exposed by libc.
|
/// More readable aliases for the permission bits exposed by libc.
|
||||||
#[allow(trivial_numeric_casts)]
|
#[allow(trivial_numeric_casts)]
|
||||||
mod modes {
|
mod modes {
|
||||||
use libc;
|
|
||||||
|
|
||||||
pub type Mode = u32;
|
pub type Mode = u32;
|
||||||
// The `libc::mode_t` type’s actual type varies, but the value returned
|
// The `libc::mode_t` type’s actual type varies, but the value returned
|
||||||
// from `metadata.permissions().mode()` is always `u32`.
|
// from `metadata.permissions().mode()` is always `u32`.
|
||||||
|
@ -5,9 +5,6 @@ use std::iter::FromIterator;
|
|||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use glob;
|
|
||||||
use natord;
|
|
||||||
|
|
||||||
use crate::fs::File;
|
use crate::fs::File;
|
||||||
use crate::fs::DotFilter;
|
use crate::fs::DotFilter;
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@ use std::ffi::OsString;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::num::ParseIntError;
|
use std::num::ParseIntError;
|
||||||
|
|
||||||
use glob;
|
|
||||||
|
|
||||||
use crate::options::{flags, HelpString, VersionString};
|
use crate::options::{flags, HelpString, VersionString};
|
||||||
use crate::options::parser::{Arg, Flag, ParseError};
|
use crate::options::parser::{Arg, Flag, ParseError};
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ impl Args {
|
|||||||
// -abx => error
|
// -abx => error
|
||||||
//
|
//
|
||||||
else {
|
else {
|
||||||
for (index, byte) in bytes.into_iter().enumerate().skip(1) {
|
for (index, byte) in bytes.iter().enumerate().skip(1) {
|
||||||
let arg = self.lookup_short(*byte)?;
|
let arg = self.lookup_short(*byte)?;
|
||||||
let flag = Flag::Short(*byte);
|
let flag = Flag::Short(*byte);
|
||||||
match arg.takes_value {
|
match arg.takes_value {
|
||||||
@ -283,7 +283,7 @@ impl Args {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
match arg.takes_value {
|
match arg.takes_value {
|
||||||
Forbidden => assert!(false),
|
Forbidden => unreachable!(),
|
||||||
Necessary(_) => {
|
Necessary(_) => {
|
||||||
return Err(ParseError::NeedsValue { flag, values });
|
return Err(ParseError::NeedsValue { flag, values });
|
||||||
},
|
},
|
||||||
@ -292,7 +292,6 @@ impl Args {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,14 +308,14 @@ impl Args {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn lookup_short(&self, short: ShortArg) -> Result<&Arg, ParseError> {
|
fn lookup_short(&self, short: ShortArg) -> Result<&Arg, ParseError> {
|
||||||
match self.0.into_iter().find(|arg| arg.short == Some(short)) {
|
match self.0.iter().find(|arg| arg.short == Some(short)) {
|
||||||
Some(arg) => Ok(arg),
|
Some(arg) => Ok(arg),
|
||||||
None => Err(ParseError::UnknownShortArgument { attempt: short })
|
None => Err(ParseError::UnknownShortArgument { attempt: short })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lookup_long<'b>(&self, long: &'b OsStr) -> Result<&Arg, ParseError> {
|
fn lookup_long<'b>(&self, long: &'b OsStr) -> Result<&Arg, ParseError> {
|
||||||
match self.0.into_iter().find(|arg| arg.long == long) {
|
match self.0.iter().find(|arg| arg.long == long) {
|
||||||
Some(arg) => Ok(arg),
|
Some(arg) => Ok(arg),
|
||||||
None => Err(ParseError::UnknownArgument { attempt: long.to_os_string() })
|
None => Err(ParseError::UnknownArgument { attempt: long.to_os_string() })
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use ansi_term::Style;
|
use ansi_term::Style;
|
||||||
use glob;
|
|
||||||
|
|
||||||
use crate::fs::File;
|
use crate::fs::File;
|
||||||
use crate::options::{flags, Vars, Misfire};
|
use crate::options::{flags, Vars, Misfire};
|
||||||
@ -366,7 +365,7 @@ mod customs_test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn $name() {
|
fn $name() {
|
||||||
let mappings: Vec<(glob::Pattern, Style)>
|
let mappings: Vec<(glob::Pattern, Style)>
|
||||||
= $mappings.into_iter()
|
= $mappings.iter()
|
||||||
.map(|t| (glob::Pattern::new(t.0).unwrap(), t.1))
|
.map(|t| (glob::Pattern::new(t.0).unwrap(), t.1))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ impl TimeFormat {
|
|||||||
Ok(TimeFormat::FullISO)
|
Ok(TimeFormat::FullISO)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Err(Misfire::BadArgument(&flags::TIME_STYLE, word.into()))
|
Err(Misfire::BadArgument(&flags::TIME_STYLE, word))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ impl<'a> Render<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
grid.add(tg::Cell {
|
grid.add(tg::Cell {
|
||||||
contents: format!("{icon}{filename}", icon=&icon.unwrap_or("".to_string()), filename=filename.strings().to_string()),
|
contents: format!("{icon}{filename}", icon=&icon.unwrap_or_default(), filename=filename.strings().to_string()),
|
||||||
width: *width,
|
width: *width,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,7 @@ fn icon(file: &File) -> char {
|
|||||||
let extensions = Box::new(FileExtensions);
|
let extensions = Box::new(FileExtensions);
|
||||||
if file.is_directory() { '\u{f115}' }
|
if file.is_directory() { '\u{f115}' }
|
||||||
else if let Some(icon) = extensions.icon_file(file) { icon }
|
else if let Some(icon) = extensions.icon_file(file) { icon }
|
||||||
else {
|
else if let Some(ext) = file.ext.as_ref() {
|
||||||
if let Some(ext) = file.ext.as_ref() {
|
|
||||||
match ext.as_str() {
|
match ext.as_str() {
|
||||||
"ai" => '\u{e7b4}',
|
"ai" => '\u{e7b4}',
|
||||||
"android" => '\u{e70e}',
|
"android" => '\u{e70e}',
|
||||||
@ -191,4 +190,3 @@ fn icon(file: &File) -> char {
|
|||||||
'\u{f15b}'
|
'\u{f15b}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -6,8 +6,6 @@ use std::sync::{Mutex, MutexGuard};
|
|||||||
use datetime::TimeZone;
|
use datetime::TimeZone;
|
||||||
use zoneinfo_compiled::{CompiledData, Result as TZResult};
|
use zoneinfo_compiled::{CompiledData, Result as TZResult};
|
||||||
|
|
||||||
use locale;
|
|
||||||
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
use users::UsersCache;
|
use users::UsersCache;
|
||||||
|
@ -4,7 +4,6 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use datetime::{LocalDateTime, TimeZone, DatePiece, TimePiece};
|
use datetime::{LocalDateTime, TimeZone, DatePiece, TimePiece};
|
||||||
use datetime::fmt::DateFormat;
|
use datetime::fmt::DateFormat;
|
||||||
use locale;
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user