Configuration overview
How to configure Debt-collector
./debt-collector.config.jsdebt-collector check --config ./configs/debt-collector.jsConfiguration Structure
type Config = {
// Glob patterns for files to analyze
includes: string | string[];
// Optional glob patterns for files to exclude
excludes?: string | string[];
// Rules to check in files
fileRules: {
// Required fields
id: string; // Unique identifier in SNAKE_CASE
title: string; // Human-readable description
debtScore: number; // Score to add for each match
// Optional fields
description?: string; // Detailed explanation of the rule
howTo?: string; // Instructions on how to fix the issue
include?: string | string[]; // Rule-specific file patterns
exclude?: string | string[]; // Rule-specific file exclusions
tags?: string | string[]; // Categories for filtering rules
matchRule?: (context: MatchRuleContext) => number; // Rule matching logic
}[];
// Optional walk command configuration
walkConfig?: {
gitCommand: string; // Git command to get revisions
parser: (gitResult: string) => {hash: string; name: string; date: string}[]; // Parse git command output
limit?: number; // Maximum number of revisions to analyze
report?: {
// Report configuration options
};
};
}Rule Types
File Rules
Examples
Basic Configuration
Walk Command Configuration
Best Practices
Common Patterns
Finding Specific Code Patterns
Counting Multiple Patterns
Complex Pattern Matching
Last updated