Skip to content

Commit

Permalink
Transition to 2018 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
cundd committed Nov 7, 2019
1 parent ca9fcf3 commit 4f38515
Show file tree
Hide file tree
Showing 29 changed files with 80 additions and 221 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "hackscanner"
version = "0.3.0"
authors = ["Daniel Corn <[email protected]>"]
edition = "2018"

[lib]
name = "hackscanner_lib"
Expand Down
2 changes: 1 addition & 1 deletion src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn configure_logging(matches: &ArgMatches) -> Result<(), Error> {
_ => simplelog::LevelFilter::Warn,
};

let mut loggers: Vec<Box<simplelog::SharedLogger>> = vec![];
let mut loggers: Vec<Box<dyn simplelog::SharedLogger>> = vec![];
let mut config = simplelog::Config::default();
config.time_format = Some("%H:%M:%S%.3f");

Expand Down
8 changes: 4 additions & 4 deletions src/classifier/content_classifier.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use DirEntryTrait;
use crate::DirEntryTrait;
use super::Classification;
use super::ClassifierTrait;
use super::Violation;
use rule::*;
use matcher::Matcher;
use errors::Result;
use crate::rule::*;
use crate::matcher::Matcher;
use crate::errors::Result;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
Expand Down
8 changes: 4 additions & 4 deletions src/classifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ mod classification;
mod content_classifier;
mod path_classifier;

use dir_entry::*;
use rule::*;
use crate::dir_entry::*;
use crate::rule::*;

