Skip to content

Commit

Permalink
Working well on my notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpeach committed Nov 2, 2024
1 parent ca93eed commit da86f6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct Config {
#[builder(default=r"-|_|\s".to_owned())]
pub filename_spacing_pattern: String,
/// See [`self::cli::Config::filename_match_threshold`]
#[builder(default = 95)]
#[builder(default = 100)]
pub filename_match_threshold: i64,
/// See [`self::cli::Config::exclude`]
#[builder(default=vec![])]
Expand Down
11 changes: 10 additions & 1 deletion src/rules/duplicate_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pub enum NewDuplicateAliasError {
MissingSubstringError(#[from] MissingSubstringError),
#[error(transparent)]
ReplacePairError(#[from] ReplacePairError),
#[error("The file {filename} contains its own alias {alias}")]
AliasAndFilenameSame { filename: Filename, alias: Alias },
}

#[derive(Error, Debug)]
Expand All @@ -108,7 +110,14 @@ impl DuplicateAlias {
file1_path: &PathBuf,
file2_path: &PathBuf,
) -> Result<Self, NewDuplicateAliasError> {
assert_ne!(file1_path, file2_path);
// Boundary conditions
if file1_path == file2_path {
return Err(NewDuplicateAliasError::AliasAndFilenameSame {
filename: get_filename(file1_path.as_path()),
alias: alias.clone(),
});
}

// Create the unique id
let id = format!("{CODE}::{alias}");

Expand Down

0 comments on commit da86f6a

Please sign in to comment.