@sun-asterisk/sunlint 1.3.52 → 1.3.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,7 +7,7 @@ class ConfigOverrideProcessor {
|
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
9
|
// Rule C014: Dependency injection for minimatch
|
|
10
|
-
this.minimatch = require('minimatch');
|
|
10
|
+
this.minimatch = require('minimatch').minimatch;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -37,12 +37,27 @@ class ConfigOverrideProcessor {
|
|
|
37
37
|
*/
|
|
38
38
|
shouldApplyOverride(override, filePath) {
|
|
39
39
|
const { files } = override;
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
|
|
41
|
+
// No files pattern means the override applies to all files
|
|
42
|
+
if (!files) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!Array.isArray(files)) {
|
|
42
47
|
return false;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
return files.some(pattern =>
|
|
50
|
+
return files.some(pattern => {
|
|
51
|
+
// Direct match (works when filePath is relative or pattern is absolute)
|
|
52
|
+
if (this.minimatch(filePath, pattern, { dot: true })) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
// For relative patterns, also try with **/ prefix so they match absolute paths
|
|
56
|
+
if (!pattern.startsWith('/')) {
|
|
57
|
+
return this.minimatch(filePath, '**/' + pattern, { dot: true });
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
});
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
/**
|
|
@@ -315,10 +315,9 @@ class SummaryReportService {
|
|
|
315
315
|
analysis_time_ms: archSummary.analysisTime || 0
|
|
316
316
|
};
|
|
317
317
|
|
|
318
|
-
// Add all rules
|
|
318
|
+
// Add all checked rules (passed + failed) to report
|
|
319
319
|
if (options.architecture.allRules && options.architecture.allRules.length > 0) {
|
|
320
320
|
summaryReport.architecture.rules = options.architecture.allRules
|
|
321
|
-
.filter(r => r.score > 0) // Only include rules with evidence (score > 0)
|
|
322
321
|
.map(r => ({
|
|
323
322
|
rule_code: r.ruleId,
|
|
324
323
|
rule_name: r.ruleName,
|
|
@@ -9,6 +9,7 @@ const AnalysisEngineInterface = require('../core/interfaces/analysis-engine.inte
|
|
|
9
9
|
const ASTModuleRegistry = require('../core/ast-modules/index');
|
|
10
10
|
const dependencyChecker = require('../core/dependency-checker');
|
|
11
11
|
const SunlintRuleAdapter = require('../core/adapters/sunlint-rule-adapter');
|
|
12
|
+
const ConfigOverrideProcessor = require('../core/config-override-processor');
|
|
12
13
|
const SemanticEngine = require('../core/semantic-engine');
|
|
13
14
|
const SemanticRuleBase = require('../core/semantic-rule-base');
|
|
14
15
|
const { getInstance: getUnifiedRegistry } = require('../core/unified-rule-registry');
|
|
@@ -76,6 +77,9 @@ class HeuristicEngine extends AnalysisEngineInterface {
|
|
|
76
77
|
// Unified rule registry
|
|
77
78
|
this.unifiedRegistry = getUnifiedRegistry();
|
|
78
79
|
|
|
80
|
+
// Rule C014: Dependency injection for per-file override processing
|
|
81
|
+
this.overrideProcessor = new ConfigOverrideProcessor();
|
|
82
|
+
|
|
79
83
|
// ✅ PERFORMANCE OPTIMIZATIONS (Integrated)
|
|
80
84
|
this.performanceManager = new AutoPerformanceManager();
|
|
81
85
|
this.performanceConfig = null;
|
|
@@ -996,16 +1000,32 @@ class HeuristicEngine extends AnalysisEngineInterface {
|
|
|
996
1000
|
const violationsByFile = this.groupViolationsByFile(ruleViolations);
|
|
997
1001
|
|
|
998
1002
|
for (const [filePath, violations] of violationsByFile) {
|
|
1003
|
+
|
|
1004
|
+
// Apply per-file config overrides — skip violations disabled by overrides
|
|
1005
|
+
let overriddenSeverity = null;
|
|
1006
|
+
if (options.config?.overrides?.length > 0) {
|
|
1007
|
+
const effectiveConfig = this.overrideProcessor.applyFileOverrides(options.config, filePath);
|
|
1008
|
+
const overrideValue = effectiveConfig.rules?.[rule.id];
|
|
1009
|
+
if (overrideValue === 'off') {
|
|
1010
|
+
continue;
|
|
1011
|
+
}
|
|
1012
|
+
if (overrideValue === 'error') {
|
|
1013
|
+
overriddenSeverity = 'error';
|
|
1014
|
+
} else if (overrideValue === 'warn' || overrideValue === 'warning') {
|
|
1015
|
+
overriddenSeverity = 'warning';
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
999
1019
|
// Find or create file result
|
|
1000
1020
|
let fileResult = results.results.find(r => r.file === filePath);
|
|
1001
1021
|
if (!fileResult) {
|
|
1002
1022
|
fileResult = { file: filePath, violations: [] };
|
|
1003
1023
|
results.results.push(fileResult);
|
|
1004
1024
|
}
|
|
1005
|
-
// Apply rule severity to each violation (
|
|
1025
|
+
// Apply rule severity to each violation (override takes precedence over rule default)
|
|
1006
1026
|
const violationsWithSeverity = violations.map(v => ({
|
|
1007
1027
|
...v,
|
|
1008
|
-
severity: rule.severity || v.severity || 'warning'
|
|
1028
|
+
severity: overriddenSeverity || rule.severity || v.severity || 'warning'
|
|
1009
1029
|
}));
|
|
1010
1030
|
fileResult.violations.push(...violationsWithSeverity);
|
|
1011
1031
|
}
|
package/package.json
CHANGED