pub struct Config {
pub classification: ClassificationConfig,
pub weights: WeightsConfig,
pub limits: LimitsConfig,
pub output: OutputConfig,
}Expand description
Main configuration structure
Fields§
§classification: ClassificationConfigClassification settings
weights: WeightsConfigWeight settings
limits: LimitsConfigLimit settings
output: OutputConfigOutput settings
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_file(path: &Path) -> Result<Self, AppError>
pub fn from_file(path: &Path) -> Result<Self, AppError>
Loads configuration from a TOML file
§Arguments
path- Path to the configuration file
§Returns
Loaded configuration or error
§Errors
Returns error if file cannot be read or parsed
§Examples
use std::path::Path;
use rust_diff_analyzer::Config;
let config = Config::from_file(Path::new(".rust-diff-analyzer.toml"));Sourcepub fn test_features_set(&self) -> HashSet<&str>
pub fn test_features_set(&self) -> HashSet<&str>
Sourcepub fn should_ignore(&self, path: &Path) -> bool
pub fn should_ignore(&self, path: &Path) -> bool
Checks if a path should be ignored
Patterns match whole path components: src/gen ignores files under
src/gen/ but not src/generic.rs.
§Arguments
path- Path to check
§Returns
true if path should be ignored
§Examples
use std::path::Path;
use rust_diff_analyzer::Config;
let config = Config::default();
assert!(!config.should_ignore(Path::new("src/lib.rs")));Sourcepub fn matched_ignore_pattern(&self, path: &Path) -> Option<&str>
pub fn matched_ignore_pattern(&self, path: &Path) -> Option<&str>
Returns the first ignore pattern matching the path, if any
§Arguments
path- Path to check
§Returns
The matching pattern or None
§Examples
use std::path::Path;
use rust_diff_analyzer::Config;
let mut config = Config::default();
config
.classification
.ignore_paths
.push("generated/".to_string());
assert_eq!(
config.matched_ignore_pattern(Path::new("generated/api.rs")),
Some("generated/")
);Checks if an author should be ignored
§Arguments
author- Author name to check
§Returns
true if author is in the ignore list
§Examples
use rust_diff_analyzer::Config;
let mut config = Config::default();
config
.classification
.ignored_authors
.push("dependabot[bot]".to_string());
assert!(config.should_ignore_author("dependabot[bot]"));
assert!(!config.should_ignore_author("developer"));Sourcepub fn should_ignore_commit(&self, author: &str) -> bool
pub fn should_ignore_commit(&self, author: &str) -> bool
Checks if a commit should be ignored based on author
This method checks if the given author matches any of the ignored authors. It performs a substring match, so “github-actions[bot]” will match “github-actions[bot]” and “github-actions[bot]@users.noreply.github.com”.
§Arguments
author- Author string from git commit
§Returns
true if the commit author should be ignored
§Examples
use rust_diff_analyzer::Config;
let mut config = Config::default();
config
.classification
.ignored_authors
.push("dependabot".to_string());
assert!(config.should_ignore_author("dependabot[bot]"));Sourcepub fn is_test_path(&self, path: &Path) -> bool
pub fn is_test_path(&self, path: &Path) -> bool
Checks if a path is in a test directory
§Arguments
path- Path to check
§Returns
true if path is in a test directory
§Examples
use std::path::Path;
use rust_diff_analyzer::Config;
let config = Config::default();
assert!(config.is_test_path(Path::new("tests/integration.rs")));
assert!(!config.is_test_path(Path::new("src/lib.rs")));Sourcepub fn is_build_script(&self, path: &Path) -> bool
pub fn is_build_script(&self, path: &Path) -> bool
Checks if path is a build script
§Arguments
path- Path to check
§Returns
true if path is build.rs
§Examples
use std::path::Path;
use rust_diff_analyzer::Config;
let config = Config::default();
assert!(config.is_build_script(Path::new("build.rs")));
assert!(!config.is_build_script(Path::new("src/lib.rs")));