Skip to content

Commit

Permalink
chore: Additional clippy lints and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
VorpalBlade committed Sep 6, 2024
1 parent bbb77d8 commit bec95ae
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 69 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ rust-2018-idioms = "warn"
unreachable_pub = "warn"

[lints.clippy]
assigning_clones = "warn"
doc_markdown = "warn"
format_push_string = "warn"
needless_pass_by_value = "warn"
ptr_as_ptr = "warn"
redundant_clone = "warn"
redundant_closure_for_method_calls = "warn"
semicolon_if_nothing_returned = "warn"
undocumented_unsafe_blocks = "warn"
uninlined_format_args = "warn"
unnecessary_box_returns = "warn"
unnecessary_safety_doc = "warn"
unwrap_used = "warn"
wildcard_imports = "warn"
5 changes: 2 additions & 3 deletions src/actions.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//! Action matching framework for INI processing

use std::borrow::Cow;
use std::collections::HashMap;

use log::warn;
use regex::RegexSet;
use std::borrow::Cow;
use std::collections::HashMap;
use thiserror::Error;

/// Handles matching on INI lines and mapping the matches to generic actions
Expand Down
18 changes: 7 additions & 11 deletions src/filter.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
//! INI filtering functionality

use std::io::Read;

use lending_iterator::prelude::*;
use log::error;
use thiserror::Error;

use crate::actions::Actions;
use crate::actions::ActionsBuilder;
use crate::loader::Loader;
use crate::loader::{self};
use lending_iterator::prelude::*;
use log::error;
use std::io::Read;
use thiserror::Error;

/// Operations that can be set for filtering
#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -156,13 +154,11 @@ pub fn filter_ini(

#[cfg(test)]
mod tests {
use std::collections::VecDeque;

use indoc::indoc;
use pretty_assertions::assert_eq;

use super::FilterAction;
use super::FilterActionsBuilder;
use indoc::indoc;
use pretty_assertions::assert_eq;
use std::collections::VecDeque;

const INPUT: &str = indoc! {"
; A comment
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
/// Re-export keyring
#[cfg(feature = "keyring")]
pub use keyring;

// Re-export sub-module
pub use merge::mutations;

Expand Down
6 changes: 2 additions & 4 deletions src/loader.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::io::Read;

use ini_roundtrip::Parser;
use lending_iterator::prelude::*;
use ouroboros::self_referencing;

use ini_roundtrip::Parser;
use std::io::Read;

/// A loader for INI files. Handles the parser state internally.
///
Expand Down
23 changes: 10 additions & 13 deletions src/merge.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
//! INI merger functionality

use std::borrow::Cow;
use std::collections::HashSet;
use std::io::Read;

use lending_iterator::prelude::*;
use log::error;
use thiserror::Error;

use self::mutations::transforms::Transformer;
use self::mutations::Action;
use self::mutations::Mutations;
use self::mutations::SectionAction;
use crate::loader::Loader;
use crate::loader::{self};
use crate::source_loader::SectionAndKey;
use crate::source_loader::SourceIni;
use crate::source_loader::SourceValue;
use crate::source_loader::{self};

use self::mutations::transforms::Transformer;
use self::mutations::Action;
use self::mutations::Mutations;
use self::mutations::SectionAction;
use lending_iterator::prelude::*;
use log::error;
use std::borrow::Cow;
use std::collections::HashSet;
use std::io::Read;
use thiserror::Error;

pub mod mutations;

Expand Down
10 changes: 4 additions & 6 deletions src/merge/mutations.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
//! Define mutations that can be applied to merging

use std::borrow::Cow;
use std::collections::HashMap;
use std::collections::HashSet;

use self::transforms::TransformerDispatch;
use crate::actions::Actions;
use crate::actions::ActionsBuilder;
use crate::actions::ActionsBuilderError;
use crate::mutations::transforms::TransformSet;

use self::transforms::TransformerDispatch;
use std::borrow::Cow;
use std::collections::HashMap;
use std::collections::HashSet;

pub mod transforms;

Expand Down
28 changes: 10 additions & 18 deletions src/merge/mutations/transforms.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
//! Define transfomers that can be applied as mutations

use crate::InputData;
use itertools::Itertools;
#[cfg(feature = "keyring")]
pub use keyring_transform::TransformKeyring;
use std::borrow::Borrow;
use std::borrow::Cow;
use std::collections::HashMap;
use std::collections::HashSet;
use std::hash::Hash;

use itertools::Itertools;
use thiserror::Error;

#[cfg(feature = "keyring")]
pub use keyring_transform::TransformKeyring;

use crate::InputData;

/// The action that a transform decides should happen for a line it processes.
#[derive(Debug, PartialEq, Eq)]
#[non_exhaustive]
Expand Down Expand Up @@ -308,16 +305,13 @@ impl Transformer for TransformSet {

#[cfg(feature = "keyring")]
mod keyring_transform {
use std::borrow::Borrow;
use std::hash::Hash;

use log::error;

use crate::InputData;

use super::Transformer;
use super::TransformerAction;
use super::TransformerConstructionError;
use crate::InputData;
use log::error;
use std::borrow::Borrow;
use std::hash::Hash;

/// Get value from system keyring (secrets service). Useful for passwords
/// etc that you do not want in your dotfiles repo, but sync via some more
Expand Down Expand Up @@ -426,11 +420,9 @@ mod keyring_transform {

#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;

use crate::Property;

use super::*;
use crate::Property;
use pretty_assertions::assert_eq;

#[test]
fn unsorted_lists() {
Expand Down
8 changes: 3 additions & 5 deletions src/merge/tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use std::collections::VecDeque;

use indoc::indoc;
use pretty_assertions::assert_eq;

use crate::mutations::transforms::TransformKdeShortcut;
use crate::mutations::transforms::TransformUnsortedLists;
use crate::mutations::Action;
use crate::mutations::MutationsBuilder;
use crate::mutations::SectionAction;
use indoc::indoc;
use pretty_assertions::assert_eq;
use std::collections::VecDeque;

const SOURCE: &str = indoc! {"
; Comments are ignored in source
Expand Down
13 changes: 5 additions & 8 deletions src/source_loader.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
//! This module handles loading the source INI into a form that is easy for
//! random access (instead of the linear processing we do with the target state
//! INI file).
use lending_iterator::prelude::*;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::io::Read;
use std::ops::Bound;

use lending_iterator::prelude::*;
use thiserror::Error;

/// Newtype for INI section and key
Expand Down Expand Up @@ -136,15 +135,13 @@ pub(crate) fn load_source_ini(data: &mut impl Read) -> Result<SourceIni, SourceL

#[cfg(test)]
mod tests {
use std::borrow::Cow;
use std::collections::VecDeque;

use indoc::indoc;
use pretty_assertions::assert_eq;

use crate::source_loader::SectionAndKey;
use crate::source_loader::SourceValue;
use crate::OUTSIDE_SECTION;
use indoc::indoc;
use pretty_assertions::assert_eq;
use std::borrow::Cow;
use std::collections::VecDeque;

/// Test data
const TEST_DATA: &str = indoc! {"
Expand Down

0 comments on commit bec95ae

Please sign in to comment.