Skip to content

Commit

Permalink
chore: Rustrover optimise imports
Browse files Browse the repository at this point in the history
  • Loading branch information
VorpalBlade committed Jul 27, 2024
1 parent a477c72 commit 1c75ddf
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 35 deletions.
21 changes: 12 additions & 9 deletions src/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@
// Doc comments are used to generate --help, not to for rustdoc.
#![allow(clippy::doc_markdown)]

#[cfg(test)]
mod tests;
use std::fs::File;
use std::io::Write;

use crate::config;
use crate::utils::Chezmoi;
use crate::utils::ChezmoiVersion;
use crate::utils::CHEZMOI_AUTO_SOURCE_VERSION;
use anyhow::anyhow;
use anyhow::Context;
use camino::Utf8Path;
use camino::Utf8PathBuf;
use indoc::formatdoc;
use ini_merge::filter::filter_ini;
use std::fs::File;
use std::io::Write;
use strum::Display;
use strum::EnumIter;
use strum::EnumMessage;
use strum::EnumString;
use strum::IntoStaticStr;

use ini_merge::filter::filter_ini;

use crate::config;
use crate::utils::Chezmoi;
use crate::utils::ChezmoiVersion;
use crate::utils::CHEZMOI_AUTO_SOURCE_VERSION;

#[cfg(test)]
mod tests;

/// The style of calls to the executable
#[derive(
Debug, Eq, PartialEq, EnumString, Clone, Copy, EnumIter, EnumMessage, Display, IntoStaticStr,
Expand Down
3 changes: 2 additions & 1 deletion src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Doc comments are used to generate --help, not to for rustdoc.
#![allow(clippy::doc_markdown)]

use crate::add::Style;
use bpaf::short;
use bpaf::Bpaf;
use bpaf::Parser;
Expand All @@ -13,6 +12,8 @@ use itertools::Itertools;
use strum::EnumMessage;
use strum::IntoEnumIterator;

use crate::add::Style;

/// Parser for `--style`
fn style() -> impl Parser<Style> {
const DEFAULT: Style = Style::Auto;
Expand Down
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use anyhow::anyhow;
use anyhow::Context;
use camino::Utf8Path;
use camino::Utf8PathBuf;
use winnow::Parser;

use ini_merge::filter::FilterAction;
use ini_merge::filter::FilterActions;
use ini_merge::filter::FilterActionsBuilder;
Expand All @@ -16,7 +18,6 @@ use ini_merge::mutations::Action;
use ini_merge::mutations::Mutations;
use ini_merge::mutations::MutationsBuilder;
use ini_merge::mutations::SectionAction;
use winnow::Parser;

use crate::transforms::Transform;

Expand Down
2 changes: 1 addition & 1 deletion src/config/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ fn quoted_string_nl(i: &mut &str) -> PResult<String> {
#[cfg(test)]
mod tests {
use indoc::indoc;
use pretty_assertions::assert_eq;

use super::*;
use pretty_assertions::assert_eq;

#[test]
fn check_quoted_string() {
Expand Down
16 changes: 8 additions & 8 deletions src/doctor.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
//! Sanity checking of environment

use anstream::println;
use anstream::stdout;
use anstyle::Effects;
use anstyle::Reset;
use itertools::Itertools;
use std::env::VarError;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Write;
use std::process::Command;

use medic::Check;
use medic::CheckResult;

use anstream::println;
use anstream::stdout;
use anstyle::Effects;
use anstyle::Reset;
use anyhow::anyhow;
use anyhow::Context;
use itertools::Itertools;

use medic::Check;
use medic::CheckResult;

use crate::utils::Chezmoi;
use crate::utils::ChezmoiVersion;
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ use std::fs::File;
use std::io::Read;
use std::io::Write;

pub use add::Style;
use anyhow::Context;
use indoc::printdoc;

pub use add::Style;
pub use arguments::parse_args;
pub use arguments::ChmmArgs;
use ini_merge::merge::merge_ini;

use crate::utils::RealChezmoi;
use crate::utils::CHEZMOI_AUTO_SOURCE_VERSION;

mod add;
mod arguments;
Expand All @@ -18,12 +24,6 @@ mod transforms;
mod update;
mod utils;

use indoc::printdoc;
use ini_merge::merge::merge_ini;

use crate::utils::RealChezmoi;
use crate::utils::CHEZMOI_AUTO_SOURCE_VERSION;

/// Main function, amenable to integration tests.
///
/// In order to support integration tests we need to be able to provide stdin
Expand Down
14 changes: 8 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
#![warn(clippy::semicolon_if_nothing_returned)]
#![warn(clippy::wildcard_imports)]

use anstyle::AnsiColor;
use chezmoi_modify_manager::inner_main;
use chezmoi_modify_manager::parse_args;
use env_logger::Builder;
use env_logger::Env;
use log::Level;
use std::io::stdin;
use std::io::stdout;
use std::io::BufWriter;
use std::io::Write;

use anstyle::AnsiColor;
use env_logger::Builder;
use env_logger::Env;
use log::Level;

use chezmoi_modify_manager::inner_main;
use chezmoi_modify_manager::parse_args;

fn main() -> anyhow::Result<()> {
// Set up logging
let mut builder = Builder::from_env(Env::default().default_filter_or("warn"));
Expand Down
3 changes: 2 additions & 1 deletion src/transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

use std::collections::HashMap;

use ini_merge::mutations::transforms as ini_transforms;
use strum::EnumIter;
use strum::EnumMessage;
use strum::EnumString;
use strum::IntoStaticStr;

use ini_merge::mutations::transforms as ini_transforms;

/// Supported transforms
///
/// This serves as a central point for documentation, parsing, generating
Expand Down
1 change: 0 additions & 1 deletion tests/integration/data_driven.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::io::BufReader;
use std::io::Read;

use camino::Utf8PathBuf;

use pretty_assertions::assert_eq;

use chezmoi_modify_manager::inner_main;
Expand Down

0 comments on commit 1c75ddf

Please sign in to comment.