pub use self::violation::Violation;
use self::classification::*;
Expand Down Expand Up @@ -100,9 +100,9 @@ fn panic_empty() -> ! {
#[cfg(test)]
mod test {
use super::*;
use severity::Severity;
use crate::severity::Severity;
use std::convert::TryInto;
use fs::StandaloneFileType;
use crate::fs::StandaloneFileType;

fn test_classify_entry<D: DirEntryTrait>(entry: &D, rule: &Rule) -> Classification {
let mut path_classifier = path_classifier::PathClassifier::new(entry);
Expand Down
6 changes: 3 additions & 3 deletions src/classifier/path_classifier.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use rule::*;
use crate::rule::*;
use super::Classification;
use super::ClassifierTrait;
use super::Violation;
use DirEntryTrait;
use matcher::Matcher;
use crate::DirEntryTrait;
use crate::matcher::Matcher;

pub struct PathClassifier {}

Expand Down
12 changes: 6 additions & 6 deletions src/classifier/violation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ::{Rule, Severity};
use crate::{Rule, Severity};
use std::error::Error as StdError;
use PatternRule;
use crate::PatternRule;

#[derive(Debug, Clone)]
pub struct Violation {
Expand Down Expand Up @@ -39,14 +39,14 @@ impl Violation {
}
}

impl From<&StdError> for Violation {
fn from(error: &StdError) -> Self {
impl From<&dyn StdError> for Violation {
fn from(error: &dyn StdError) -> Self {
Self::with_name_and_severity(error.description().to_owned(), Severity::NOTICE)
}
}

impl From<&::errors::Error> for Violation {
fn from(error: &::errors::Error) -> Self {
impl From<&crate::errors::Error> for Violation {
fn from(error: &crate::errors::Error) -> Self {
Self::with_name_and_severity(error.description().to_owned(), Severity::NOTICE)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/dir_entry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::Path;
use std::ffi::OsStr;
use std::io;
use std::fmt::Debug;
use fs::FileTypeTrait;
use crate::fs::FileTypeTrait;

pub trait DirEntryTrait: Debug {
/// The full path that this entry represents.
Expand All @@ -25,7 +25,7 @@ pub trait DirEntryTrait: Debug {
/// Return the file type for the file that this entry points to.
///
/// See [`walkdir::DirEntry::file_type`] for more details
fn file_type(&self) -> Box<FileTypeTrait>;
fn file_type(&self) -> Box<dyn FileTypeTrait>;

/// Return the file name of this entry.
///
Expand Down
6 changes: 3 additions & 3 deletions src/dir_entry/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::io;
use std::path::Path;
use std::path::PathBuf;
use std::fs;
use fs::FileTypeTrait;
use fs::StandaloneFileType;
use crate::fs::FileTypeTrait;
use crate::fs::StandaloneFileType;
use super::DirEntryTrait;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -56,7 +56,7 @@ impl DirEntryTrait for DirEntry {
/// Return the file type for the file that this entry points to.
///
/// See [`walkdir::DirEntry::file_type`] for more details
fn file_type(&self) -> Box<FileTypeTrait> {
fn file_type(&self) -> Box<dyn FileTypeTrait> {
Box::new(self.file_type.clone())
}

Expand Down
4 changes: 2 additions & 2 deletions src/dir_entry/walkdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io;
use std::path::Path;
use std::ffi::OsStr;
use walkdir;
use fs::FileTypeTrait;
use crate::fs::FileTypeTrait;
use super::DirEntryTrait;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -59,7 +59,7 @@ impl DirEntryTrait for DirEntry {
/// Return the file type for the file that this entry points to.
///
/// See [`walkdir::DirEntry::file_type`] for more details
fn file_type(&self) -> Box<FileTypeTrait> {
fn file_type(&self) -> Box<dyn FileTypeTrait> {
Box::new(self.raw.file_type())
}

Expand Down
143 changes: 0 additions & 143 deletions src/file_finder/ftw.rs.off

This file was deleted.

6 changes: 3 additions & 3 deletions src/file_finder/ftw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use std::fmt::Debug;
use std::vec::Vec;
use std::cell::RefCell;

use fs::constants::*;
use crate::fs::constants::*;

use super::FileFinderTrait;
use dir_entry::StandaloneDirEntry;
use fs::StandaloneFileType;
use crate::dir_entry::StandaloneDirEntry;
use crate::fs::StandaloneFileType;

#[repr(C)]
struct FTW {
Expand Down
8 changes: 4 additions & 4 deletions src/file_finder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pub mod ftw;
pub mod fts;
pub mod walkdir;

use rule::*;
use dir_entry::*;
use matcher::Matcher;
use Severity;
use crate::rule::*;
use crate::dir_entry::*;
use crate::matcher::Matcher;
use crate::Severity;

pub trait FileFinderTrait {
type DirEntry: DirEntryTrait;
Expand Down
2 changes: 1 addition & 1 deletion src/file_finder/walkdir.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dir_entry::WalkdirDirEntry;
use crate::dir_entry::WalkdirDirEntry;
use std::fmt::Debug;
use std::path::Path;
use super::FileFinderTrait;
Expand Down
2 changes: 1 addition & 1 deletion src/join.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use classifier::Violation;
use crate::classifier::Violation;

pub fn join_violations(violations: &Vec<Violation>) -> String {
violations.iter().map(|v| v.name().to_owned()).collect::<Vec<String>>().join(", ")
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ pub mod rating;
pub mod file_finder;
pub mod classifier;

pub use errors::*;
pub use dir_entry::*;
pub use rule::*;
pub use rating::*;
pub use file_finder::find_files;
pub use severity::Severity;
pub use join::join_violations;
pub use crate::errors::*;
pub use crate::dir_entry::*;
pub use crate::rule::*;
pub use crate::rating::*;
pub use crate::file_finder::find_files;
pub use crate::severity::Severity;
pub use crate::join::join_violations;
6 changes: 3 additions & 3 deletions src/matcher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rule::RuleTrait;
use rule::PatternRule;
use dir_entry::*;
use crate::rule::RuleTrait;
use crate::rule::PatternRule;
use crate::dir_entry::*;

pub struct Matcher {}

Expand Down
Loading

0 comments on commit 4f38515

Please sign in to comment.