slopbrick 0.26.0 → 0.27.0
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.
- package/dist/engine/worker.cjs +10 -745
- package/dist/engine/worker.js +10 -745
- package/dist/index.cjs +16 -851
- package/dist/index.js +16 -851
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ var VERSION;
|
|
|
36
36
|
var init_header = __esm({
|
|
37
37
|
"src/types/_header.ts"() {
|
|
38
38
|
"use strict";
|
|
39
|
-
VERSION = "0.
|
|
39
|
+
VERSION = "0.27.0";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
@@ -30662,589 +30662,6 @@ var init_struct_tag_inconsistency = __esm({
|
|
|
30662
30662
|
}
|
|
30663
30663
|
});
|
|
30664
30664
|
|
|
30665
|
-
// src/rules/java/arraylist-vs-linkedlist.ts
|
|
30666
|
-
var NEW_LINKED_LIST_REGEX, javaArraylistVsLinkedlistRule;
|
|
30667
|
-
var init_arraylist_vs_linkedlist = __esm({
|
|
30668
|
-
"src/rules/java/arraylist-vs-linkedlist.ts"() {
|
|
30669
|
-
"use strict";
|
|
30670
|
-
init_rule();
|
|
30671
|
-
NEW_LINKED_LIST_REGEX = /new\s+LinkedList\s*</g;
|
|
30672
|
-
javaArraylistVsLinkedlistRule = createRule({
|
|
30673
|
-
id: "java/arraylist-vs-linkedlist",
|
|
30674
|
-
category: "typo",
|
|
30675
|
-
severity: "low",
|
|
30676
|
-
aiSpecific: true,
|
|
30677
|
-
description: "new LinkedList<>() \u2014 use ArrayList (Effective Java, Item 28)",
|
|
30678
|
-
create(_context) {
|
|
30679
|
-
return {};
|
|
30680
|
-
},
|
|
30681
|
-
analyze(_context, facts) {
|
|
30682
|
-
const issues = [];
|
|
30683
|
-
const source = facts.v2?._source;
|
|
30684
|
-
if (!source) return issues;
|
|
30685
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
30686
|
-
let m;
|
|
30687
|
-
NEW_LINKED_LIST_REGEX.lastIndex = 0;
|
|
30688
|
-
while ((m = NEW_LINKED_LIST_REGEX.exec(source)) !== null) {
|
|
30689
|
-
const line = source.slice(0, m.index).split("\n").length;
|
|
30690
|
-
issues.push({
|
|
30691
|
-
ruleId: "java/arraylist-vs-linkedlist",
|
|
30692
|
-
category: "typo",
|
|
30693
|
-
severity: "low",
|
|
30694
|
-
aiSpecific: true,
|
|
30695
|
-
message: `new LinkedList at line ${line} \u2014 use ArrayList instead`,
|
|
30696
|
-
line,
|
|
30697
|
-
column: 1,
|
|
30698
|
-
advice: "Replace `new LinkedList<>()` with `new ArrayList<>()`. LinkedList is rarely the right choice (worse cache locality, 5x more memory per element, O(n) indexed access). Joshua Bloch (Effective Java, Item 28) recommends ArrayList unless you specifically need a Deque. AI agents default to LinkedList because of textbook examples. Reference: java/arraylist-vs-linkedlist v0.20."
|
|
30699
|
-
});
|
|
30700
|
-
}
|
|
30701
|
-
return issues;
|
|
30702
|
-
}
|
|
30703
|
-
});
|
|
30704
|
-
}
|
|
30705
|
-
});
|
|
30706
|
-
|
|
30707
|
-
// src/rules/java/builder-overuse.ts
|
|
30708
|
-
var BUILDER_ANNOTATION_REGEX, FIELD_DECL_REGEX, DEFAULT_FIELD_COUNT_CAP, javaBuilderOveruseRule;
|
|
30709
|
-
var init_builder_overuse = __esm({
|
|
30710
|
-
"src/rules/java/builder-overuse.ts"() {
|
|
30711
|
-
"use strict";
|
|
30712
|
-
init_rule();
|
|
30713
|
-
BUILDER_ANNOTATION_REGEX = /@Builder\b/;
|
|
30714
|
-
FIELD_DECL_REGEX = /(?:private|public|protected)\s+(?:final\s+)?[\w<>,\s]+\s+(\w+)\s*[=;]/g;
|
|
30715
|
-
DEFAULT_FIELD_COUNT_CAP = 3;
|
|
30716
|
-
javaBuilderOveruseRule = createRule({
|
|
30717
|
-
id: "java/builder-overuse",
|
|
30718
|
-
category: "typo",
|
|
30719
|
-
severity: "low",
|
|
30720
|
-
aiSpecific: true,
|
|
30721
|
-
description: "@Builder on a class with few fields \u2014 plain constructor is simpler",
|
|
30722
|
-
create(_context) {
|
|
30723
|
-
return { fieldCountCap: DEFAULT_FIELD_COUNT_CAP };
|
|
30724
|
-
},
|
|
30725
|
-
analyze(context, facts) {
|
|
30726
|
-
const issues = [];
|
|
30727
|
-
const source = facts.v2?._source;
|
|
30728
|
-
if (!source) return issues;
|
|
30729
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
30730
|
-
BUILDER_ANNOTATION_REGEX.lastIndex = 0;
|
|
30731
|
-
const builderMatch = BUILDER_ANNOTATION_REGEX.exec(source);
|
|
30732
|
-
if (!builderMatch) return issues;
|
|
30733
|
-
const firstBuilderLine = source.slice(0, builderMatch.index).split("\n").length;
|
|
30734
|
-
FIELD_DECL_REGEX.lastIndex = 0;
|
|
30735
|
-
let fieldCount = 0;
|
|
30736
|
-
while (FIELD_DECL_REGEX.exec(source) !== null) {
|
|
30737
|
-
fieldCount++;
|
|
30738
|
-
}
|
|
30739
|
-
if (fieldCount > context.fieldCountCap) return issues;
|
|
30740
|
-
issues.push({
|
|
30741
|
-
ruleId: "java/builder-overuse",
|
|
30742
|
-
category: "typo",
|
|
30743
|
-
severity: "low",
|
|
30744
|
-
aiSpecific: true,
|
|
30745
|
-
message: `@Builder on a class with ${fieldCount} field(s) \u2014 plain constructor is simpler`,
|
|
30746
|
-
line: firstBuilderLine,
|
|
30747
|
-
column: 1,
|
|
30748
|
-
advice: "Use a plain constructor for classes with \u2264 3 fields. AI agents default to @Builder because their training data emphasizes the pattern. Builder adds Lombok dependency and a Builder inner class for every annotated class. Reference: java/builder-overuse v0.26.0."
|
|
30749
|
-
});
|
|
30750
|
-
return issues;
|
|
30751
|
-
}
|
|
30752
|
-
});
|
|
30753
|
-
}
|
|
30754
|
-
});
|
|
30755
|
-
|
|
30756
|
-
// src/rules/java/empty-catch-block.ts
|
|
30757
|
-
var SINGLE_LINE_EMPTY_CATCH_REGEX, javaEmptyCatchBlockRule;
|
|
30758
|
-
var init_empty_catch_block = __esm({
|
|
30759
|
-
"src/rules/java/empty-catch-block.ts"() {
|
|
30760
|
-
"use strict";
|
|
30761
|
-
init_rule();
|
|
30762
|
-
SINGLE_LINE_EMPTY_CATCH_REGEX = /catch\s*\([^)]*\)\s*\{\s*\}/g;
|
|
30763
|
-
javaEmptyCatchBlockRule = createRule({
|
|
30764
|
-
id: "java/empty-catch-block",
|
|
30765
|
-
category: "logic",
|
|
30766
|
-
severity: "medium",
|
|
30767
|
-
aiSpecific: true,
|
|
30768
|
-
description: "Empty catch block \u2014 silently swallows exceptions",
|
|
30769
|
-
create(_context) {
|
|
30770
|
-
return {};
|
|
30771
|
-
},
|
|
30772
|
-
analyze(_context, facts) {
|
|
30773
|
-
const issues = [];
|
|
30774
|
-
const source = facts.v2?._source;
|
|
30775
|
-
if (!source) return issues;
|
|
30776
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
30777
|
-
let m;
|
|
30778
|
-
SINGLE_LINE_EMPTY_CATCH_REGEX.lastIndex = 0;
|
|
30779
|
-
while ((m = SINGLE_LINE_EMPTY_CATCH_REGEX.exec(source)) !== null) {
|
|
30780
|
-
const line = source.slice(0, m.index).split("\n").length;
|
|
30781
|
-
issues.push({
|
|
30782
|
-
ruleId: "java/empty-catch-block",
|
|
30783
|
-
category: "logic",
|
|
30784
|
-
severity: "medium",
|
|
30785
|
-
aiSpecific: true,
|
|
30786
|
-
message: `Empty catch block at line ${line} \u2014 exception is silently swallowed`,
|
|
30787
|
-
line,
|
|
30788
|
-
column: 1,
|
|
30789
|
-
advice: 'Log the exception (`log.error("...", e)`), re-throw it, or both. Empty catch blocks hide bugs. The pattern is common in AI-generated code that wants to look defensive. Reference: java/empty-catch-block v0.20.'
|
|
30790
|
-
});
|
|
30791
|
-
}
|
|
30792
|
-
return issues;
|
|
30793
|
-
}
|
|
30794
|
-
});
|
|
30795
|
-
}
|
|
30796
|
-
});
|
|
30797
|
-
|
|
30798
|
-
// src/rules/java/immutable-collection-preference.ts
|
|
30799
|
-
var IMMUTABLE_REGEX, MUTABLE_REGEX, DEFAULT_IMMUTABLE_THRESHOLD, DEFAULT_MUTABLE_CAP, javaImmutableCollectionPreferenceRule;
|
|
30800
|
-
var init_immutable_collection_preference = __esm({
|
|
30801
|
-
"src/rules/java/immutable-collection-preference.ts"() {
|
|
30802
|
-
"use strict";
|
|
30803
|
-
init_rule();
|
|
30804
|
-
IMMUTABLE_REGEX = /\b(List|Map|Set)\.of\s*\(/g;
|
|
30805
|
-
MUTABLE_REGEX = /new\s+(ArrayList|HashMap|HashSet|LinkedList|TreeMap)\s*[<(]/g;
|
|
30806
|
-
DEFAULT_IMMUTABLE_THRESHOLD = 5;
|
|
30807
|
-
DEFAULT_MUTABLE_CAP = 1;
|
|
30808
|
-
javaImmutableCollectionPreferenceRule = createRule({
|
|
30809
|
-
id: "java/immutable-collection-preference",
|
|
30810
|
-
category: "typo",
|
|
30811
|
-
severity: "low",
|
|
30812
|
-
aiSpecific: true,
|
|
30813
|
-
description: "Immutable factory method over-use \u2014 prefer mutable when collection will be modified",
|
|
30814
|
-
create(_context) {
|
|
30815
|
-
return {
|
|
30816
|
-
immutableThreshold: DEFAULT_IMMUTABLE_THRESHOLD,
|
|
30817
|
-
mutableCap: DEFAULT_MUTABLE_CAP
|
|
30818
|
-
};
|
|
30819
|
-
},
|
|
30820
|
-
analyze(context, facts) {
|
|
30821
|
-
const issues = [];
|
|
30822
|
-
const source = facts.v2?._source;
|
|
30823
|
-
if (!source) return issues;
|
|
30824
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
30825
|
-
IMMUTABLE_REGEX.lastIndex = 0;
|
|
30826
|
-
let immutableCount = 0;
|
|
30827
|
-
let firstIdx = 0;
|
|
30828
|
-
let m;
|
|
30829
|
-
while ((m = IMMUTABLE_REGEX.exec(source)) !== null) {
|
|
30830
|
-
immutableCount++;
|
|
30831
|
-
if (firstIdx === 0) firstIdx = m.index;
|
|
30832
|
-
}
|
|
30833
|
-
if (immutableCount < context.immutableThreshold) return issues;
|
|
30834
|
-
MUTABLE_REGEX.lastIndex = 0;
|
|
30835
|
-
let mutableCount = 0;
|
|
30836
|
-
while ((m = MUTABLE_REGEX.exec(source)) !== null) {
|
|
30837
|
-
mutableCount++;
|
|
30838
|
-
}
|
|
30839
|
-
if (mutableCount > context.mutableCap) return issues;
|
|
30840
|
-
const line = source.slice(0, firstIdx).split("\n").length;
|
|
30841
|
-
issues.push({
|
|
30842
|
-
ruleId: "java/immutable-collection-preference",
|
|
30843
|
-
category: "typo",
|
|
30844
|
-
severity: "low",
|
|
30845
|
-
aiSpecific: true,
|
|
30846
|
-
message: `${immutableCount} immutable factory calls (List/Map/Set.of) with only ${mutableCount} mutable collection \u2014 likely over-preferring immutability`,
|
|
30847
|
-
line,
|
|
30848
|
-
column: 1,
|
|
30849
|
-
advice: "Prefer mutable collections (new ArrayList<>()) when the collection will be modified later. AI agents default to List.of/Map.of/Set.of because their training data emphasizes functional-style Java. Reference: java/immutable-collection-preference v0.26.0."
|
|
30850
|
-
});
|
|
30851
|
-
return issues;
|
|
30852
|
-
}
|
|
30853
|
-
});
|
|
30854
|
-
}
|
|
30855
|
-
});
|
|
30856
|
-
|
|
30857
|
-
// src/rules/java/legacy-date-api.ts
|
|
30858
|
-
var LEGACY_IMPORT_REGEX, LEGACY_USAGE_REGEX, CALENDAR_GET_INSTANCE_REGEX, javaLegacyDateApiRule;
|
|
30859
|
-
var init_legacy_date_api = __esm({
|
|
30860
|
-
"src/rules/java/legacy-date-api.ts"() {
|
|
30861
|
-
"use strict";
|
|
30862
|
-
init_rule();
|
|
30863
|
-
LEGACY_IMPORT_REGEX = /^import\s+(?:static\s+)?java\.(?:util|sql)\.(?:Date|Calendar|GregorianCalendar)\s*;/gm;
|
|
30864
|
-
LEGACY_USAGE_REGEX = /\bnew\s+(?:Date|GregorianCalendar)\s*\(/g;
|
|
30865
|
-
CALENDAR_GET_INSTANCE_REGEX = /Calendar\.getInstance\s*\(/g;
|
|
30866
|
-
javaLegacyDateApiRule = createRule({
|
|
30867
|
-
id: "java/legacy-date-api",
|
|
30868
|
-
category: "typo",
|
|
30869
|
-
severity: "low",
|
|
30870
|
-
aiSpecific: true,
|
|
30871
|
-
description: "Legacy java.util.Date / Calendar \u2014 use java.time (JSR-310) from Java 8+",
|
|
30872
|
-
create(_context) {
|
|
30873
|
-
return {};
|
|
30874
|
-
},
|
|
30875
|
-
analyze(_context, facts) {
|
|
30876
|
-
const issues = [];
|
|
30877
|
-
const source = facts.v2?._source;
|
|
30878
|
-
if (!source) return issues;
|
|
30879
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
30880
|
-
const flagged = /* @__PURE__ */ new Set();
|
|
30881
|
-
let m;
|
|
30882
|
-
LEGACY_IMPORT_REGEX.lastIndex = 0;
|
|
30883
|
-
while ((m = LEGACY_IMPORT_REGEX.exec(source)) !== null) {
|
|
30884
|
-
const line = source.slice(0, m.index).split("\n").length;
|
|
30885
|
-
flagged.add(line);
|
|
30886
|
-
issues.push({
|
|
30887
|
-
ruleId: "java/legacy-date-api",
|
|
30888
|
-
category: "typo",
|
|
30889
|
-
severity: "low",
|
|
30890
|
-
aiSpecific: true,
|
|
30891
|
-
message: `Legacy date import at line ${line} \u2014 use java.time (JSR-310) from Java 8+`,
|
|
30892
|
-
line,
|
|
30893
|
-
column: 1,
|
|
30894
|
-
advice: "Replace `java.util.Date` / `java.util.Calendar` with `java.time` (`LocalDate`, `LocalDateTime`, `Instant`, `ZonedDateTime`). java.time is immutable, thread-safe, and has a much better API. AI agents default to the legacy API because their training data predates Java 8 (2014). Reference: java/legacy-date-api v0.20."
|
|
30895
|
-
});
|
|
30896
|
-
}
|
|
30897
|
-
LEGACY_USAGE_REGEX.lastIndex = 0;
|
|
30898
|
-
while ((m = LEGACY_USAGE_REGEX.exec(source)) !== null) {
|
|
30899
|
-
const line = source.slice(0, m.index).split("\n").length;
|
|
30900
|
-
if (flagged.has(line)) continue;
|
|
30901
|
-
issues.push({
|
|
30902
|
-
ruleId: "java/legacy-date-api",
|
|
30903
|
-
category: "typo",
|
|
30904
|
-
severity: "low",
|
|
30905
|
-
aiSpecific: true,
|
|
30906
|
-
message: `new Date() / GregorianCalendar at line ${line} \u2014 use java.time`,
|
|
30907
|
-
line,
|
|
30908
|
-
column: 1,
|
|
30909
|
-
advice: "Replace with `LocalDate.now()`, `Instant.now()`, or `ZonedDateTime.now()`. Reference: java/legacy-date-api v0.20."
|
|
30910
|
-
});
|
|
30911
|
-
}
|
|
30912
|
-
CALENDAR_GET_INSTANCE_REGEX.lastIndex = 0;
|
|
30913
|
-
while ((m = CALENDAR_GET_INSTANCE_REGEX.exec(source)) !== null) {
|
|
30914
|
-
const line = source.slice(0, m.index).split("\n").length;
|
|
30915
|
-
if (flagged.has(line)) continue;
|
|
30916
|
-
issues.push({
|
|
30917
|
-
ruleId: "java/legacy-date-api",
|
|
30918
|
-
category: "typo",
|
|
30919
|
-
severity: "low",
|
|
30920
|
-
aiSpecific: true,
|
|
30921
|
-
message: `Calendar.getInstance() at line ${line} \u2014 use java.time`,
|
|
30922
|
-
line,
|
|
30923
|
-
column: 1,
|
|
30924
|
-
advice: "Replace with `LocalDate.now()` (date-only) or `ZonedDateTime.now()`. Reference: java/legacy-date-api v0.20."
|
|
30925
|
-
});
|
|
30926
|
-
}
|
|
30927
|
-
return issues;
|
|
30928
|
-
}
|
|
30929
|
-
});
|
|
30930
|
-
}
|
|
30931
|
-
});
|
|
30932
|
-
|
|
30933
|
-
// src/rules/java/optional-overuse.ts
|
|
30934
|
-
var OR_ELSE_THROW_REGEX, NULL_CHECK_REGEX, DEFAULT_THRESHOLD, javaOptionalOveruseRule;
|
|
30935
|
-
var init_optional_overuse = __esm({
|
|
30936
|
-
"src/rules/java/optional-overuse.ts"() {
|
|
30937
|
-
"use strict";
|
|
30938
|
-
init_rule();
|
|
30939
|
-
OR_ELSE_THROW_REGEX = /\.orElseThrow\s*\(/g;
|
|
30940
|
-
NULL_CHECK_REGEX = /Objects\.requireNonNull\s*\(|if\s*\([^)]*==\s*null\)\s*(?:throw|return)/g;
|
|
30941
|
-
DEFAULT_THRESHOLD = 2;
|
|
30942
|
-
javaOptionalOveruseRule = createRule({
|
|
30943
|
-
id: "java/optional-overuse",
|
|
30944
|
-
category: "typo",
|
|
30945
|
-
severity: "low",
|
|
30946
|
-
aiSpecific: true,
|
|
30947
|
-
description: "Optional chain over-use \u2014 null check or Objects.requireNonNull is faster",
|
|
30948
|
-
create(_context) {
|
|
30949
|
-
return { threshold: DEFAULT_THRESHOLD };
|
|
30950
|
-
},
|
|
30951
|
-
analyze(context, facts) {
|
|
30952
|
-
const issues = [];
|
|
30953
|
-
const source = facts.v2?._source;
|
|
30954
|
-
if (!source) return issues;
|
|
30955
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
30956
|
-
OR_ELSE_THROW_REGEX.lastIndex = 0;
|
|
30957
|
-
let orElseThrowCount = 0;
|
|
30958
|
-
let firstIdx = 0;
|
|
30959
|
-
let m;
|
|
30960
|
-
while ((m = OR_ELSE_THROW_REGEX.exec(source)) !== null) {
|
|
30961
|
-
orElseThrowCount++;
|
|
30962
|
-
if (firstIdx === 0) firstIdx = m.index;
|
|
30963
|
-
}
|
|
30964
|
-
if (orElseThrowCount < context.threshold) return issues;
|
|
30965
|
-
NULL_CHECK_REGEX.lastIndex = 0;
|
|
30966
|
-
const nullCheckCount = (source.match(NULL_CHECK_REGEX) ?? []).length;
|
|
30967
|
-
const optionalRatio = orElseThrowCount / Math.max(orElseThrowCount + nullCheckCount, 1);
|
|
30968
|
-
if (optionalRatio < 0.6) return issues;
|
|
30969
|
-
const line = source.slice(0, firstIdx).split("\n").length;
|
|
30970
|
-
issues.push({
|
|
30971
|
-
ruleId: "java/optional-overuse",
|
|
30972
|
-
category: "typo",
|
|
30973
|
-
severity: "low",
|
|
30974
|
-
aiSpecific: true,
|
|
30975
|
-
message: `${orElseThrowCount} .orElseThrow() calls with ${nullCheckCount} null checks \u2014 Optional chain over-use`,
|
|
30976
|
-
line,
|
|
30977
|
-
column: 1,
|
|
30978
|
-
advice: 'Use Objects.requireNonNull(x, "msg") for null checks; reserve Optional for return values. AI agents default to Optional chains because their training data emphasizes null-safety. Real Java code uses null checks in hot paths. Reference: java/optional-overuse v0.26.0.'
|
|
30979
|
-
});
|
|
30980
|
-
return issues;
|
|
30981
|
-
}
|
|
30982
|
-
});
|
|
30983
|
-
}
|
|
30984
|
-
});
|
|
30985
|
-
|
|
30986
|
-
// src/rules/java/raw-type-overuse.ts
|
|
30987
|
-
var RAW_TYPE_REGEX, javaRawTypeOveruseRule;
|
|
30988
|
-
var init_raw_type_overuse = __esm({
|
|
30989
|
-
"src/rules/java/raw-type-overuse.ts"() {
|
|
30990
|
-
"use strict";
|
|
30991
|
-
init_rule();
|
|
30992
|
-
RAW_TYPE_REGEX = /\b(List|Map|Set|Collection|Iterable)\s+(?![<A-Z])(\w+)/g;
|
|
30993
|
-
javaRawTypeOveruseRule = createRule({
|
|
30994
|
-
id: "java/raw-type-overuse",
|
|
30995
|
-
category: "typo",
|
|
30996
|
-
severity: "low",
|
|
30997
|
-
aiSpecific: true,
|
|
30998
|
-
description: "Raw type usage (List, Map, Set) \u2014 use generics (Effective Java, Item 23)",
|
|
30999
|
-
create(_context) {
|
|
31000
|
-
return {};
|
|
31001
|
-
},
|
|
31002
|
-
analyze(_context, facts) {
|
|
31003
|
-
const issues = [];
|
|
31004
|
-
const source = facts.v2?._source;
|
|
31005
|
-
if (!source) return issues;
|
|
31006
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
31007
|
-
let m;
|
|
31008
|
-
RAW_TYPE_REGEX.lastIndex = 0;
|
|
31009
|
-
while ((m = RAW_TYPE_REGEX.exec(source)) !== null) {
|
|
31010
|
-
const typeName = m[1];
|
|
31011
|
-
const line = source.slice(0, m.index).split("\n").length;
|
|
31012
|
-
issues.push({
|
|
31013
|
-
ruleId: "java/raw-type-overuse",
|
|
31014
|
-
category: "typo",
|
|
31015
|
-
severity: "low",
|
|
31016
|
-
aiSpecific: true,
|
|
31017
|
-
message: `Raw type ${typeName} at line ${line} \u2014 add type parameters`,
|
|
31018
|
-
line,
|
|
31019
|
-
column: 1,
|
|
31020
|
-
advice: `Replace raw \`${typeName}\` with \`${typeName}<...>\`. Raw types disable generic type checking. Effective Java, Item 23: 'Don't use raw types in new code'. AI agents default to raw types when unsure of the correct generic parameters. Reference: java/raw-type-overuse v0.20.`
|
|
31021
|
-
});
|
|
31022
|
-
}
|
|
31023
|
-
return issues;
|
|
31024
|
-
}
|
|
31025
|
-
});
|
|
31026
|
-
}
|
|
31027
|
-
});
|
|
31028
|
-
|
|
31029
|
-
// src/rules/java/stream-overuse.ts
|
|
31030
|
-
var STREAM_OPS, DEFAULT_CHAIN_THRESHOLD, javaStreamOveruseRule;
|
|
31031
|
-
var init_stream_overuse = __esm({
|
|
31032
|
-
"src/rules/java/stream-overuse.ts"() {
|
|
31033
|
-
"use strict";
|
|
31034
|
-
init_rule();
|
|
31035
|
-
STREAM_OPS = [
|
|
31036
|
-
".map(",
|
|
31037
|
-
".filter(",
|
|
31038
|
-
".flatMap(",
|
|
31039
|
-
".collect(",
|
|
31040
|
-
".reduce(",
|
|
31041
|
-
".sorted(",
|
|
31042
|
-
".distinct(",
|
|
31043
|
-
".limit(",
|
|
31044
|
-
".skip(",
|
|
31045
|
-
".anyMatch(",
|
|
31046
|
-
".allMatch(",
|
|
31047
|
-
".noneMatch(",
|
|
31048
|
-
".findFirst(",
|
|
31049
|
-
".findAny("
|
|
31050
|
-
];
|
|
31051
|
-
DEFAULT_CHAIN_THRESHOLD = 3;
|
|
31052
|
-
javaStreamOveruseRule = createRule({
|
|
31053
|
-
id: "java/stream-overuse",
|
|
31054
|
-
category: "typo",
|
|
31055
|
-
severity: "low",
|
|
31056
|
-
aiSpecific: true,
|
|
31057
|
-
description: "Stream API chain over-use \u2014 for-loop is faster for simple transformations",
|
|
31058
|
-
create(_context) {
|
|
31059
|
-
return { chainThreshold: DEFAULT_CHAIN_THRESHOLD };
|
|
31060
|
-
},
|
|
31061
|
-
analyze(context, facts) {
|
|
31062
|
-
const issues = [];
|
|
31063
|
-
const source = facts.v2?._source;
|
|
31064
|
-
if (!source) return issues;
|
|
31065
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
31066
|
-
const lines = source.split("\n");
|
|
31067
|
-
const streamOpPattern = new RegExp(STREAM_OPS.map((op) => op.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), "g");
|
|
31068
|
-
let firstOffendingLine = 0;
|
|
31069
|
-
let firstOffendingCount = 0;
|
|
31070
|
-
for (let i = 0; i < lines.length; i++) {
|
|
31071
|
-
const line = lines[i] ?? "";
|
|
31072
|
-
if (line.trim().startsWith("//") || line.trim().startsWith("*")) continue;
|
|
31073
|
-
const matches = line.match(streamOpPattern);
|
|
31074
|
-
if (matches && matches.length >= context.chainThreshold) {
|
|
31075
|
-
if (firstOffendingLine === 0) {
|
|
31076
|
-
firstOffendingLine = i + 1;
|
|
31077
|
-
firstOffendingCount = matches.length;
|
|
31078
|
-
}
|
|
31079
|
-
}
|
|
31080
|
-
}
|
|
31081
|
-
if (firstOffendingLine === 0) return issues;
|
|
31082
|
-
issues.push({
|
|
31083
|
-
ruleId: "java/stream-overuse",
|
|
31084
|
-
category: "typo",
|
|
31085
|
-
severity: "low",
|
|
31086
|
-
aiSpecific: true,
|
|
31087
|
-
message: `${firstOffendingCount} stream operations on a single line \u2014 for-loop is faster`,
|
|
31088
|
-
line: firstOffendingLine,
|
|
31089
|
-
column: 1,
|
|
31090
|
-
advice: "Prefer a for-loop for simple transformations. AI agents default to Stream API chains because their training data emphasizes functional-style Java. Stream chains allocate intermediate objects; for small collections, a for-loop is faster and more readable. Reference: java/stream-overuse v0.26.0."
|
|
31091
|
-
});
|
|
31092
|
-
return issues;
|
|
31093
|
-
}
|
|
31094
|
-
});
|
|
31095
|
-
}
|
|
31096
|
-
});
|
|
31097
|
-
|
|
31098
|
-
// src/rules/java/string-concat-loop.ts
|
|
31099
|
-
var STRING_CONCAT_REGEX, javaStringConcatLoopRule;
|
|
31100
|
-
var init_string_concat_loop = __esm({
|
|
31101
|
-
"src/rules/java/string-concat-loop.ts"() {
|
|
31102
|
-
"use strict";
|
|
31103
|
-
init_rule();
|
|
31104
|
-
STRING_CONCAT_REGEX = /(\b\w+)\s*=\s*\1\s*\+\s*[^;]+;|(\b\w+)\s*\+=\s*['"`]/g;
|
|
31105
|
-
javaStringConcatLoopRule = createRule({
|
|
31106
|
-
id: "java/string-concat-loop",
|
|
31107
|
-
category: "perf",
|
|
31108
|
-
severity: "low",
|
|
31109
|
-
aiSpecific: true,
|
|
31110
|
-
description: "String concatenation in a loop \u2014 use StringBuilder",
|
|
31111
|
-
create(_context) {
|
|
31112
|
-
return {};
|
|
31113
|
-
},
|
|
31114
|
-
analyze(_context, facts) {
|
|
31115
|
-
const issues = [];
|
|
31116
|
-
const source = facts.v2?._source;
|
|
31117
|
-
if (!source) return issues;
|
|
31118
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
31119
|
-
if (!/\b(for|while|do)\b/.test(source)) return issues;
|
|
31120
|
-
let m;
|
|
31121
|
-
STRING_CONCAT_REGEX.lastIndex = 0;
|
|
31122
|
-
while ((m = STRING_CONCAT_REGEX.exec(source)) !== null) {
|
|
31123
|
-
const line = source.slice(0, m.index).split("\n").length;
|
|
31124
|
-
issues.push({
|
|
31125
|
-
ruleId: "java/string-concat-loop",
|
|
31126
|
-
category: "perf",
|
|
31127
|
-
severity: "low",
|
|
31128
|
-
aiSpecific: true,
|
|
31129
|
-
message: `String concatenation in a loop at line ${line} \u2014 use StringBuilder`,
|
|
31130
|
-
line,
|
|
31131
|
-
column: 1,
|
|
31132
|
-
advice: "Declare a `StringBuilder` outside the loop: `StringBuilder sb = new StringBuilder(); sb.append(...);` then `return sb.toString();` after the loop. String concatenation in a loop is O(n\xB2) \u2014 each iteration copies the prior string. AI agents concatenate strings in loops because of training-data examples. Reference: java/string-concat-loop v0.20."
|
|
31133
|
-
});
|
|
31134
|
-
}
|
|
31135
|
-
return issues;
|
|
31136
|
-
}
|
|
31137
|
-
});
|
|
31138
|
-
}
|
|
31139
|
-
});
|
|
31140
|
-
|
|
31141
|
-
// src/rules/java/system-out-println.ts
|
|
31142
|
-
var PRINTLN_REGEX, DEFAULT_THRESHOLD2, javaSystemOutPrintlnRule;
|
|
31143
|
-
var init_system_out_println = __esm({
|
|
31144
|
-
"src/rules/java/system-out-println.ts"() {
|
|
31145
|
-
"use strict";
|
|
31146
|
-
init_rule();
|
|
31147
|
-
PRINTLN_REGEX = /System\.out\.println\s*\(/g;
|
|
31148
|
-
DEFAULT_THRESHOLD2 = 1;
|
|
31149
|
-
javaSystemOutPrintlnRule = createRule({
|
|
31150
|
-
id: "java/system-out-println",
|
|
31151
|
-
category: "typo",
|
|
31152
|
-
severity: "low",
|
|
31153
|
-
aiSpecific: true,
|
|
31154
|
-
description: "System.out.println in production code \u2014 use a logger (SLF4J, Log4j, etc.)",
|
|
31155
|
-
create(_context) {
|
|
31156
|
-
return { threshold: DEFAULT_THRESHOLD2 };
|
|
31157
|
-
},
|
|
31158
|
-
analyze(context, facts) {
|
|
31159
|
-
const issues = [];
|
|
31160
|
-
const source = facts.v2?._source;
|
|
31161
|
-
if (!source) return issues;
|
|
31162
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
31163
|
-
const matches = [];
|
|
31164
|
-
let m;
|
|
31165
|
-
PRINTLN_REGEX.lastIndex = 0;
|
|
31166
|
-
while ((m = PRINTLN_REGEX.exec(source)) !== null) {
|
|
31167
|
-
matches.push(m.index);
|
|
31168
|
-
}
|
|
31169
|
-
if (matches.length <= context.threshold) return issues;
|
|
31170
|
-
const cap = Math.min(matches.length, 10);
|
|
31171
|
-
for (let i = 0; i < cap; i++) {
|
|
31172
|
-
const idx = matches[i];
|
|
31173
|
-
const line = source.slice(0, idx).split("\n").length;
|
|
31174
|
-
issues.push({
|
|
31175
|
-
ruleId: "java/system-out-println",
|
|
31176
|
-
category: "typo",
|
|
31177
|
-
severity: "low",
|
|
31178
|
-
aiSpecific: true,
|
|
31179
|
-
message: `System.out.println at line ${line} \u2014 use a logger for production output`,
|
|
31180
|
-
line,
|
|
31181
|
-
column: 1,
|
|
31182
|
-
advice: "Replace with `private static final Logger log = LoggerFactory.getLogger(...);` then `log.info(...)`. AI agents default to println because their training data has countless textbook examples. Real Java code uses a logger. Reference: java/system-out-println v0.20."
|
|
31183
|
-
});
|
|
31184
|
-
}
|
|
31185
|
-
return issues;
|
|
31186
|
-
}
|
|
31187
|
-
});
|
|
31188
|
-
}
|
|
31189
|
-
});
|
|
31190
|
-
|
|
31191
|
-
// src/rules/java/verbose-javadoc.ts
|
|
31192
|
-
var TAG_REGEX, DEFAULT_TAG_THRESHOLD, DEFAULT_BODY_LENGTH_CAP, javaVerboseJavadocRule;
|
|
31193
|
-
var init_verbose_javadoc = __esm({
|
|
31194
|
-
"src/rules/java/verbose-javadoc.ts"() {
|
|
31195
|
-
"use strict";
|
|
31196
|
-
init_rule();
|
|
31197
|
-
TAG_REGEX = /@(param|return|throws)\b/g;
|
|
31198
|
-
DEFAULT_TAG_THRESHOLD = 3;
|
|
31199
|
-
DEFAULT_BODY_LENGTH_CAP = 5;
|
|
31200
|
-
javaVerboseJavadocRule = createRule({
|
|
31201
|
-
id: "java/verbose-javadoc",
|
|
31202
|
-
category: "typo",
|
|
31203
|
-
severity: "low",
|
|
31204
|
-
aiSpecific: true,
|
|
31205
|
-
description: "Excessive Javadoc tags on trivial methods \u2014 over-documentation is an AI fingerprint",
|
|
31206
|
-
create(_context) {
|
|
31207
|
-
return {
|
|
31208
|
-
tagThreshold: DEFAULT_TAG_THRESHOLD,
|
|
31209
|
-
bodyLengthCap: DEFAULT_BODY_LENGTH_CAP
|
|
31210
|
-
};
|
|
31211
|
-
},
|
|
31212
|
-
analyze(context, facts) {
|
|
31213
|
-
const issues = [];
|
|
31214
|
-
const source = facts.v2?._source;
|
|
31215
|
-
if (!source) return issues;
|
|
31216
|
-
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
31217
|
-
TAG_REGEX.lastIndex = 0;
|
|
31218
|
-
let tagCount = 0;
|
|
31219
|
-
let firstTagLine = 0;
|
|
31220
|
-
let m;
|
|
31221
|
-
while ((m = TAG_REGEX.exec(source)) !== null) {
|
|
31222
|
-
tagCount++;
|
|
31223
|
-
if (firstTagLine === 0) {
|
|
31224
|
-
firstTagLine = source.slice(0, m.index).split("\n").length;
|
|
31225
|
-
}
|
|
31226
|
-
}
|
|
31227
|
-
if (tagCount < context.tagThreshold) return issues;
|
|
31228
|
-
const lineCount = source.split("\n").length;
|
|
31229
|
-
const tagDensity = tagCount / Math.max(lineCount, 1);
|
|
31230
|
-
if (tagDensity < 0.05) return issues;
|
|
31231
|
-
if (lineCount > 200) return issues;
|
|
31232
|
-
issues.push({
|
|
31233
|
-
ruleId: "java/verbose-javadoc",
|
|
31234
|
-
category: "typo",
|
|
31235
|
-
severity: "low",
|
|
31236
|
-
aiSpecific: true,
|
|
31237
|
-
message: `${tagCount} Javadoc tags in ${lineCount} lines (density ${(tagDensity * 100).toFixed(1)}%) \u2014 likely over-documented`,
|
|
31238
|
-
line: firstTagLine,
|
|
31239
|
-
column: 1,
|
|
31240
|
-
advice: "Skip Javadoc on trivial methods (getters, setters, builders). AI agents default to over-documentation because their training data has countless textbook Javadoc examples. Real Java code limits Javadoc to public API surface. Reference: java/verbose-javadoc v0.26.0."
|
|
31241
|
-
});
|
|
31242
|
-
return issues;
|
|
31243
|
-
}
|
|
31244
|
-
});
|
|
31245
|
-
}
|
|
31246
|
-
});
|
|
31247
|
-
|
|
31248
30665
|
// src/rules/kotlin/coroutine-global-scope.ts
|
|
31249
30666
|
var GLOBAL_SCOPE_REGEX, kotlinCoroutineGlobalScopeRule;
|
|
31250
30667
|
var init_coroutine_global_scope = __esm({
|
|
@@ -31409,13 +30826,13 @@ var init_object_singleton_misuse = __esm({
|
|
|
31409
30826
|
});
|
|
31410
30827
|
|
|
31411
30828
|
// src/rules/kotlin/println-debug.ts
|
|
31412
|
-
var
|
|
30829
|
+
var PRINTLN_REGEX, DEFAULT_THRESHOLD, kotlinPrintlnDebugRule;
|
|
31413
30830
|
var init_println_debug = __esm({
|
|
31414
30831
|
"src/rules/kotlin/println-debug.ts"() {
|
|
31415
30832
|
"use strict";
|
|
31416
30833
|
init_rule();
|
|
31417
|
-
|
|
31418
|
-
|
|
30834
|
+
PRINTLN_REGEX = /^\s*println\s*\(/gm;
|
|
30835
|
+
DEFAULT_THRESHOLD = 1;
|
|
31419
30836
|
kotlinPrintlnDebugRule = createRule({
|
|
31420
30837
|
id: "kotlin/println-debug",
|
|
31421
30838
|
category: "typo",
|
|
@@ -31423,7 +30840,7 @@ var init_println_debug = __esm({
|
|
|
31423
30840
|
aiSpecific: true,
|
|
31424
30841
|
description: "println(...) in production code \u2014 use Timber, android.util.Log, or an SLF4J facade",
|
|
31425
30842
|
create(_context) {
|
|
31426
|
-
return { threshold:
|
|
30843
|
+
return { threshold: DEFAULT_THRESHOLD };
|
|
31427
30844
|
},
|
|
31428
30845
|
analyze(context, facts) {
|
|
31429
30846
|
const issues = [];
|
|
@@ -31432,8 +30849,8 @@ var init_println_debug = __esm({
|
|
|
31432
30849
|
if (!/\.kt$/i.test(facts.filePath)) return issues;
|
|
31433
30850
|
const matches = [];
|
|
31434
30851
|
let m;
|
|
31435
|
-
|
|
31436
|
-
while ((m =
|
|
30852
|
+
PRINTLN_REGEX.lastIndex = 0;
|
|
30853
|
+
while ((m = PRINTLN_REGEX.exec(source)) !== null) {
|
|
31437
30854
|
matches.push(m.index);
|
|
31438
30855
|
}
|
|
31439
30856
|
if (matches.length <= context.threshold) return issues;
|
|
@@ -31459,12 +30876,12 @@ var init_println_debug = __esm({
|
|
|
31459
30876
|
});
|
|
31460
30877
|
|
|
31461
30878
|
// src/rules/kotlin/string-concat-loop.ts
|
|
31462
|
-
var
|
|
31463
|
-
var
|
|
30879
|
+
var STRING_CONCAT_REGEX, kotlinStringConcatLoopRule;
|
|
30880
|
+
var init_string_concat_loop = __esm({
|
|
31464
30881
|
"src/rules/kotlin/string-concat-loop.ts"() {
|
|
31465
30882
|
"use strict";
|
|
31466
30883
|
init_rule();
|
|
31467
|
-
|
|
30884
|
+
STRING_CONCAT_REGEX = /\b(\w+)\s*=\s*\1\s*\+\s*[^;}]+[;}\n]/g;
|
|
31468
30885
|
kotlinStringConcatLoopRule = createRule({
|
|
31469
30886
|
id: "kotlin/string-concat-loop",
|
|
31470
30887
|
category: "perf",
|
|
@@ -31481,8 +30898,8 @@ var init_string_concat_loop2 = __esm({
|
|
|
31481
30898
|
if (!/\.kt$/i.test(facts.filePath)) return issues;
|
|
31482
30899
|
if (!/\b(?:for|while|repeat|forEach)\b/.test(source)) return issues;
|
|
31483
30900
|
let m;
|
|
31484
|
-
|
|
31485
|
-
while ((m =
|
|
30901
|
+
STRING_CONCAT_REGEX.lastIndex = 0;
|
|
30902
|
+
while ((m = STRING_CONCAT_REGEX.exec(source)) !== null) {
|
|
31486
30903
|
const line = source.slice(0, m.index).split("\n").length;
|
|
31487
30904
|
const lineText = source.slice(0, m.index).split("\n").pop() ?? "";
|
|
31488
30905
|
if (/\.append\s*\(/.test(lineText)) continue;
|
|
@@ -41128,13 +40545,13 @@ var init_implicitly_unwrapped_optional = __esm({
|
|
|
41128
40545
|
});
|
|
41129
40546
|
|
|
41130
40547
|
// src/rules/swift/print-debug.ts
|
|
41131
|
-
var PRINT_REGEX,
|
|
40548
|
+
var PRINT_REGEX, DEFAULT_THRESHOLD2, swiftPrintDebugRule;
|
|
41132
40549
|
var init_print_debug = __esm({
|
|
41133
40550
|
"src/rules/swift/print-debug.ts"() {
|
|
41134
40551
|
"use strict";
|
|
41135
40552
|
init_rule();
|
|
41136
40553
|
PRINT_REGEX = /\bprint\s*\(/g;
|
|
41137
|
-
|
|
40554
|
+
DEFAULT_THRESHOLD2 = 1;
|
|
41138
40555
|
swiftPrintDebugRule = createRule({
|
|
41139
40556
|
id: "swift/print-debug",
|
|
41140
40557
|
category: "typo",
|
|
@@ -41142,7 +40559,7 @@ var init_print_debug = __esm({
|
|
|
41142
40559
|
aiSpecific: true,
|
|
41143
40560
|
description: "print(...) in production Swift \u2014 use Logger (os.log) for level-controlled output",
|
|
41144
40561
|
create(_context) {
|
|
41145
|
-
return { threshold:
|
|
40562
|
+
return { threshold: DEFAULT_THRESHOLD2 };
|
|
41146
40563
|
},
|
|
41147
40564
|
analyze(context, facts) {
|
|
41148
40565
|
const issues = [];
|
|
@@ -46892,22 +46309,11 @@ var init_builtins = __esm({
|
|
|
46892
46309
|
init_error_wrap_without_context();
|
|
46893
46310
|
init_nil_slice_vs_empty();
|
|
46894
46311
|
init_struct_tag_inconsistency();
|
|
46895
|
-
init_arraylist_vs_linkedlist();
|
|
46896
|
-
init_builder_overuse();
|
|
46897
|
-
init_empty_catch_block();
|
|
46898
|
-
init_immutable_collection_preference();
|
|
46899
|
-
init_legacy_date_api();
|
|
46900
|
-
init_optional_overuse();
|
|
46901
|
-
init_raw_type_overuse();
|
|
46902
|
-
init_stream_overuse();
|
|
46903
|
-
init_string_concat_loop();
|
|
46904
|
-
init_system_out_println();
|
|
46905
|
-
init_verbose_javadoc();
|
|
46906
46312
|
init_coroutine_global_scope();
|
|
46907
46313
|
init_data_class_defaults_overuse();
|
|
46908
46314
|
init_object_singleton_misuse();
|
|
46909
46315
|
init_println_debug();
|
|
46910
|
-
|
|
46316
|
+
init_string_concat_loop();
|
|
46911
46317
|
init_gap_monopoly();
|
|
46912
46318
|
init_math_element_uniformity();
|
|
46913
46319
|
init_math_grid_uniformity();
|
|
@@ -47032,17 +46438,6 @@ var init_builtins = __esm({
|
|
|
47032
46438
|
goErrorWrapWithoutContextRule,
|
|
47033
46439
|
goNilSliceVsEmptyRule,
|
|
47034
46440
|
goStructTagInconsistencyRule,
|
|
47035
|
-
javaArraylistVsLinkedlistRule,
|
|
47036
|
-
javaBuilderOveruseRule,
|
|
47037
|
-
javaEmptyCatchBlockRule,
|
|
47038
|
-
javaImmutableCollectionPreferenceRule,
|
|
47039
|
-
javaLegacyDateApiRule,
|
|
47040
|
-
javaOptionalOveruseRule,
|
|
47041
|
-
javaRawTypeOveruseRule,
|
|
47042
|
-
javaStreamOveruseRule,
|
|
47043
|
-
javaStringConcatLoopRule,
|
|
47044
|
-
javaSystemOutPrintlnRule,
|
|
47045
|
-
javaVerboseJavadocRule,
|
|
47046
46441
|
kotlinCoroutineGlobalScopeRule,
|
|
47047
46442
|
kotlinDataClassDefaultsOveruseRule,
|
|
47048
46443
|
kotlinObjectSingletonMisuseRule,
|
|
@@ -50212,224 +49607,6 @@ var init_signal_strength = __esm({
|
|
|
50212
49607
|
_v8Lift: 1,
|
|
50213
49608
|
defaultOff: true
|
|
50214
49609
|
},
|
|
50215
|
-
"java/arraylist-vs-linkedlist": {
|
|
50216
|
-
recall: 35e-4,
|
|
50217
|
-
fpRate: 94e-4,
|
|
50218
|
-
ratio: 0.37,
|
|
50219
|
-
precision: 0.0446,
|
|
50220
|
-
lastCalibratedAt: "2026-07-02T19:34:00Z",
|
|
50221
|
-
verdict: "DORMANT",
|
|
50222
|
-
_calibrationNote: "v9 Java corpus calibration (v0.25.0, 2026-07-02): 81891 neg + 10305 pos Java files = 92196 total. v9 TP=36, FP=771, P=4.46%, FPR=0.94%, recall=0.35%, ratio=0.37, lift=P/FPR=4.74. Rule fires more on legacy enterprise Java (neg) than on AI/ML-integration Java (pos) because modern Java idiom defaults to ArrayList. v0.20: new rule (new LinkedList<>() \u2014 use ArrayList, Effective Java Item 28).",
|
|
50223
|
-
aiSpecific: true,
|
|
50224
|
-
_v7Verdict: "DORMANT",
|
|
50225
|
-
_v7Lift: 1,
|
|
50226
|
-
_v7Recall: 0,
|
|
50227
|
-
_v7FpRate: 0,
|
|
50228
|
-
_v7Precision: 0,
|
|
50229
|
-
_v8Verdict: "DORMANT",
|
|
50230
|
-
_v8Lift: 1,
|
|
50231
|
-
_v9Verdict: "DORMANT",
|
|
50232
|
-
_v9Lift: 4.74,
|
|
50233
|
-
_v9Recall: 35e-4,
|
|
50234
|
-
_v9FpRate: 94e-4,
|
|
50235
|
-
_v9Precision: 0.0446,
|
|
50236
|
-
defaultOff: true
|
|
50237
|
-
},
|
|
50238
|
-
"java/empty-catch-block": {
|
|
50239
|
-
recall: 8e-3,
|
|
50240
|
-
fpRate: 0.1118,
|
|
50241
|
-
ratio: 0.07,
|
|
50242
|
-
precision: 89e-4,
|
|
50243
|
-
lastCalibratedAt: "2026-07-02T19:34:00Z",
|
|
50244
|
-
verdict: "DORMANT",
|
|
50245
|
-
_calibrationNote: "v9 Java corpus calibration (v0.25.0, 2026-07-02): 81891 neg + 10305 pos Java files. v9 TP=82, FP=9159, P=0.89%, FPR=11.18%, recall=0.80%, ratio=0.07, lift=P/FPR=0.08. Strongly INVERTED: empty catch blocks are 14x more common in legacy enterprise Java than in AI/Java-modern pos repos. Heuristic likely needs to be tightened (e.g., require at least a comment) before it can serve as a meaningful discriminator. v0.20: new rule.",
|
|
50246
|
-
aiSpecific: true,
|
|
50247
|
-
_v7Verdict: "DORMANT",
|
|
50248
|
-
_v7Lift: 1,
|
|
50249
|
-
_v7Recall: 0,
|
|
50250
|
-
_v7FpRate: 0,
|
|
50251
|
-
_v7Precision: 0,
|
|
50252
|
-
_v8Verdict: "DORMANT",
|
|
50253
|
-
_v8Lift: 1,
|
|
50254
|
-
_v9Verdict: "DORMANT",
|
|
50255
|
-
_v9Lift: 0.08,
|
|
50256
|
-
_v9Recall: 8e-3,
|
|
50257
|
-
_v9FpRate: 0.1118,
|
|
50258
|
-
_v9Precision: 89e-4,
|
|
50259
|
-
defaultOff: true
|
|
50260
|
-
},
|
|
50261
|
-
"java/legacy-date-api": {
|
|
50262
|
-
recall: 0.0285,
|
|
50263
|
-
fpRate: 0.0511,
|
|
50264
|
-
ratio: 0.56,
|
|
50265
|
-
precision: 0.0657,
|
|
50266
|
-
lastCalibratedAt: "2026-07-02T19:34:00Z",
|
|
50267
|
-
verdict: "DORMANT",
|
|
50268
|
-
_calibrationNote: "v9 Java corpus calibration (v0.25.0, 2026-07-02): 81891 neg + 10305 pos Java files. v9 TP=294, FP=4181, P=6.57%, FPR=5.11%, recall=2.85%, ratio=0.56, lift=P/FPR=1.29. INVERTED-to-NOISY: legacy date API is more common in older enterprise Java (neg) than in modern AI/Java repos (pos). The heuristic correctly flags the legacy pattern, but the legacy pattern is over-represented in the neg baseline (older codebases). v0.20: new rule.",
|
|
50269
|
-
aiSpecific: true,
|
|
50270
|
-
_v7Verdict: "DORMANT",
|
|
50271
|
-
_v7Lift: 1,
|
|
50272
|
-
_v7Recall: 0,
|
|
50273
|
-
_v7FpRate: 0,
|
|
50274
|
-
_v7Precision: 0,
|
|
50275
|
-
_v8Verdict: "DORMANT",
|
|
50276
|
-
_v8Lift: 1,
|
|
50277
|
-
_v9Verdict: "DORMANT",
|
|
50278
|
-
_v9Lift: 1.29,
|
|
50279
|
-
_v9Recall: 0.0285,
|
|
50280
|
-
_v9FpRate: 0.0511,
|
|
50281
|
-
_v9Precision: 0.0657,
|
|
50282
|
-
defaultOff: true
|
|
50283
|
-
},
|
|
50284
|
-
"java/verbose-javadoc": {
|
|
50285
|
-
recall: 0,
|
|
50286
|
-
fpRate: 0,
|
|
50287
|
-
ratio: 1,
|
|
50288
|
-
precision: 0,
|
|
50289
|
-
lastCalibratedAt: "2026-07-03T00:00:00Z",
|
|
50290
|
-
verdict: "DORMANT",
|
|
50291
|
-
_calibrationNote: "v0.26.0: new positive AI-signal rule. Triggers when a small Java file (< 200 lines) has 3+ Javadoc tags with density >= 0.05. Calibration pending v9 Java corpus re-run; placeholder values until then. v0.20.0: anti-pattern design was wrong (humans write more Javadoc on trivial methods because their training data has it). v0.26.0: redesigned as positive signal (AI over-documents trivial methods). Reference: java/verbose-javadoc v0.26.0.",
|
|
50292
|
-
aiSpecific: true,
|
|
50293
|
-
_v9Verdict: "DORMANT",
|
|
50294
|
-
_v9Lift: 1,
|
|
50295
|
-
_v9Recall: 0,
|
|
50296
|
-
_v9FpRate: 0,
|
|
50297
|
-
_v9Precision: 0,
|
|
50298
|
-
defaultOff: true
|
|
50299
|
-
},
|
|
50300
|
-
"java/optional-overuse": {
|
|
50301
|
-
recall: 0,
|
|
50302
|
-
fpRate: 0,
|
|
50303
|
-
ratio: 1,
|
|
50304
|
-
precision: 0,
|
|
50305
|
-
lastCalibratedAt: "2026-07-03T00:00:00Z",
|
|
50306
|
-
verdict: "DORMANT",
|
|
50307
|
-
_calibrationNote: "v0.26.0: new positive AI-signal rule. Triggers when a Java file has 2+ .orElseThrow() calls AND 0 Objects.requireNonNull()/null checks (optionalRatio > 0.6). Calibration pending v9 Java corpus re-run; placeholder values until then. v0.26.0: redesigned as positive signal (AI chains Optional.ofNullable().orElseThrow() where null checks would be cleaner). Reference: java/optional-overuse v0.26.0.",
|
|
50308
|
-
aiSpecific: true,
|
|
50309
|
-
_v9Verdict: "DORMANT",
|
|
50310
|
-
_v9Lift: 1,
|
|
50311
|
-
_v9Recall: 0,
|
|
50312
|
-
_v9FpRate: 0,
|
|
50313
|
-
_v9Precision: 0,
|
|
50314
|
-
defaultOff: true
|
|
50315
|
-
},
|
|
50316
|
-
"java/immutable-collection-preference": {
|
|
50317
|
-
recall: 0,
|
|
50318
|
-
fpRate: 0,
|
|
50319
|
-
ratio: 1,
|
|
50320
|
-
precision: 0,
|
|
50321
|
-
lastCalibratedAt: "2026-07-03T00:00:00Z",
|
|
50322
|
-
verdict: "DORMANT",
|
|
50323
|
-
_calibrationNote: "v0.26.0: new positive AI-signal rule. Triggers when a Java file has 5+ List.of/Map.of/Set.of calls AND < 1 new ArrayList/HashMap/HashSet/LinkedList/TreeMap calls. Calibration pending v9 Java corpus re-run; placeholder values until then. v0.26.0: redesigned as positive signal (AI defaults to immutable factory methods). Reference: java/immutable-collection-preference v0.26.0.",
|
|
50324
|
-
aiSpecific: true,
|
|
50325
|
-
_v9Verdict: "DORMANT",
|
|
50326
|
-
_v9Lift: 1,
|
|
50327
|
-
_v9Recall: 0,
|
|
50328
|
-
_v9FpRate: 0,
|
|
50329
|
-
_v9Precision: 0,
|
|
50330
|
-
defaultOff: true
|
|
50331
|
-
},
|
|
50332
|
-
"java/builder-overuse": {
|
|
50333
|
-
recall: 0,
|
|
50334
|
-
fpRate: 0,
|
|
50335
|
-
ratio: 1,
|
|
50336
|
-
precision: 0,
|
|
50337
|
-
lastCalibratedAt: "2026-07-03T00:00:00Z",
|
|
50338
|
-
verdict: "DORMANT",
|
|
50339
|
-
_calibrationNote: "v0.26.0: new positive AI-signal rule. Triggers when @Builder annotation (Lombok) is used on a class with <= 3 fields. Calibration pending v9 Java corpus re-run; placeholder values until then. v0.26.0: redesigned as positive signal (AI defaults to Builder pattern even for simple data classes). Reference: java/builder-overuse v0.26.0.",
|
|
50340
|
-
aiSpecific: true,
|
|
50341
|
-
_v9Verdict: "DORMANT",
|
|
50342
|
-
_v9Lift: 1,
|
|
50343
|
-
_v9Recall: 0,
|
|
50344
|
-
_v9FpRate: 0,
|
|
50345
|
-
_v9Precision: 0,
|
|
50346
|
-
defaultOff: true
|
|
50347
|
-
},
|
|
50348
|
-
"java/stream-overuse": {
|
|
50349
|
-
recall: 0,
|
|
50350
|
-
fpRate: 0,
|
|
50351
|
-
ratio: 1,
|
|
50352
|
-
precision: 0,
|
|
50353
|
-
lastCalibratedAt: "2026-07-03T00:00:00Z",
|
|
50354
|
-
verdict: "DORMANT",
|
|
50355
|
-
_calibrationNote: "v0.26.0: new positive AI-signal rule. Triggers when a single line has 3+ Stream API operations (.map, .filter, .flatMap, .collect, .reduce, .sorted, .distinct, .limit, .skip, .anyMatch, .allMatch, .noneMatch, .findFirst, .findAny). Calibration pending v9 Java corpus re-run; placeholder values until then. v0.26.0: redesigned as positive signal (AI chains Stream API for everything). Reference: java/stream-overuse v0.26.0.",
|
|
50356
|
-
aiSpecific: true,
|
|
50357
|
-
_v9Verdict: "DORMANT",
|
|
50358
|
-
_v9Lift: 1,
|
|
50359
|
-
_v9Recall: 0,
|
|
50360
|
-
_v9FpRate: 0,
|
|
50361
|
-
_v9Precision: 0,
|
|
50362
|
-
defaultOff: true
|
|
50363
|
-
},
|
|
50364
|
-
"java/raw-type-overuse": {
|
|
50365
|
-
recall: 0.1093,
|
|
50366
|
-
fpRate: 0.2041,
|
|
50367
|
-
ratio: 0.54,
|
|
50368
|
-
precision: 0.0632,
|
|
50369
|
-
lastCalibratedAt: "2026-07-02T19:34:00Z",
|
|
50370
|
-
verdict: "DORMANT",
|
|
50371
|
-
_calibrationNote: "v9 Java corpus calibration (v0.25.0, 2026-07-02): 81891 neg + 10305 pos Java files. v9 TP=1126, FP=16712, P=6.32%, FPR=20.41%, recall=10.93%, ratio=0.54, lift=P/FPR=0.31. Strongly INVERTED: raw types (no generics) are 2x more common in legacy enterprise Java (neg) than in modern Java repos (pos). Heuristic is correctly identifying the legacy anti-pattern, but it's an age marker more than an AI-fingerprint. v0.20: new rule.",
|
|
50372
|
-
aiSpecific: true,
|
|
50373
|
-
_v7Verdict: "DORMANT",
|
|
50374
|
-
_v7Lift: 1,
|
|
50375
|
-
_v7Recall: 0,
|
|
50376
|
-
_v7FpRate: 0,
|
|
50377
|
-
_v7Precision: 0,
|
|
50378
|
-
_v8Verdict: "DORMANT",
|
|
50379
|
-
_v8Lift: 1,
|
|
50380
|
-
_v9Verdict: "DORMANT",
|
|
50381
|
-
_v9Lift: 0.31,
|
|
50382
|
-
_v9Recall: 0.1093,
|
|
50383
|
-
_v9FpRate: 0.2041,
|
|
50384
|
-
_v9Precision: 0.0632,
|
|
50385
|
-
defaultOff: true
|
|
50386
|
-
},
|
|
50387
|
-
"java/string-concat-loop": {
|
|
50388
|
-
recall: 46e-4,
|
|
50389
|
-
fpRate: 0.0358,
|
|
50390
|
-
ratio: 0.13,
|
|
50391
|
-
precision: 0.0158,
|
|
50392
|
-
lastCalibratedAt: "2026-07-02T19:34:00Z",
|
|
50393
|
-
verdict: "DORMANT",
|
|
50394
|
-
_calibrationNote: "v9 Java corpus calibration (v0.25.0, 2026-07-02): 81891 neg + 10305 pos Java files. v9 TP=47, FP=2933, P=1.58%, FPR=3.58%, recall=0.46%, ratio=0.13, lift=P/FPR=0.44. Strongly INVERTED: string concatenation in a loop is 8x more common in legacy enterprise Java (neg) than in AI/ML/Java-modern pos repos. Modern Java training data and modern IDE warnings discourage the pattern. v0.20: new rule.",
|
|
50395
|
-
aiSpecific: true,
|
|
50396
|
-
_v7Verdict: "DORMANT",
|
|
50397
|
-
_v7Lift: 1,
|
|
50398
|
-
_v7Recall: 0,
|
|
50399
|
-
_v7FpRate: 0,
|
|
50400
|
-
_v7Precision: 0,
|
|
50401
|
-
_v8Verdict: "DORMANT",
|
|
50402
|
-
_v8Lift: 1,
|
|
50403
|
-
_v9Verdict: "DORMANT",
|
|
50404
|
-
_v9Lift: 0.44,
|
|
50405
|
-
_v9Recall: 46e-4,
|
|
50406
|
-
_v9FpRate: 0.0358,
|
|
50407
|
-
_v9Precision: 0.0158,
|
|
50408
|
-
defaultOff: true
|
|
50409
|
-
},
|
|
50410
|
-
"java/system-out-println": {
|
|
50411
|
-
recall: 0.1503,
|
|
50412
|
-
fpRate: 0.2533,
|
|
50413
|
-
ratio: 0.59,
|
|
50414
|
-
precision: 0.0695,
|
|
50415
|
-
lastCalibratedAt: "2026-07-02T19:34:00Z",
|
|
50416
|
-
verdict: "DORMANT",
|
|
50417
|
-
_calibrationNote: "v9 Java corpus calibration (v0.25.0, 2026-07-02): 81891 neg + 10305 pos Java files. v9 TP=1549, FP=20737, P=6.95%, FPR=25.32%, recall=15.03%, ratio=0.59, lift=P/FPR=0.27. INVERTED: System.out.println is more common in legacy enterprise Java (neg) than in modern AI/Java repos (pos). Modern Java defaults to SLF4J/Log4j, AI-generated Java starts with a logger import. The pattern is the opposite of the v0.20 design intent (which assumed println was the AI-fingerprint signal). v0.25.x: consider gating this rule by Java era (recent file mtime) or making it an age-fingerprint rather than AI-fingerprint. v0.20: new rule.",
|
|
50418
|
-
aiSpecific: true,
|
|
50419
|
-
_v7Verdict: "DORMANT",
|
|
50420
|
-
_v7Lift: 1,
|
|
50421
|
-
_v7Recall: 0,
|
|
50422
|
-
_v7FpRate: 0,
|
|
50423
|
-
_v7Precision: 0,
|
|
50424
|
-
_v8Verdict: "DORMANT",
|
|
50425
|
-
_v8Lift: 1,
|
|
50426
|
-
_v9Verdict: "DORMANT",
|
|
50427
|
-
_v9Lift: 0.27,
|
|
50428
|
-
_v9Recall: 0.1503,
|
|
50429
|
-
_v9FpRate: 0.2533,
|
|
50430
|
-
_v9Precision: 0.0695,
|
|
50431
|
-
defaultOff: true
|
|
50432
|
-
},
|
|
50433
49610
|
"layout/forced-layout": {
|
|
50434
49611
|
recall: 0,
|
|
50435
49612
|
fpRate: 0,
|
|
@@ -59971,18 +59148,6 @@ var RULE_HINTS = {
|
|
|
59971
59148
|
"dup/near-duplicate": "Refactor to a shared helper. Type-2 near-duplicate: same identifiers + structure, different whitespace/comments. AI-iterated code regenerates the same function with cosmetic edits. (v0.23.0 \u2014 MinHash + LSH, k=5, thr 0.7.)",
|
|
59972
59149
|
// v0.24.0 — Type-3 structural clone detector (two-stage MinHash)
|
|
59973
59150
|
"dup/structural-clone": "Refactor to a shared helper. Type-3 clone: same shape as another file after identifier canonicalization, with renames and/or added/removed statements. AI agents and copy-paste both produce this. Extract the shared part. (v0.24.0.)",
|
|
59974
|
-
// v0.20.0 — Java-specific rules
|
|
59975
|
-
"java/system-out-println": "Replace with `private static final Logger log = LoggerFactory.getLogger(...);` then `log.info(...)`. AI agents default to println because of textbook examples; real Java code uses a logger.",
|
|
59976
|
-
"java/empty-catch-block": 'Log the exception (`log.error("...", e)`), re-throw it, or both. Empty catch blocks hide bugs. Common in AI-generated code that wants to look defensive.',
|
|
59977
|
-
"java/arraylist-vs-linkedlist": "Replace `new LinkedList<>()` with `new ArrayList<>()`. LinkedList is rarely the right choice (worse cache locality, 5x more memory per element, O(n) indexed access). Joshua Bloch recommends ArrayList unless you need a Deque.",
|
|
59978
|
-
"java/legacy-date-api": "Replace `java.util.Date` / `Calendar` with `java.time` (`LocalDate`, `LocalDateTime`, `Instant`, `ZonedDateTime`). java.time is immutable and thread-safe. AI agents default to the legacy API.",
|
|
59979
|
-
"java/raw-type-overuse": "Replace raw `List` / `Map` / `Set` with the parameterized form. Raw types disable generic type checking (Effective Java, Item 23). AI agents default to raw types when unsure of the correct generic parameters.",
|
|
59980
|
-
"java/string-concat-loop": "Declare a `StringBuilder` outside the loop: `StringBuilder sb = new StringBuilder(); sb.append(...);` then `return sb.toString();` after. String concat in a loop is O(n\xB2).",
|
|
59981
|
-
"java/verbose-javadoc": "Skip Javadoc on trivial methods (getters, setters, builders). AI over-documents; real Java limits Javadoc to public API surface. (v0.26.0 \u2014 DORMANT.)",
|
|
59982
|
-
"java/optional-overuse": "Use Objects.requireNonNull(x) for null checks; reserve Optional for return values. AI chains .ofNullable().orElseThrow() where null checks suffice. (v0.26.0 \u2014 DORMANT.)",
|
|
59983
|
-
"java/immutable-collection-preference": "Prefer mutable (new ArrayList<>()) when the collection will be modified. AI defaults to List.of/Map.of/Set.of; real Java uses mutable. (v0.26.0 \u2014 DORMANT.)",
|
|
59984
|
-
"java/builder-overuse": "Use a plain constructor for classes with \u2264 3 fields. AI defaults to @Builder; Builder adds Lombok dep and a Builder inner class per class. (v0.26.0 \u2014 DORMANT.)",
|
|
59985
|
-
"java/stream-overuse": "Prefer a for-loop for simple transformations. AI chains Stream API for everything; for small collections a for-loop is faster. (v0.26.0 \u2014 DORMANT.)",
|
|
59986
59151
|
// v0.24.0 — Kotlin rules (DORMANT until v9 Kotlin corpus calibration)
|
|
59987
59152
|
"kotlin/data-class-defaults-overuse": "Audit which fields are genuinely optional. Real Kotlin uses defaults sparingly (1-2 callbacks, the rest required). v0.24.0 \u2014 DORMANT until v9 calibration.",
|
|
59988
59153
|
"kotlin/coroutine-global-scope": "Replace with `viewModelScope.launch { ... }`, `lifecycleScope.launch { ... }`, or `coroutineScope { ... }`. GlobalScope bypasses cancellation. (v0.24.0 \u2014 DORMANT.)",
|