Benjamin Sago 5 лет назад
Родитель
Сommit
74d9f1402b
6 измененных файлов с 15 добавлено и 12 удалено
  1. 7 3
      Justfile
  2. 2 2
      src/fs/feature/xattr.rs
  3. 1 4
      src/fs/fields.rs
  4. 1 1
      src/fs/file.rs
  5. 1 1
      src/output/render/octal.rs
  6. 3 1
      src/style/lsc.rs

+ 7 - 3
Justfile

@@ -11,7 +11,7 @@ all-release: build-release test-release
     cargo build --release --verbose
 
 # compiles the exa binary with every combination of feature flags
-build-features:
+@build-features:
     cargo hack build --feature-powerset
 
 
@@ -24,16 +24,20 @@ build-features:
     cargo test --release --all --verbose
 
 # runs unit tests with every combination of feature flags
-test-features:
+@test-features:
     cargo hack test --feature-powerset -- --quiet
 
 
+# lints the code
+@clippy:
+    touch src/main.rs
+    cargo clippy
+
 # updates dependency versions, and checks for outdated ones
 @update:
     cargo update
     cargo outdated
 
-
 # prints versions of the necessary build tools
 @versions:
     rustc --version

+ 2 - 2
src/fs/feature/xattr.rs

@@ -104,7 +104,7 @@ pub fn list_attrs(lister: &lister::Lister, path: &Path) -> io::Result<Vec<Attrib
 #[cfg(target_os = "macos")]
 mod lister {
     use std::ffi::CString;
-    use libc::{c_int, size_t, ssize_t, c_char, c_void, uint32_t};
+    use libc::{c_int, size_t, ssize_t, c_char, c_void};
     use super::FollowSymlinks;
     use std::ptr;
 
@@ -116,7 +116,7 @@ mod lister {
 
         fn getxattr(
             path: *const c_char, name: *const c_char,
-            value: *mut c_void, size: size_t, position: uint32_t,
+            value: *mut c_void, size: size_t, position: u32,
             options: c_int
         ) -> ssize_t;
     }

+ 1 - 4
src/fs/fields.rs

@@ -50,10 +50,7 @@ pub enum Type {
 
 impl Type {
     pub fn is_regular_file(&self) -> bool {
-        match *self {
-            Type::File  => true,
-            _           => false,
-        }
+        matches!(*self, Type::File)
     }
 }
 

+ 1 - 1
src/fs/file.rs

@@ -338,7 +338,7 @@ impl<'dir> File<'dir> {
            if sec < 0 {
                if nsec > 0 {
                    sec += 1;
-                   nsec = nsec - 1_000_000_000;
+                   nsec -= 1_000_000_000;
                }
                UNIX_EPOCH - Duration::new(sec.abs() as u64, nsec.abs() as u32)
            } else {

+ 1 - 1
src/output/render/octal.rs

@@ -5,7 +5,7 @@ use crate::fs::fields as f;
 
 impl f::OctalPermissions {
     fn bits_to_octal(r: bool, w: bool, x: bool) -> u8 {
-        (r  as u8) * 4 + (w as u8) * 2 + (x as u8) * 1
+        (r  as u8) * 4 + (w as u8) * 2 + (x as u8)
     }
 
     pub fn render(&self, style: Style) -> TextCell {

+ 3 - 1
src/style/lsc.rs

@@ -25,7 +25,9 @@ use ansi_term::Colour::*;
 pub struct LSColors<'var>(pub &'var str);
 
 impl<'var> LSColors<'var> {
-    pub fn each_pair<C>(&mut self, mut callback: C) where C: FnMut(Pair<'var>) -> () {
+    pub fn each_pair<C>(&mut self, mut callback: C)
+    where C: FnMut(Pair<'var>)
+    {
         for next in self.0.split(':') {
             let bits = next.split('=')
                            .take(3)