Skip to content

Commit 16cbb72

Browse files
committed
Format code with cargo fmt nightly
add raketask to check if all tests and clippy and fmt are correct
1 parent b636fac commit 16cbb72

File tree

6 files changed

+35
-36
lines changed

6 files changed

+35
-36
lines changed

rakefile.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
sh 'cargo test'
2424
end
2525

26+
desc 'format code with cargo nightly'
27+
task :fmt do
28+
sh 'cargo +nightly fmt'
29+
end
30+
2631
desc 'run tests with printing to stdout'
2732
task :test_nocapture do
2833
sh 'cargo test -- --nocapture'

src/args.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
use std::cmp;
2-
use std::num;
3-
use std::ops;
4-
use std::process;
1+
use std::{cmp, num, ops, process};
52

63
use crate::app;
74
use clap;
85
use env_logger;
96
use num_cpus;
107

118
use super::check::InfoLevel;
12-
use std::path::{Path, PathBuf};
13-
use std::result::Result;
9+
use std::{
10+
path::{Path, PathBuf},
11+
result::Result,
12+
};
1413

1514
/// `Args` are transformed/normalized from `ArgMatches`.
1615
#[derive(Debug)]

src/check.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use ansi_term;
2-
use std;
3-
use std::fs::metadata;
4-
use std::fs::File;
5-
use std::io;
6-
use std::io::prelude::*;
7-
use std::path::Path;
2+
use std::{
3+
self,
4+
fs::{metadata, File},
5+
io,
6+
io::prelude::*,
7+
path::Path,
8+
};
89
use unic_char_range::CharRange;
910

1011
#[cfg(not(target_os = "windows"))]
@@ -288,13 +289,10 @@ pub fn bold(s: &str) -> ansi_term::ANSIString {
288289

289290
#[cfg(test)]
290291
mod tests {
291-
use super::check_content;
292-
use super::InfoLevel;
293-
use super::HAS_ILLEGAL_CHARACTERS;
294-
use super::HAS_TABS;
295-
use super::HAS_WINDOWS_LINE_ENDINGS;
296-
use super::LINE_TOO_LONG;
297-
use super::TRAILING_SPACES;
292+
use super::{
293+
check_content, InfoLevel, HAS_ILLEGAL_CHARACTERS, HAS_TABS, HAS_WINDOWS_LINE_ENDINGS,
294+
LINE_TOO_LONG, TRAILING_SPACES,
295+
};
298296
use crate::clean::TabStrategy::{Tabify, Untabify};
299297
use std::sync::mpsc::sync_channel;
300298

src/config.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use anyhow::{anyhow, Error};
22
use regex::Regex;
33
use serde_derive::Deserialize;
4-
use std;
5-
use std::fs;
4+
use std::{self, fs};
65

7-
use std::io::Read;
8-
use std::path::PathBuf;
6+
use std::{io::Read, path::PathBuf};
97
use toml;
108

119
const DEFAULT_CFG_FILE: &str = "./.enforcer";
@@ -144,10 +142,7 @@ pub fn parse_config(input: &str) -> Result<EnforcerCfg, Error> {
144142

145143
#[cfg(test)]
146144
mod tests {
147-
use super::parse_config;
148-
use super::s;
149-
use super::suggestion;
150-
use super::EnforcerCfg;
145+
use super::{parse_config, s, suggestion, EnforcerCfg};
151146

152147
#[test]
153148
fn test_load_simple_config() {

src/main.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ mod config;
2626
mod search;
2727

2828
use pbr::ProgressBar;
29-
use std::fs::File;
30-
use std::io::prelude::*;
31-
use std::num;
32-
use std::process;
33-
use std::sync::mpsc::{sync_channel, SyncSender};
34-
use std::sync::Arc;
35-
use std::thread;
29+
use std::{
30+
fs::File,
31+
io::prelude::*,
32+
num, process,
33+
sync::{
34+
mpsc::{sync_channel, SyncSender},
35+
Arc,
36+
},
37+
thread,
38+
};
3639

3740
macro_rules! eprintln {
3841
($($tt:tt)*) => {{

src/search.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ pub fn find_matches(
6161

6262
#[cfg(test)]
6363
mod tests {
64-
use super::find_matches;
65-
use super::path_components_matches;
64+
use super::{find_matches, path_components_matches};
6665
use std::path;
6766

6867
fn s(x: &str) -> String {

0 commit comments

Comments
 (0)