Skip to content

Commit 5333ebd

Browse files
committed
fix: add comment-line skip for overconfident_comment and return config copy from getConfig
- Add comment-line skip (//, *, /*) for overconfident_comment pattern so JSDoc deprecation comments don't false-positive - Return shallow copy from getConfig() to prevent external mutation
1 parent 8459346 commit 5333ebd

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

ai-slop-detector.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,14 @@ class AISlopDetector {
822822
}
823823
}
824824

825+
// Skip comment-line-only patterns that only make sense in actual code comments
826+
if (pattern.id === 'overconfident_comment') {
827+
const trimmed = line.trim();
828+
if (trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*')) {
829+
continue;
830+
}
831+
}
832+
825833
// In quiet mode, skip test and mock files for all patterns except production console logs
826834
if (quiet && pattern.id !== 'production_console_log') {
827835
const isTestFile = filePath.includes('__tests__') ||
@@ -1120,7 +1128,7 @@ class AISlopDetector {
11201128
* Get the current configuration
11211129
*/
11221130
getConfig(): KarpeSlopConfig {
1123-
return this.config;
1131+
return { ...this.config };
11241132
}
11251133

11261134
/**

karpeslop-bin.js

100644100755
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,14 @@ class AISlopDetector {
691691
}
692692
}
693693

694+
// Skip comment-line-only patterns that only make sense in actual code comments
695+
if (pattern.id === 'overconfident_comment') {
696+
const trimmed = line.trim();
697+
if (trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*')) {
698+
continue;
699+
}
700+
}
701+
694702
// In quiet mode, skip test and mock files for all patterns except production console logs
695703
if (quiet && pattern.id !== 'production_console_log') {
696704
const isTestFile = filePath.includes('__tests__') || filePath.includes('.test.') || filePath.includes('.spec.') || filePath.includes('__mocks__') || filePath.includes('test-');
@@ -955,7 +963,9 @@ class AISlopDetector {
955963
* Get the current configuration
956964
*/
957965
getConfig() {
958-
return this.config;
966+
return {
967+
...this.config
968+
};
959969
}
960970

961971
/**

0 commit comments

Comments
 (0)