pub fn calculate_weight(unit: &SemanticUnit, config: &Config) -> usizeExpand description
Calculates the weight score for a semantic unit
§Arguments
unit- Semantic unit to calculate weight forconfig- Configuration with weight settings
§Returns
Weight score for the unit
§Examples
use rust_diff_analyzer::{
classifier::rules::calculate_weight,
config::Config,
types::{LineSpan, SemanticUnit, SemanticUnitKind, Visibility},
};
let unit = SemanticUnit::new(
SemanticUnitKind::Function,
"public_fn".to_string(),
Visibility::Public,
LineSpan::new(1, 10),
vec![],
);
let config = Config::default();
let weight = calculate_weight(&unit, &config);
assert_eq!(weight, 3); // default public function weight