Skip to content

Commit ee2c21d

Browse files
committed
use spotbugs builder to detect problems (that ai can generated)
This does include a build command and a nature (so spotbugs needs to be installed to support this) i enabled it for the project (so thats why the project settings are now in git). It is enabled on build so if ai generates/changes code it right away should reported as error (scary and scariest). getCompileErrors will already get those back, so after any change it will report to the AI that there is a Spotbugs thing found which it should fix. so this should make the ai code better.
1 parent 55d4571 commit ee2c21d

7 files changed

Lines changed: 196 additions & 5 deletions

File tree

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/@dot
22
/exports
3-
/bin
4-
/.settings
3+
/bin

plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/.project

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@
2020
<arguments>
2121
</arguments>
2222
</buildCommand>
23+
<buildCommand>
24+
<name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
2328
</buildSpec>
2429
<natures>
2530
<nature>org.eclipse.pde.PluginNature</nature>
2631
<nature>org.eclipse.jdt.core.javanature</nature>
32+
<nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
2733
</natures>
2834
</projectDescription>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
com.github.spotbugs.plugin.eclipse.findbugsMarkerScariest=Error
2+
com.github.spotbugs.plugin.eclipse.findbugsMarkerScary=Error
3+
eclipse.preferences.version=1
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#SpotBugs User Preferences
2+
#Thu May 14 00:03:12 CEST 2026
3+
adjust_priority=
4+
detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
5+
detectorAtomicityProblem=AtomicityProblem|true
6+
detectorBadAppletConstructor=BadAppletConstructor|false
7+
detectorBadResultSetAccess=BadResultSetAccess|true
8+
detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
9+
detectorBadUseOfReturnValue=BadUseOfReturnValue|true
10+
detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
11+
detectorBooleanReturnNull=BooleanReturnNull|true
12+
detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false
13+
detectorCheckExpectedWarnings=CheckExpectedWarnings|false
14+
detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
15+
detectorCheckRelaxingNullnessAnnotation=CheckRelaxingNullnessAnnotation|true
16+
detectorCheckTypeQualifiers=CheckTypeQualifiers|true
17+
detectorCloneIdiom=CloneIdiom|true
18+
detectorComparatorIdiom=ComparatorIdiom|true
19+
detectorConfusedInheritance=ConfusedInheritance|true
20+
detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
21+
detectorConstructorThrow=ConstructorThrow|true
22+
detectorCovariantArrayAssignment=CovariantArrayAssignment|false
23+
detectorCrossSiteScripting=CrossSiteScripting|true
24+
detectorDateFormatStringChecker=DateFormatStringChecker|true
25+
detectorDefaultEncodingDetector=DefaultEncodingDetector|true
26+
detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
27+
detectorDontAssertInstanceofInTests=DontAssertInstanceofInTests|true
28+
detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
29+
detectorDontCatchNullPointerException=DontCatchNullPointerException|true
30+
detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
31+
detectorDontReusePublicIdentifiers=DontReusePublicIdentifiers|false
32+
detectorDontUseEnum=DontUseEnum|true
33+
detectorDontUseFloatsAsLoopCounters=DontUseFloatsAsLoopCounters|true
34+
detectorDroppedException=DroppedException|true
35+
detectorDumbMethodInvocations=DumbMethodInvocations|true
36+
detectorDumbMethods=DumbMethods|true
37+
detectorDuplicateBranches=DuplicateBranches|true
38+
detectorEmptyZipFileEntry=EmptyZipFileEntry|false
39+
detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
40+
detectorExplicitSerialization=ExplicitSerialization|true
41+
detectorFinalizerNullsFields=FinalizerNullsFields|true
42+
detectorFindArgumentAssertions=FindArgumentAssertions|true
43+
detectorFindAssertionsWithSideEffects=FindAssertionsWithSideEffects|true
44+
detectorFindBadCast2=FindBadCast2|true
45+
detectorFindBadEndOfStreamCheck=FindBadEndOfStreamCheck|true
46+
detectorFindBadForLoop=FindBadForLoop|true
47+
detectorFindCircularDependencies=FindCircularDependencies|false
48+
detectorFindComparatorProblems=FindComparatorProblems|true
49+
detectorFindDeadLocalStores=FindDeadLocalStores|true
50+
detectorFindDoubleCheck=FindDoubleCheck|true
51+
detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
52+
detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
53+
detectorFindFinalizeInvocations=FindFinalizeInvocations|true
54+
detectorFindFloatEquality=FindFloatEquality|true
55+
detectorFindHEmismatch=FindHEmismatch|true
56+
detectorFindHiddenMethod=FindHiddenMethod|true
57+
detectorFindInconsistentSync2=FindInconsistentSync2|true
58+
detectorFindInstanceLockOnSharedStaticData=FindInstanceLockOnSharedStaticData|true
59+
detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
60+
detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
61+
detectorFindMaskedFields=FindMaskedFields|true
62+
detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
63+
detectorFindNakedNotify=FindNakedNotify|true
64+
detectorFindNonShortCircuit=FindNonShortCircuit|true
65+
detectorFindNullDeref=FindNullDeref|true
66+
detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
67+
detectorFindOpenStream=FindOpenStream|true
68+
detectorFindOverridableMethodCall=FindOverridableMethodCall|true
69+
detectorFindPotentialSecurityCheckBasedOnUntrustedSource=FindPotentialSecurityCheckBasedOnUntrustedSource|true
70+
detectorFindPublicAttributes=FindPublicAttributes|true
71+
detectorFindPuzzlers=FindPuzzlers|true
72+
detectorFindRefComparison=FindRefComparison|true
73+
detectorFindReturnRef=FindReturnRef|true
74+
detectorFindRoughConstants=FindRoughConstants|true
75+
detectorFindRunInvocations=FindRunInvocations|true
76+
detectorFindSelfComparison=FindSelfComparison|true
77+
detectorFindSelfComparison2=FindSelfComparison2|true
78+
detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
79+
detectorFindSpinLoop=FindSpinLoop|true
80+
detectorFindSqlInjection=FindSqlInjection|true
81+
detectorFindTwoLockWait=FindTwoLockWait|true
82+
detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
83+
detectorFindUnconditionalWait=FindUnconditionalWait|true
84+
detectorFindUninitializedGet=FindUninitializedGet|true
85+
detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
86+
detectorFindUnreleasedLock=FindUnreleasedLock|true
87+
detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
88+
detectorFindUnsyncGet=FindUnsyncGet|true
89+
detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true
90+
detectorFindUselessControlFlow=FindUselessControlFlow|true
91+
detectorFindUselessObjects=FindUselessObjects|true
92+
detectorFindVulnerableSecurityCheckMethods=FindVulnerableSecurityCheckMethods|true
93+
detectorFormatStringChecker=FormatStringChecker|true
94+
detectorHugeSharedStringConstants=HugeSharedStringConstants|true
95+
detectorIDivResultCastToDouble=IDivResultCastToDouble|true
96+
detectorIncompatMask=IncompatMask|true
97+
detectorInconsistentAnnotations=InconsistentAnnotations|true
98+
detectorInefficientIndexOf=InefficientIndexOf|false
99+
detectorInefficientInitializationInsideLoop=InefficientInitializationInsideLoop|false
100+
detectorInefficientMemberAccess=InefficientMemberAccess|false
101+
detectorInefficientToArray=InefficientToArray|false
102+
detectorInfiniteLoop=InfiniteLoop|true
103+
detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
104+
detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
105+
detectorInitializationChain=InitializationChain|true
106+
detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true
107+
detectorInstantiateStaticClass=InstantiateStaticClass|true
108+
detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true
109+
detectorInvalidJUnitTest=InvalidJUnitTest|true
110+
detectorIteratorIdioms=IteratorIdioms|true
111+
detectorLazyInit=LazyInit|true
112+
detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
113+
detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
114+
detectorMethodReturnCheck=MethodReturnCheck|true
115+
detectorMultipleInstantiationsOfSingletons=MultipleInstantiationsOfSingletons|true
116+
detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
117+
detectorMutableEnum=MutableEnum|true
118+
detectorMutableLock=MutableLock|true
119+
detectorMutableStaticFields=MutableStaticFields|true
120+
detectorNaming=Naming|true
121+
detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true
122+
detectorNumberConstructor=NumberConstructor|true
123+
detectorOptionalReturnNull=OptionalReturnNull|true
124+
detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
125+
detectorOverridingMethodsMustInvokeSuperDetector=OverridingMethodsMustInvokeSuperDetector|true
126+
detectorPermissionsSuper=PermissionsSuper|true
127+
detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
128+
detectorPublicSemaphores=PublicSemaphores|false
129+
detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
130+
detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
131+
detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
132+
detectorRedundantConditions=RedundantConditions|true
133+
detectorRedundantInterfaces=RedundantInterfaces|true
134+
detectorReflectionIncreaseAccessibility=ReflectionIncreaseAccessibility|true
135+
detectorRepeatedConditionals=RepeatedConditionals|true
136+
detectorResourceInMultipleThreadsDetector=ResourceInMultipleThreadsDetector|true
137+
detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
138+
detectorSerializableIdiom=SerializableIdiom|true
139+
detectorSharedVariableAtomicityDetector=SharedVariableAtomicityDetector|true
140+
detectorStartInConstructor=StartInConstructor|true
141+
detectorStaticCalendarDetector=StaticCalendarDetector|true
142+
detectorStringConcatenation=StringConcatenation|true
143+
detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
144+
detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
145+
detectorSwitchFallthrough=SwitchFallthrough|true
146+
detectorSynchronizationOnSharedBuiltinConstant=SynchronizationOnSharedBuiltinConstant|true
147+
detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
148+
detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
149+
detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
150+
detectorThrowingExceptions=ThrowingExceptions|true
151+
detectorURLProblems=URLProblems|true
152+
detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
153+
detectorUnnecessaryEnvUsage=UnnecessaryEnvUsage|true
154+
detectorUnnecessaryMath=UnnecessaryMath|true
155+
detectorUnreadFields=UnreadFields|true
156+
detectorUselessSubclassMethod=UselessSubclassMethod|false
157+
detectorVarArgsProblems=VarArgsProblems|true
158+
detectorVolatileUsage=VolatileUsage|true
159+
detectorWaitInLoop=WaitInLoop|true
160+
detectorWrongMapIterator=WrongMapIterator|true
161+
detectorXMLFactoryBypass=XMLFactoryBypass|true
162+
detector_threshold=2
163+
effort=default
164+
filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|15
165+
filter_settings_neg=EXPERIMENTAL,NOISE,I18N|
166+
mergeSimilarWarnings=false
167+
run_at_full_build=true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=21
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
10+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
11+
org.eclipse.jdt.core.compiler.release=enabled
12+
org.eclipse.jdt.core.compiler.source=21

plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/tools/EclipseVariableUtilities.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ public static String resolveEclipseVariables(String input) {
4848
String variable = matcher.group(1);
4949
String replacement = getVariableValue(variable);
5050

51-
// Convert Windows path to WSL path if needed
52-
if (isWsl && replacement != null && !replacement.isEmpty())
51+
if (replacement == null)
52+
{
53+
replacement = matcher.group(0);
54+
}
55+
else if (isWsl && !replacement.isEmpty())
5356
{
5457
replacement = convertToWslPath(replacement);
5558
}
5659

57-
// Escape backslashes and dollar signs for the replacement
5860
replacement = replacement.replace("\\", "\\\\").replace("$", "\\$");
5961
matcher.appendReplacement(result, replacement);
6062
}

0 commit comments

Comments
 (0)