detect method
List<DebtItem>
detect(
- CompilationUnit unit,
- String filePath, {
- LineInfo? lineInfo,
- FileMaintainabilityResult? metrics,
- String? sourceCode,
Detect all debt items in a compilation unit.
If sourceCode is provided, it will be used for comment detection.
Otherwise, the source is reconstructed from the compilation unit,
which may not include comments.
Implementation
List<DebtItem> detect(
CompilationUnit unit,
String filePath, {
LineInfo? lineInfo,
FileMaintainabilityResult? metrics,
String? sourceCode,
}) {
final info = lineInfo ?? unit.lineInfo;
final items = <DebtItem>[];
// Detect comment-based debt (TODO, FIXME, ignore)
// Use provided source code for accurate comment detection
final source = sourceCode ?? _extractSourceWithComments(unit);
items.addAll(_detectCommentDebt(source, filePath, info));
// Detect cast-based debt (as dynamic)
items.addAll(_detectCastDebt(unit, filePath, info));
// Detect annotation-based debt (@deprecated)
items.addAll(_detectAnnotationDebt(unit, filePath, info));
// Detect metrics-based debt
if (metrics != null) {
items.addAll(_detectMetricsDebt(metrics, filePath, info));
}
return items;
}