From 6bb7802379ea829b20d47534f30d422af22e3b0e Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Tue, 25 Feb 2025 17:05:07 +0100 Subject: [PATCH 01/11] feat: apply fix command --- .../eclipse/plugin/html/BaseHtmlProvider.java | 3 +- .../eclipse/plugin/html/CodeHtmlProvider.java | 132 +++++++++++------- .../views/snyktoolview/BrowserHandler.java | 59 +++++++- .../io/snyk/languageserver/LsConstants.java | 1 + .../SnykExtendedLanguageClient.java | 10 ++ .../protocolextension/messageObjects/Fix.java | 11 ++ 6 files changed, 156 insertions(+), 60 deletions(-) create mode 100644 plugin/src/main/java/io/snyk/languageserver/protocolextension/messageObjects/Fix.java diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/html/BaseHtmlProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/html/BaseHtmlProvider.java index 608cb599..8cb14dcf 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/html/BaseHtmlProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/html/BaseHtmlProvider.java @@ -119,9 +119,10 @@ public String replaceCssVariables(String html) { getColorAsHex("org.eclipse.ui.workbench.INACTIVE_TAB_BG_START", "#F0F0F0")); htmlStyled = htmlStyled.replace("var(--circle-color)", getColorAsHex("org.eclipse.ui.workbench.INACTIVE_TAB_BG_START", "#F0F0F0")); - htmlStyled = htmlStyled.replace("var(--border-color)", getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_OUTER_KEYLINE_COLOR", "#CCCCCC")); + htmlStyled = htmlStyled.replace("var(--input-border)", + getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_OUTER_KEYLINE_COLOR", "#CCCCCC")); htmlStyled = htmlStyled.replace("var(--link-color)", getColorAsHex("ACTIVE_HYPERLINK_COLOR", "#0000FF")); htmlStyled = htmlStyled.replace("var(--horizontal-border-color)", getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_OUTER_KEYLINE_COLOR", "#CCCCCC")); diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java index 5f18a55a..748c0630 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java @@ -3,7 +3,7 @@ import io.snyk.eclipse.plugin.preferences.Preferences; public class CodeHtmlProvider extends BaseHtmlProvider { - private static CodeHtmlProvider instance = new CodeHtmlProvider(); + private static CodeHtmlProvider instance = new CodeHtmlProvider(); public static CodeHtmlProvider getInstance() { synchronized (CodeHtmlProvider.class) { @@ -16,61 +16,85 @@ public static CodeHtmlProvider getInstance() { return instance; } - @Override - public String getInitScript() { - String themeScript = getThemeScript(); - String initScript = super.getInitScript(); - return initScript + "\n" + """ - function navigateToIssue(e, target) { - e.preventDefault(); - var filePath = target.getAttribute('file-path'); - var startLine = target.getAttribute('start-line'); - var endLine = target.getAttribute('end-line'); - var startCharacter = target.getAttribute('start-character'); - var endCharacter = target.getAttribute('end-character'); - window.openInEditor(filePath, startLine, endLine, startCharacter, endCharacter); - } - var navigatableLines = document.getElementsByClassName('data-flow-clickable-row'); - for(var i = 0; i < navigatableLines.length; i++) { - navigatableLines[i].onclick = function(e) { - navigateToIssue(e, this); - return false; - }; - } - if(document.getElementById('position-line')) { - document.getElementById('position-line').onclick = function(e) { - var target = navigatableLines[0]; - if(target) { - navigateToIssue(e, target); - } - } - } - // Disable AIfix - if(document.getElementById('ai-fix-wrapper') && document.getElementById('no-ai-fix-wrapper')){ - document.getElementById('ai-fix-wrapper').className = 'hidden'; - document.getElementById('no-ai-fix-wrapper').className = ''; - } - """ + themeScript; - } + @Override + public String getInitScript() { + String themeScript = getThemeScript(); + String initScript = super.getInitScript(); + return initScript + "\n" + """ + function navigateToIssue(e, target) { + e.preventDefault(); + var filePath = target.getAttribute('file-path'); + var startLine = target.getAttribute('start-line'); + var endLine = target.getAttribute('end-line'); + var startCharacter = target.getAttribute('start-character'); + var endCharacter = target.getAttribute('end-character'); + window.openInEditor(filePath, startLine, endLine, startCharacter, endCharacter); + } + var navigatableLines = document.getElementsByClassName('data-flow-clickable-row'); + for(var i = 0; i < navigatableLines.length; i++) { + navigatableLines[i].onclick = function(e) { + navigateToIssue(e, this); + return false; + }; + } + if(document.getElementById('position-line')) { + document.getElementById('position-line').onclick = function(e) { + var target = navigatableLines[0]; + if(target) { + navigateToIssue(e, target); + } + } + } + """ + themeScript; + } + + private String getThemeScript() { + if (Preferences.getInstance().isTest()) { + return ""; + } + + String themeScript = "var isDarkTheme = " + isDarkTheme() + ";\n" + + "document.body.classList.add(isDarkTheme ? 'dark' : 'light');"; + return themeScript; + } + + @Override + public String replaceCssVariables(String html) { + String htmlStyled = super.replaceCssVariables(html); + + // Replace CSS variables with actual color values + htmlStyled = htmlStyled.replace("var(--example-line-removed-color)", + super.getColorAsHex("DELETION_COLOR", "#ff0000")); + htmlStyled = htmlStyled.replace("var(--example-line-added-color)", + super.getColorAsHex("ADDITION_COLOR", "#00ff00")); + htmlStyled = htmlStyled.replace("var(--generated-ai-fix-button-background-color)", +// super.getColorAsHex("org.eclipse.ui.workbench.INACTIVE_TAB_BG_START", "#F0F0F0")); + super.getColorAsHex("ADDITION_COLOR", "#00ff00")); + htmlStyled = htmlStyled.replace("var(--disabled-background-color)", + super.getColorAsHex("ADDITION_COLOR", "#00ff00")); - private String getThemeScript() { - if(Preferences.getInstance().isTest()) { - return ""; - } + String htmlWithScripts = getReplaceAIFixScripts(htmlStyled); - String themeScript = "var isDarkTheme = " + isDarkTheme() + ";\n" + - "document.body.classList.add(isDarkTheme ? 'dark' : 'light');"; - return themeScript; - } + return htmlWithScripts; + } + + private String getReplaceAIFixScripts(String html) { + String htmlWithGenerateFunc = html.replace("${ideGenerateAIFix}", getGenerateAiFixScript()); + String htmlWithApplyFunc = htmlWithGenerateFunc.replace("${ideApplyAIFix}", getApplyAiFixScript()); + + return htmlWithApplyFunc; + } - @Override - public String replaceCssVariables(String html) { - String htmlStyled = super.replaceCssVariables(html); - - // Replace CSS variables with actual color values - htmlStyled = htmlStyled.replace("var(--example-line-removed-color)", super.getColorAsHex("DELETION_COLOR", "#ff0000")); - htmlStyled = htmlStyled.replace("var(--example-line-added-color)", super.getColorAsHex("ADDITION_COLOR", "#00ff00")); + private String getGenerateAiFixScript() { + // TODO this script is broken, does not trigger a generate + return "const issueId = generateAIFixButton.getAttribute('issue-id');\n" + + "const folderPath = generateAIFixButton.getAttribute('folder-path');\n" + + "const filePath = generateAIFixButton.getAttribute('file-path');\n" + "console.log(filePath);\n" + + "window.generateAIFix(folderPath + \"@|@\" + filePath + \"@|@\" + issueId);"; + } + + private String getApplyAiFixScript() { + return "window.applyAIFix(fixId + '|@' + filePath + '|@' + patch);\n"; + } - return htmlStyled; - } } diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java index 5413af0e..ec0e8386 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java @@ -3,6 +3,7 @@ import static org.apache.commons.lang3.StringUtils.isEmpty; import java.nio.file.Paths; +import java.util.List; import java.util.concurrent.CompletableFuture; import org.eclipse.core.commands.common.CommandException; @@ -31,6 +32,8 @@ import io.snyk.eclipse.plugin.utils.SnykLogger; import io.snyk.eclipse.plugin.views.snyktoolview.handlers.IHandlerCommands; import io.snyk.eclipse.plugin.wizards.SnykWizard; +import io.snyk.languageserver.protocolextension.SnykExtendedLanguageClient; +import io.snyk.languageserver.protocolextension.messageObjects.Fix; @SuppressWarnings("restriction") public class BrowserHandler { @@ -84,13 +87,45 @@ public Object function(Object[] arguments) { new BrowserFunction(browser, "stopScan") { @Override public Object function(Object[] arguments) { - IHandlerService handlerService = - (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); + IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() + .getService(IHandlerService.class); + try { handlerService.executeCommand(IHandlerCommands.STOP_SCAN, null); } catch (CommandException e) { SnykLogger.logError(e); - } + } + return null; + } + }; + + new BrowserFunction(browser, "generateAIFix") { + @Override + public Object function(Object[] arguments) { + browser.execute("debugger;"); // Triggers a breakpoint for debugging + System.out.println("generateAIFix"); + SnykLogger.logInfo("generateAIFix"); + + String folderURI = (String) arguments[0]; + String fileURI = (String) arguments[1]; + String issueID = (String) arguments[2]; + + // Do we want to capture and do something with the responseDiffs here? + List responseDiffs = SnykExtendedLanguageClient.getInstance().sendCodeFixDiffsCommand(folderURI, + fileURI, issueID); + + return null; + } + }; + + new BrowserFunction(browser, "applyAIFix") { + @Override + public Object function(Object[] arguments) { + System.out.println("applyAIFix"); + SnykLogger.logInfo("applyAIFix"); + + String fixId = (String) arguments[0]; + SnykExtendedLanguageClient.getInstance().sendCodeApplyAiFixEditCommand(fixId); return null; } }; @@ -158,7 +193,20 @@ public CompletableFuture updateBrowserContent(TreeNode node) { } final var browserContent = htmlProvider.replaceCssVariables(htmlContent); - + +// String[] lines = browserContent.split("\n"); +// for (String line : lines) { +// if (line.contains("window.generateAIFix")) { +// System.out.println(line); +// } else if (line.contains("applyAIFix")) { +// System.out.println(line); +// } else if (line.contains("issue-id")) { +// System.out.println(line); +// } else if (line.contains("folder-path")) { +// System.out.println(line); +// } +// } + Display.getDefault().syncExec(() -> { browser.setText(browserContent); }); @@ -191,7 +239,8 @@ public String generateHtmlContent(String text) { } public void setDefaultBrowserText() { - // If we are not authenticated, show the welcome page, else show the issue placeholder. + // If we are not authenticated, show the welcome page, else show the issue + // placeholder. if (Preferences.getInstance().getAuthToken().isBlank()) { browser.setText(StaticPageHtmlProvider.getInstance().getInitHtml()); } else { diff --git a/plugin/src/main/java/io/snyk/languageserver/LsConstants.java b/plugin/src/main/java/io/snyk/languageserver/LsConstants.java index a57213fa..ad39821d 100644 --- a/plugin/src/main/java/io/snyk/languageserver/LsConstants.java +++ b/plugin/src/main/java/io/snyk/languageserver/LsConstants.java @@ -17,6 +17,7 @@ private LsConstants() { public static final String COMMAND_REPORT_ANALYTICS = "snyk.reportAnalytics"; public static final String COMMAND_GET_FEATURE_FLAG_STATUS = "snyk.getFeatureFlagStatus"; public static final String COMMAND_CODE_FIX_DIFFS = "snyk.code.fixDiffs"; + public static final String COMMAND_CODE_FIX_APPLY_AI_EDIT = "$/snyk.code.fixApplyEdit"; public static final String COMMAND_CODE_SUBMIT_FIX_FEEDBACK = "snyk.code.submitFixFeedback"; public static final String COMMAND_SNYK_CLI = "snyk.executeCLI"; public static final String SNYK_HAS_AUTHENTICATED = "$/snyk.hasAuthenticated"; diff --git a/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java b/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java index 1f00dc85..e9a9455c 100644 --- a/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java +++ b/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java @@ -96,6 +96,7 @@ import io.snyk.languageserver.SnykLanguageServer; import io.snyk.languageserver.protocolextension.messageObjects.Diagnostic316; import io.snyk.languageserver.protocolextension.messageObjects.FeatureFlagStatus; +import io.snyk.languageserver.protocolextension.messageObjects.Fix; import io.snyk.languageserver.protocolextension.messageObjects.FolderConfig; import io.snyk.languageserver.protocolextension.messageObjects.FolderConfigsParam; import io.snyk.languageserver.protocolextension.messageObjects.HasAuthenticatedParam; @@ -869,4 +870,13 @@ public void setLs(LanguageServer ls) { this.ls = ls; } + public List sendCodeFixDiffsCommand(String folderURI, String fileURI, String issueID) { + // TODO: capture and return results + executeCommand(LsConstants.COMMAND_CODE_FIX_DIFFS, List.of(folderURI, fileURI, issueID)); + return null; + } + + public void sendCodeApplyAiFixEditCommand(String fixId) { + executeCommand(LsConstants.COMMAND_CODE_FIX_APPLY_AI_EDIT, List.of(fixId)); + } } diff --git a/plugin/src/main/java/io/snyk/languageserver/protocolextension/messageObjects/Fix.java b/plugin/src/main/java/io/snyk/languageserver/protocolextension/messageObjects/Fix.java new file mode 100644 index 00000000..38d0ec64 --- /dev/null +++ b/plugin/src/main/java/io/snyk/languageserver/protocolextension/messageObjects/Fix.java @@ -0,0 +1,11 @@ +package io.snyk.languageserver.protocolextension.messageObjects; + +import java.util.Map; + +import com.google.gson.annotations.SerializedName; + +public record Fix( + @SerializedName("fixId") String fixId, + @SerializedName("unifiedDiffsPerFile") Map unifiedDiffsPerFile) { + // no-arg constructor is generated automatically by Java compiler +} \ No newline at end of file From a820e708b5bb6e5d2c4b6044302647aadcc4b708 Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Wed, 26 Feb 2025 10:44:26 +0100 Subject: [PATCH 02/11] tidy: clean up methods order --- .pmd | 1699 +++++++++++++++++ plugin/.project | 4 +- .../views/snyktoolview/BrowserHandler.java | 13 - .../SnykExtendedLanguageClient.java | 60 +- tests/.pmd | 1699 +++++++++++++++++ 5 files changed, 3429 insertions(+), 46 deletions(-) create mode 100644 .pmd create mode 100644 tests/.pmd diff --git a/.pmd b/.pmd new file mode 100644 index 00000000..09e37c6e --- /dev/null +++ b/.pmd @@ -0,0 +1,1699 @@ + + + false + + + + + AbstractClassWithoutAbstractMethod + Best Practices + + + AccessorClassGeneration + Best Practices + + + AccessorMethodGeneration + Best Practices + + + AmbiguousResolution + Best Practices + + + ApexAssertionsShouldIncludeMessage + Best Practices + + + ApexUnitTestClassShouldHaveAsserts + Best Practices + + + ApexUnitTestClassShouldHaveRunAs + Best Practices + + + ApexUnitTestMethodShouldHaveIsTestAnnotation + Best Practices + + + ApexUnitTestShouldNotUseSeeAllDataTrue + Best Practices + + + ArrayIsStoredDirectly + Best Practices + + + AvoidGlobalModifier + Best Practices + + + AvoidInlineStyles + Best Practices + + + AvoidLogicInTrigger + Best Practices + + + AvoidMessageDigestField + Best Practices + + + AvoidPrintStackTrace + Best Practices + + + AvoidReassigningCatchVariables + Best Practices + + + AvoidReassigningLoopVariables + Best Practices + + + AvoidReassigningParameters + Best Practices + + + AvoidReassigningParameters + Best Practices + + + AvoidStringBufferField + Best Practices + + + AvoidUsingHardCodedIP + Best Practices + + + AvoidWithStatement + Best Practices + + + CheckResultSet + Best Practices + + + ClassStartNameEqualsEndName + Best Practices + + + ConnectUsingNonConnector + Best Practices + + + ConsistentReturn + Best Practices + + + ConstantsInInterface + Best Practices + + + DebugsShouldUseLoggingLevel + Best Practices + + + DefaultLabelNotLastInSwitch + Best Practices + + + DontNestJsfInJstlIteration + Best Practices + + + DoubleBraceInitialization + Best Practices + + + ForLoopCanBeForeach + Best Practices + + + ForLoopVariableCount + Best Practices + + + FunctionNameTooShort + Best Practices + + + GlobalVariable + Best Practices + + + GuardLogStatement + Best Practices + + + JUnit4SuitesShouldUseSuiteAnnotation + Best Practices + + + JUnit5TestShouldBePackagePrivate + Best Practices + + + JUnitUseExpected + Best Practices + + + LiteralsFirstInComparisons + Best Practices + + + LooseCoupling + Best Practices + + + MethodReturnsInternalArray + Best Practices + + + MissingEncoding + Best Practices + + + MissingOverride + Best Practices + + + NoClassAttribute + Best Practices + + + NoHtmlComments + Best Practices + + + NoJspForward + Best Practices + + + NonExhaustiveSwitch + Best Practices + + + OneDeclarationPerLine + Best Practices + + + PreserveStackTrace + Best Practices + + + PrimitiveWrapperInstantiation + Best Practices + + + ProhibitedInterfaceBuilder + Best Practices + + + QueueableWithoutFinalizer + Best Practices + + + ReplaceEnumerationWithIterator + Best Practices + + + ReplaceHashtableWithMap + Best Practices + + + ReplaceVectorWithList + Best Practices + + + ScopeForInVariable + Best Practices + + + SimplifiableTestAssertion + Best Practices + + + SystemPrintln + Best Practices + + + TomKytesDespair + Best Practices + + + UnavailableFunction + Best Practices + + + UnitTestAssertionsShouldIncludeMessage + Best Practices + + + UnitTestContainsTooManyAsserts + Best Practices + + + UnitTestShouldIncludeAssert + Best Practices + + + UnitTestShouldUseAfterAnnotation + Best Practices + + + UnitTestShouldUseBeforeAnnotation + Best Practices + + + UnitTestShouldUseTestAnnotation + Best Practices + + + UnnecessaryTypeAttribute + Best Practices + + + UnnecessaryVarargsArrayCreation + Best Practices + + + UnusedAssignment + Best Practices + + + UnusedFormalParameter + Best Practices + + + UnusedLocalVariable + Best Practices + + + UnusedLocalVariable + Best Practices + + + UnusedMacroParameter + Best Practices + + + UnusedPrivateField + Best Practices + + + UnusedPrivateMethod + Best Practices + + + UseAltAttributeForImages + Best Practices + + + UseBaseWithParseInt + Best Practices + + + UseCollectionIsEmpty + Best Practices + + + UseEnumCollections + Best Practices + + + UseStandardCharsets + Best Practices + + + UseTryWithResources + Best Practices + + + UseVarargs + Best Practices + + + WhileLoopWithLiteralBoolean + Best Practices + + + AssignmentInOperand + Code Style + + + AtLeastOneConstructor + Code Style + + + AvoidDollarSigns + Code Style + + + AvoidProtectedFieldInFinalClass + Code Style + + + AvoidProtectedMethodInFinalClassNotExtending + Code Style + + + AvoidTabCharacter + Code Style + + + AvoidUsingNativeCode + Code Style + + + BooleanGetMethodName + Code Style + + + CallSuperInConstructor + Code Style + + + ClassNamingConventions + Code Style + + + ClassNamingConventions + Code Style + + + CodeFormat + Code Style + + + CommentDefaultAccessModifier + Code Style + + + ConfusingTernary + Code Style + + + ControlStatementBraces + Code Style + + + DuplicateJspImports + Code Style + + + EmptyControlStatement + Code Style + + + EmptyMethodInAbstractClassShouldBeAbstract + Code Style + + + ExtendsObject + Code Style + + + FieldDeclarationsShouldBeAtStart + Code Style + + + FieldDeclarationsShouldBeAtStartOfClass + Code Style + + + FieldNamingConventions + Code Style + + + FieldNamingConventions + Code Style + + + FinalParameterInAbstractMethod + Code Style + + + ForLoopNaming + Code Style + + + ForLoopShouldBeWhileLoop + Code Style + + + ForLoopsMustUseBraces + Code Style + + + ForLoopsMustUseBraces + Code Style + + + FormalParameterNamingConventions + Code Style + + + FormalParameterNamingConventions + Code Style + + + GenericsNaming + Code Style + + + IdenticalCatchBranches + Code Style + + + IfElseStmtsMustUseBraces + Code Style + + + IfElseStmtsMustUseBraces + Code Style + + + IfStmtsMustUseBraces + Code Style + + + IfStmtsMustUseBraces + Code Style + + + LambdaCanBeMethodReference + Code Style + + + LineLength + Code Style + + + LinguisticNaming + Code Style + + + LocalHomeNamingConvention + Code Style + + + LocalInterfaceSessionNamingConvention + Code Style + + + LocalVariableCouldBeFinal + Code Style + + + LocalVariableNamingConventions + Code Style + + + LocalVariableNamingConventions + Code Style + + + LongVariable + Code Style + + + MDBAndSessionBeanNamingConvention + Code Style + + + MethodArgumentCouldBeFinal + Code Style + + + MethodNamingConventions + Code Style + + + MethodNamingConventions + Code Style + + + MisplacedPragma + Code Style + + + NoElseReturn + Code Style + + + NoPackage + Code Style + + + OneDeclarationPerLine + Code Style + + + OnlyOneReturn + Code Style + + + PackageCase + Code Style + + + PrematureDeclaration + Code Style + + + PropertyNamingConventions + Code Style + + + RemoteInterfaceNamingConvention + Code Style + + + RemoteSessionInterfaceNamingConvention + Code Style + + + ShortClassName + Code Style + + + ShortMethodName + Code Style + + + ShortVariable + Code Style + + + TooManyStaticImports + Code Style + + + UnnecessaryAnnotationValueElement + Code Style + + + UnnecessaryBlock + Code Style + + + UnnecessaryBoxing + Code Style + + + UnnecessaryCast + Code Style + + + UnnecessaryConstructor + Code Style + + + UnnecessaryFullyQualifiedName + Code Style + + + UnnecessaryImport + Code Style + + + UnnecessaryLocalBeforeReturn + Code Style + + + UnnecessaryModifier + Code Style + + + UnnecessaryParentheses + Code Style + + + UnnecessaryReturn + Code Style + + + UnnecessarySemicolon + Code Style + + + UnreachableCode + Code Style + + + UseConcatOnce + Code Style + + + UseDiamondOperator + Code Style + + + UseExplicitTypes + Code Style + + + UselessParentheses + Code Style + + + UselessQualifiedThis + Code Style + + + UseShortArrayInitializer + Code Style + + + UseUnderscoresInNumericLiterals + Code Style + + + WhileLoopsMustUseBraces + Code Style + + + WhileLoopsMustUseBraces + Code Style + + + AbstractClassWithoutAnyMethod + Design + + + AvoidCatchingGenericException + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidRethrowingException + Design + + + AvoidThrowingNewInstanceOfSameException + Design + + + AvoidThrowingNullPointerException + Design + + + AvoidThrowingRawExceptionTypes + Design + + + AvoidUncheckedExceptionsInSignatures + Design + + + ClassWithOnlyPrivateConstructorsShouldBeFinal + Design + + + CognitiveComplexity + Design + + + CognitiveComplexity + Design + + + CollapsibleIfStatements + Design + + + CollapsibleIfStatements + Design + + + CouplingBetweenObjects + Design + + + CyclomaticComplexity + Design + + + CyclomaticComplexity + Design + + + CyclomaticComplexity + Design + + + DataClass + Design + + + DoNotExtendJavaLangError + Design + + + ExceptionAsFlowControl + Design + + + ExcessiveClassLength + Design + + + ExcessiveImports + Design + + + ExcessiveMethodLength + Design + + + ExcessiveObjectLength + Design + + + ExcessivePackageBodyLength + Design + + + ExcessivePackageSpecificationLength + Design + + + ExcessiveParameterList + Design + + + ExcessiveParameterList + Design + + + ExcessiveParameterList + Design + + + ExcessivePublicCount + Design + + + ExcessivePublicCount + Design + + + ExcessiveTemplateLength + Design + + + ExcessiveTypeLength + Design + + + FinalFieldCouldBeStatic + Design + + + GodClass + Design + + + ImmutableField + Design + + + InvalidJavaBean + Design + + + LawOfDemeter + Design + + + LogicInversion + Design + + + LoosePackageCoupling + Design + + + MutableStaticState + Design + + + NcssConstructorCount + Design + + + NcssCount + Design + + + NcssMethodCount + Design + + + NcssMethodCount + Design + + + NcssObjectCount + Design + + + NcssTypeCount + Design + + + NoInlineJavaScript + Design + + + NoInlineScript + Design + + + NoInlineStyleInformation + Design + + + NoInlineStyles + Design + + + NoLongScripts + Design + + + NoScriptlets + Design + + + NPathComplexity + Design + + + NPathComplexity + Design + + + SignatureDeclareThrowsException + Design + + + SimplifiedTernary + Design + + + SimplifyBooleanExpressions + Design + + + SimplifyBooleanReturns + Design + + + SimplifyConditional + Design + + + SingularField + Design + + + StdCyclomaticComplexity + Design + + + SwitchDensity + Design + + + TooManyFields + Design + + + TooManyFields + Design + + + TooManyFields + Design + + + TooManyMethods + Design + + + TooManyMethods + Design + + + UnusedMethod + Design + + + UselessOverridingMethod + Design + + + UseObjectForClearerAPI + Design + + + UseUtilityClass + Design + + + ApexDoc + Documentation + + + CommentContent + Documentation + + + CommentRequired + Documentation + + + CommentSize + Documentation + + + UncommentedEmptyConstructor + Documentation + + + UncommentedEmptyMethodBody + Documentation + + + ApexCSRF + Error Prone + + + AssignmentInOperand + Error Prone + + + AssignmentToNonFinalStatic + Error Prone + + + AvoidAccessibilityAlteration + Error Prone + + + AvoidAssertAsIdentifier + Error Prone + + + AvoidBranchingStatementAsLastInLoop + Error Prone + + + AvoidCallingFinalize + Error Prone + + + AvoidCatchingNPE + Error Prone + + + AvoidCatchingThrowable + Error Prone + + + AvoidDecimalLiteralsInBigDecimalConstructor + Error Prone + + + AvoidDirectAccessTriggerMap + Error Prone + + + AvoidDuplicateLiterals + Error Prone + + + AvoidEnumAsIdentifier + Error Prone + + + AvoidFieldNameMatchingMethodName + Error Prone + + + AvoidFieldNameMatchingTypeName + Error Prone + + + AvoidHardcodingId + Error Prone + + + AvoidInstanceofChecksInCatchClause + Error Prone + + + AvoidLiteralsInIfCondition + Error Prone + + + AvoidLosingExceptionInformation + Error Prone + + + AvoidMultipleUnaryOperators + Error Prone + + + AvoidNonExistentAnnotations + Error Prone + + + AvoidTrailingComma + Error Prone + + + AvoidUsingOctalValues + Error Prone + + + BrokenNullCheck + Error Prone + + + CallSuperFirst + Error Prone + + + CallSuperLast + Error Prone + + + CheckSkipResult + Error Prone + + + ClassCastExceptionWithToArray + Error Prone + + + CloneMethodMustBePublic + Error Prone + + + CloneMethodMustImplementCloneable + Error Prone + + + CloneMethodReturnTypeMustMatchClassName + Error Prone + + + CloseResource + Error Prone + + + CompareObjectsWithEquals + Error Prone + + + ComparisonWithNaN + Error Prone + + + ConfusingArgumentToVarargsMethod + Error Prone + + + ConstructorCallsOverridableMethod + Error Prone + + + DetachedTestCase + Error Prone + + + DoNotCallGarbageCollectionExplicitly + Error Prone + + + DoNotExtendJavaLangThrowable + Error Prone + + + DoNotHardCodeSDCard + Error Prone + + + DoNotTerminateVM + Error Prone + + + DoNotThrowExceptionInFinally + Error Prone + + + DontImportSun + Error Prone + + + DontUseFloatTypeForLoopIndices + Error Prone + + + EmptyCatchBlock + Error Prone + + + EmptyCatchBlock + Error Prone + + + EmptyFinalizer + Error Prone + + + EmptyForeachStmt + Error Prone + + + EmptyIfStmt + Error Prone + + + EmptyIfStmt + Error Prone + + + EmptyStatementBlock + Error Prone + + + EmptyTryOrFinallyBlock + Error Prone + + + EmptyWhileStmt + Error Prone + + + EqualComparison + Error Prone + + + EqualsNull + Error Prone + + + FinalizeDoesNotCallSuperFinalize + Error Prone + + + FinalizeOnlyCallsSuperFinalize + Error Prone + + + FinalizeOverloaded + Error Prone + + + FinalizeShouldBeProtected + Error Prone + + + ForceCast + Error Prone + + + ForceTry + Error Prone + + + IdempotentOperations + Error Prone + + + ImplicitSwitchFallThrough + Error Prone + + + InaccessibleAuraEnabledGetter + Error Prone + + + InaccurateNumericLiteral + Error Prone + + + InstantiationToGetClass + Error Prone + + + InvalidDependencyTypes + Error Prone + + + InvalidLogMessageFormat + Error Prone + + + JspEncoding + Error Prone + + + JumbledIncrementer + Error Prone + + + JUnitSpelling + Error Prone + + + JUnitStaticSuite + Error Prone + + + MethodWithSameNameAsEnclosingClass + Error Prone + + + MethodWithSameNameAsEnclosingClass + Error Prone + + + MisplacedNullCheck + Error Prone + + + MissingSerialVersionUID + Error Prone + + + MissingStaticMethodInNonInstantiatableClass + Error Prone + + + MistypedCDATASection + Error Prone + + + MoreThanOneLogger + Error Prone + + + NonCaseLabelInSwitch + Error Prone + + + NonSerializableClass + Error Prone + + + NonStaticInitializer + Error Prone + + + NullAssignment + Error Prone + + + OverrideBothEqualsAndHashcode + Error Prone + + + OverrideBothEqualsAndHashcode + Error Prone + + + OverrideBothEqualsAndHashcode + Error Prone + + + ProjectVersionAsDependencyVersion + Error Prone + + + ProperCloneImplementation + Error Prone + + + ProperLogger + Error Prone + + + ReturnEmptyCollectionRatherThanNull + Error Prone + + + ReturnFromFinallyBlock + Error Prone + + + SimpleDateFormatNeedsLocale + Error Prone + + + SingleMethodSingleton + Error Prone + + + SingletonClassReturningNewInstance + Error Prone + + + StaticEJBFieldShouldBeFinal + Error Prone + + + StringBufferInstantiationWithChar + Error Prone + + + SuspiciousEqualsMethodName + Error Prone + + + SuspiciousHashcodeMethodName + Error Prone + + + SuspiciousOctalEscape + Error Prone + + + TestClassWithoutTestCases + Error Prone + + + TestMethodsMustBeInTestClasses + Error Prone + + + TO_DATEWithoutDateFormat + Error Prone + + + TO_DATE_TO_CHAR + Error Prone + + + TO_TIMESTAMPWithoutDateFormat + Error Prone + + + UnconditionalIfStatement + Error Prone + + + UnnecessaryBooleanAssertion + Error Prone + + + UnnecessaryCaseChange + Error Prone + + + UnnecessaryConversionTemporary + Error Prone + + + UnusedNullCheckInEquals + Error Prone + + + UseCorrectExceptionLogging + Error Prone + + + UseEqualsToCompareStrings + Error Prone + + + UselessOperationOnImmutable + Error Prone + + + UseLocaleWithCaseConversions + Error Prone + + + UseProperClassLoader + Error Prone + + + AvoidSynchronizedAtMethodLevel + Multithreading + + + AvoidSynchronizedStatement + Multithreading + + + AvoidThreadGroup + Multithreading + + + AvoidUsingVolatile + Multithreading + + + DoNotUseThreads + Multithreading + + + DontCallThreadRun + Multithreading + + + DoubleCheckedLocking + Multithreading + + + NonThreadSafeSingleton + Multithreading + + + UnsynchronizedStaticFormatter + Multithreading + + + UseConcurrentHashMap + Multithreading + + + UseNotifyAllInsteadOfNotify + Multithreading + + + AddEmptyString + Performance + + + AppendCharacterWithChar + Performance + + + AvoidArrayLoops + Performance + + + AvoidAxisNavigation + Performance + + + AvoidCalendarDateCreation + Performance + + + AvoidConsoleStatements + Performance + + + AvoidDebugStatements + Performance + + + AvoidFileStream + Performance + + + AvoidInstantiatingObjectsInLoops + Performance + + + AvoidNonRestrictiveQueries + Performance + + + BigIntegerInstantiation + Performance + + + ConsecutiveAppendsShouldReuse + Performance + + + ConsecutiveLiteralAppends + Performance + + + EagerlyLoadedDescribeSObjectResult + Performance + + + InefficientEmptyStringCheck + Performance + + + InefficientStringBuffering + Performance + + + InsufficientStringBufferDeclaration + Performance + + + OperationWithHighCostInLoop + Performance + + + OperationWithLimitsInLoop + Performance + + + OptimizableToArrayCall + Performance + + + RedundantFieldInitializer + Performance + + + StringInstantiation + Performance + + + StringToString + Performance + + + TooFewBranchesForSwitch + Performance + + + UseArrayListInsteadOfVector + Performance + + + UseArraysAsList + Performance + + + UseIndexOfChar + Performance + + + UseIOStreamsWithApacheCommonsFileItem + Performance + + + UselessStringValueOf + Performance + + + UseStringBufferForStringAppends + Performance + + + UseStringBufferLength + Performance + + + ApexBadCrypto + Security + + + ApexCRUDViolation + Security + + + ApexDangerousMethods + Security + + + ApexInsecureEndpoint + Security + + + ApexOpenRedirect + Security + + + ApexSharingViolations + Security + + + ApexSOQLInjection + Security + + + ApexSuggestUsingNamedCred + Security + + + ApexXSSFromEscapeFalse + Security + + + ApexXSSFromURLParam + Security + + + HardCodedCryptoKey + Security + + + IframeMissingSrcAttribute + Security + + + InsecureCryptoIv + Security + + + NoUnsanitizedJSPExpression + Security + + + VfCsrf + Security + + + VfHtmlStyleTagXss + Security + + + VfUnescapeEl + Security + + + false + true + true + diff --git a/plugin/.project b/plugin/.project index 8ccae640..287e3027 100644 --- a/plugin/.project +++ b/plugin/.project @@ -21,12 +21,12 @@ - org.eclipse.m2e.core.maven2Builder + net.sourceforge.pmd.eclipse.plugin.pmdBuilder - net.sourceforge.pmd.eclipse.plugin.pmdBuilder + org.eclipse.m2e.core.maven2Builder diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java index ec0e8386..7bdcb3ea 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java @@ -194,19 +194,6 @@ public CompletableFuture updateBrowserContent(TreeNode node) { final var browserContent = htmlProvider.replaceCssVariables(htmlContent); -// String[] lines = browserContent.split("\n"); -// for (String line : lines) { -// if (line.contains("window.generateAIFix")) { -// System.out.println(line); -// } else if (line.contains("applyAIFix")) { -// System.out.println(line); -// } else if (line.contains("issue-id")) { -// System.out.println(line); -// } else if (line.contains("folder-path")) { -// System.out.println(line); -// } -// } - Display.getDefault().syncExec(() -> { browser.setText(browserContent); }); diff --git a/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java b/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java index e9a9455c..cae674f5 100644 --- a/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java +++ b/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java @@ -334,6 +334,16 @@ public String getIssueDescription(String issueId) { return String.valueOf(result); } + public List sendCodeFixDiffsCommand(String folderURI, String fileURI, String issueID) { + // TODO: capture and return results + executeCommand(LsConstants.COMMAND_CODE_FIX_DIFFS, List.of(folderURI, fileURI, issueID)); + return null; + } + + public void sendCodeApplyAiFixEditCommand(String fixId) { + executeCommand(LsConstants.COMMAND_CODE_FIX_APPLY_AI_EDIT, List.of(fixId)); + } + @JsonNotification(value = LsConstants.SNYK_HAS_AUTHENTICATED) public void hasAuthenticated(HasAuthenticatedParam param) { var prefs = Preferences.getInstance(); @@ -478,7 +488,7 @@ public CompletableFuture showDocument( return new ShowDocumentResult(true); }); } - + private Issue getIssueFromCache(String filePath, String issueId) { SnykIssueCache issueCache = getIssueCache(filePath); return issueCache.getCodeSecurityIssuesForPath(filePath).stream() @@ -741,6 +751,18 @@ public CompletableFuture createProgress( return super.createProgress(params); } + @Override + public void notifyProgress(final ProgressParams params) { + if (params.getValue() == null) { + return; + } + WorkDoneProgressNotification progressNotification = params.getValue().getLeft(); + if (progressNotification != null && progressNotification.getKind() == WorkDoneProgressKind.end) { + this.progressManager.removeProgress(params.getToken().getLeft()); + } + super.notifyProgress(params); + } + /** * Refresh the token using language server. Waits up to 2s for the token * change. @@ -812,10 +834,6 @@ public static T convertInstanceOfObject(Object o, Class clazz) { } } - public void setToolWindow(ISnykToolView toolView) { - this.toolView = toolView; - } - public void clearCache() { List openProjects = ResourceUtils .getAccessibleTopLevelProjects(); @@ -832,24 +850,6 @@ public void clearCache() { } - public void setProgressMgr(ProgressManager progressMgr) { - this.progressManager = progressMgr; - } - - @Override - public void notifyProgress(final ProgressParams params) { - if (params.getValue() == null) { - return; - } - WorkDoneProgressNotification progressNotification = params.getValue() - .getLeft(); - if (progressNotification != null - && progressNotification.getKind() == WorkDoneProgressKind.end) { - this.progressManager.removeProgress(params.getToken().getLeft()); - } - super.notifyProgress(params); - } - @JsonRequest(value = "workspace/snyk.sdks") public CompletableFuture> getSdks( WorkspaceFolder workspaceFolder) { @@ -862,21 +862,19 @@ public CompletableFuture> getSdks( }); } - public ProgressManager getProgressManager() { - return this.progressManager; + public void setToolWindow(ISnykToolView toolView) { + this.toolView = toolView; } public void setLs(LanguageServer ls) { this.ls = ls; } - public List sendCodeFixDiffsCommand(String folderURI, String fileURI, String issueID) { - // TODO: capture and return results - executeCommand(LsConstants.COMMAND_CODE_FIX_DIFFS, List.of(folderURI, fileURI, issueID)); - return null; + public void setProgressMgr(ProgressManager progressMgr) { + this.progressManager = progressMgr; } - public void sendCodeApplyAiFixEditCommand(String fixId) { - executeCommand(LsConstants.COMMAND_CODE_FIX_APPLY_AI_EDIT, List.of(fixId)); + public ProgressManager getProgressManager() { + return this.progressManager; } } diff --git a/tests/.pmd b/tests/.pmd new file mode 100644 index 00000000..09e37c6e --- /dev/null +++ b/tests/.pmd @@ -0,0 +1,1699 @@ + + + false + + + + + AbstractClassWithoutAbstractMethod + Best Practices + + + AccessorClassGeneration + Best Practices + + + AccessorMethodGeneration + Best Practices + + + AmbiguousResolution + Best Practices + + + ApexAssertionsShouldIncludeMessage + Best Practices + + + ApexUnitTestClassShouldHaveAsserts + Best Practices + + + ApexUnitTestClassShouldHaveRunAs + Best Practices + + + ApexUnitTestMethodShouldHaveIsTestAnnotation + Best Practices + + + ApexUnitTestShouldNotUseSeeAllDataTrue + Best Practices + + + ArrayIsStoredDirectly + Best Practices + + + AvoidGlobalModifier + Best Practices + + + AvoidInlineStyles + Best Practices + + + AvoidLogicInTrigger + Best Practices + + + AvoidMessageDigestField + Best Practices + + + AvoidPrintStackTrace + Best Practices + + + AvoidReassigningCatchVariables + Best Practices + + + AvoidReassigningLoopVariables + Best Practices + + + AvoidReassigningParameters + Best Practices + + + AvoidReassigningParameters + Best Practices + + + AvoidStringBufferField + Best Practices + + + AvoidUsingHardCodedIP + Best Practices + + + AvoidWithStatement + Best Practices + + + CheckResultSet + Best Practices + + + ClassStartNameEqualsEndName + Best Practices + + + ConnectUsingNonConnector + Best Practices + + + ConsistentReturn + Best Practices + + + ConstantsInInterface + Best Practices + + + DebugsShouldUseLoggingLevel + Best Practices + + + DefaultLabelNotLastInSwitch + Best Practices + + + DontNestJsfInJstlIteration + Best Practices + + + DoubleBraceInitialization + Best Practices + + + ForLoopCanBeForeach + Best Practices + + + ForLoopVariableCount + Best Practices + + + FunctionNameTooShort + Best Practices + + + GlobalVariable + Best Practices + + + GuardLogStatement + Best Practices + + + JUnit4SuitesShouldUseSuiteAnnotation + Best Practices + + + JUnit5TestShouldBePackagePrivate + Best Practices + + + JUnitUseExpected + Best Practices + + + LiteralsFirstInComparisons + Best Practices + + + LooseCoupling + Best Practices + + + MethodReturnsInternalArray + Best Practices + + + MissingEncoding + Best Practices + + + MissingOverride + Best Practices + + + NoClassAttribute + Best Practices + + + NoHtmlComments + Best Practices + + + NoJspForward + Best Practices + + + NonExhaustiveSwitch + Best Practices + + + OneDeclarationPerLine + Best Practices + + + PreserveStackTrace + Best Practices + + + PrimitiveWrapperInstantiation + Best Practices + + + ProhibitedInterfaceBuilder + Best Practices + + + QueueableWithoutFinalizer + Best Practices + + + ReplaceEnumerationWithIterator + Best Practices + + + ReplaceHashtableWithMap + Best Practices + + + ReplaceVectorWithList + Best Practices + + + ScopeForInVariable + Best Practices + + + SimplifiableTestAssertion + Best Practices + + + SystemPrintln + Best Practices + + + TomKytesDespair + Best Practices + + + UnavailableFunction + Best Practices + + + UnitTestAssertionsShouldIncludeMessage + Best Practices + + + UnitTestContainsTooManyAsserts + Best Practices + + + UnitTestShouldIncludeAssert + Best Practices + + + UnitTestShouldUseAfterAnnotation + Best Practices + + + UnitTestShouldUseBeforeAnnotation + Best Practices + + + UnitTestShouldUseTestAnnotation + Best Practices + + + UnnecessaryTypeAttribute + Best Practices + + + UnnecessaryVarargsArrayCreation + Best Practices + + + UnusedAssignment + Best Practices + + + UnusedFormalParameter + Best Practices + + + UnusedLocalVariable + Best Practices + + + UnusedLocalVariable + Best Practices + + + UnusedMacroParameter + Best Practices + + + UnusedPrivateField + Best Practices + + + UnusedPrivateMethod + Best Practices + + + UseAltAttributeForImages + Best Practices + + + UseBaseWithParseInt + Best Practices + + + UseCollectionIsEmpty + Best Practices + + + UseEnumCollections + Best Practices + + + UseStandardCharsets + Best Practices + + + UseTryWithResources + Best Practices + + + UseVarargs + Best Practices + + + WhileLoopWithLiteralBoolean + Best Practices + + + AssignmentInOperand + Code Style + + + AtLeastOneConstructor + Code Style + + + AvoidDollarSigns + Code Style + + + AvoidProtectedFieldInFinalClass + Code Style + + + AvoidProtectedMethodInFinalClassNotExtending + Code Style + + + AvoidTabCharacter + Code Style + + + AvoidUsingNativeCode + Code Style + + + BooleanGetMethodName + Code Style + + + CallSuperInConstructor + Code Style + + + ClassNamingConventions + Code Style + + + ClassNamingConventions + Code Style + + + CodeFormat + Code Style + + + CommentDefaultAccessModifier + Code Style + + + ConfusingTernary + Code Style + + + ControlStatementBraces + Code Style + + + DuplicateJspImports + Code Style + + + EmptyControlStatement + Code Style + + + EmptyMethodInAbstractClassShouldBeAbstract + Code Style + + + ExtendsObject + Code Style + + + FieldDeclarationsShouldBeAtStart + Code Style + + + FieldDeclarationsShouldBeAtStartOfClass + Code Style + + + FieldNamingConventions + Code Style + + + FieldNamingConventions + Code Style + + + FinalParameterInAbstractMethod + Code Style + + + ForLoopNaming + Code Style + + + ForLoopShouldBeWhileLoop + Code Style + + + ForLoopsMustUseBraces + Code Style + + + ForLoopsMustUseBraces + Code Style + + + FormalParameterNamingConventions + Code Style + + + FormalParameterNamingConventions + Code Style + + + GenericsNaming + Code Style + + + IdenticalCatchBranches + Code Style + + + IfElseStmtsMustUseBraces + Code Style + + + IfElseStmtsMustUseBraces + Code Style + + + IfStmtsMustUseBraces + Code Style + + + IfStmtsMustUseBraces + Code Style + + + LambdaCanBeMethodReference + Code Style + + + LineLength + Code Style + + + LinguisticNaming + Code Style + + + LocalHomeNamingConvention + Code Style + + + LocalInterfaceSessionNamingConvention + Code Style + + + LocalVariableCouldBeFinal + Code Style + + + LocalVariableNamingConventions + Code Style + + + LocalVariableNamingConventions + Code Style + + + LongVariable + Code Style + + + MDBAndSessionBeanNamingConvention + Code Style + + + MethodArgumentCouldBeFinal + Code Style + + + MethodNamingConventions + Code Style + + + MethodNamingConventions + Code Style + + + MisplacedPragma + Code Style + + + NoElseReturn + Code Style + + + NoPackage + Code Style + + + OneDeclarationPerLine + Code Style + + + OnlyOneReturn + Code Style + + + PackageCase + Code Style + + + PrematureDeclaration + Code Style + + + PropertyNamingConventions + Code Style + + + RemoteInterfaceNamingConvention + Code Style + + + RemoteSessionInterfaceNamingConvention + Code Style + + + ShortClassName + Code Style + + + ShortMethodName + Code Style + + + ShortVariable + Code Style + + + TooManyStaticImports + Code Style + + + UnnecessaryAnnotationValueElement + Code Style + + + UnnecessaryBlock + Code Style + + + UnnecessaryBoxing + Code Style + + + UnnecessaryCast + Code Style + + + UnnecessaryConstructor + Code Style + + + UnnecessaryFullyQualifiedName + Code Style + + + UnnecessaryImport + Code Style + + + UnnecessaryLocalBeforeReturn + Code Style + + + UnnecessaryModifier + Code Style + + + UnnecessaryParentheses + Code Style + + + UnnecessaryReturn + Code Style + + + UnnecessarySemicolon + Code Style + + + UnreachableCode + Code Style + + + UseConcatOnce + Code Style + + + UseDiamondOperator + Code Style + + + UseExplicitTypes + Code Style + + + UselessParentheses + Code Style + + + UselessQualifiedThis + Code Style + + + UseShortArrayInitializer + Code Style + + + UseUnderscoresInNumericLiterals + Code Style + + + WhileLoopsMustUseBraces + Code Style + + + WhileLoopsMustUseBraces + Code Style + + + AbstractClassWithoutAnyMethod + Design + + + AvoidCatchingGenericException + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidRethrowingException + Design + + + AvoidThrowingNewInstanceOfSameException + Design + + + AvoidThrowingNullPointerException + Design + + + AvoidThrowingRawExceptionTypes + Design + + + AvoidUncheckedExceptionsInSignatures + Design + + + ClassWithOnlyPrivateConstructorsShouldBeFinal + Design + + + CognitiveComplexity + Design + + + CognitiveComplexity + Design + + + CollapsibleIfStatements + Design + + + CollapsibleIfStatements + Design + + + CouplingBetweenObjects + Design + + + CyclomaticComplexity + Design + + + CyclomaticComplexity + Design + + + CyclomaticComplexity + Design + + + DataClass + Design + + + DoNotExtendJavaLangError + Design + + + ExceptionAsFlowControl + Design + + + ExcessiveClassLength + Design + + + ExcessiveImports + Design + + + ExcessiveMethodLength + Design + + + ExcessiveObjectLength + Design + + + ExcessivePackageBodyLength + Design + + + ExcessivePackageSpecificationLength + Design + + + ExcessiveParameterList + Design + + + ExcessiveParameterList + Design + + + ExcessiveParameterList + Design + + + ExcessivePublicCount + Design + + + ExcessivePublicCount + Design + + + ExcessiveTemplateLength + Design + + + ExcessiveTypeLength + Design + + + FinalFieldCouldBeStatic + Design + + + GodClass + Design + + + ImmutableField + Design + + + InvalidJavaBean + Design + + + LawOfDemeter + Design + + + LogicInversion + Design + + + LoosePackageCoupling + Design + + + MutableStaticState + Design + + + NcssConstructorCount + Design + + + NcssCount + Design + + + NcssMethodCount + Design + + + NcssMethodCount + Design + + + NcssObjectCount + Design + + + NcssTypeCount + Design + + + NoInlineJavaScript + Design + + + NoInlineScript + Design + + + NoInlineStyleInformation + Design + + + NoInlineStyles + Design + + + NoLongScripts + Design + + + NoScriptlets + Design + + + NPathComplexity + Design + + + NPathComplexity + Design + + + SignatureDeclareThrowsException + Design + + + SimplifiedTernary + Design + + + SimplifyBooleanExpressions + Design + + + SimplifyBooleanReturns + Design + + + SimplifyConditional + Design + + + SingularField + Design + + + StdCyclomaticComplexity + Design + + + SwitchDensity + Design + + + TooManyFields + Design + + + TooManyFields + Design + + + TooManyFields + Design + + + TooManyMethods + Design + + + TooManyMethods + Design + + + UnusedMethod + Design + + + UselessOverridingMethod + Design + + + UseObjectForClearerAPI + Design + + + UseUtilityClass + Design + + + ApexDoc + Documentation + + + CommentContent + Documentation + + + CommentRequired + Documentation + + + CommentSize + Documentation + + + UncommentedEmptyConstructor + Documentation + + + UncommentedEmptyMethodBody + Documentation + + + ApexCSRF + Error Prone + + + AssignmentInOperand + Error Prone + + + AssignmentToNonFinalStatic + Error Prone + + + AvoidAccessibilityAlteration + Error Prone + + + AvoidAssertAsIdentifier + Error Prone + + + AvoidBranchingStatementAsLastInLoop + Error Prone + + + AvoidCallingFinalize + Error Prone + + + AvoidCatchingNPE + Error Prone + + + AvoidCatchingThrowable + Error Prone + + + AvoidDecimalLiteralsInBigDecimalConstructor + Error Prone + + + AvoidDirectAccessTriggerMap + Error Prone + + + AvoidDuplicateLiterals + Error Prone + + + AvoidEnumAsIdentifier + Error Prone + + + AvoidFieldNameMatchingMethodName + Error Prone + + + AvoidFieldNameMatchingTypeName + Error Prone + + + AvoidHardcodingId + Error Prone + + + AvoidInstanceofChecksInCatchClause + Error Prone + + + AvoidLiteralsInIfCondition + Error Prone + + + AvoidLosingExceptionInformation + Error Prone + + + AvoidMultipleUnaryOperators + Error Prone + + + AvoidNonExistentAnnotations + Error Prone + + + AvoidTrailingComma + Error Prone + + + AvoidUsingOctalValues + Error Prone + + + BrokenNullCheck + Error Prone + + + CallSuperFirst + Error Prone + + + CallSuperLast + Error Prone + + + CheckSkipResult + Error Prone + + + ClassCastExceptionWithToArray + Error Prone + + + CloneMethodMustBePublic + Error Prone + + + CloneMethodMustImplementCloneable + Error Prone + + + CloneMethodReturnTypeMustMatchClassName + Error Prone + + + CloseResource + Error Prone + + + CompareObjectsWithEquals + Error Prone + + + ComparisonWithNaN + Error Prone + + + ConfusingArgumentToVarargsMethod + Error Prone + + + ConstructorCallsOverridableMethod + Error Prone + + + DetachedTestCase + Error Prone + + + DoNotCallGarbageCollectionExplicitly + Error Prone + + + DoNotExtendJavaLangThrowable + Error Prone + + + DoNotHardCodeSDCard + Error Prone + + + DoNotTerminateVM + Error Prone + + + DoNotThrowExceptionInFinally + Error Prone + + + DontImportSun + Error Prone + + + DontUseFloatTypeForLoopIndices + Error Prone + + + EmptyCatchBlock + Error Prone + + + EmptyCatchBlock + Error Prone + + + EmptyFinalizer + Error Prone + + + EmptyForeachStmt + Error Prone + + + EmptyIfStmt + Error Prone + + + EmptyIfStmt + Error Prone + + + EmptyStatementBlock + Error Prone + + + EmptyTryOrFinallyBlock + Error Prone + + + EmptyWhileStmt + Error Prone + + + EqualComparison + Error Prone + + + EqualsNull + Error Prone + + + FinalizeDoesNotCallSuperFinalize + Error Prone + + + FinalizeOnlyCallsSuperFinalize + Error Prone + + + FinalizeOverloaded + Error Prone + + + FinalizeShouldBeProtected + Error Prone + + + ForceCast + Error Prone + + + ForceTry + Error Prone + + + IdempotentOperations + Error Prone + + + ImplicitSwitchFallThrough + Error Prone + + + InaccessibleAuraEnabledGetter + Error Prone + + + InaccurateNumericLiteral + Error Prone + + + InstantiationToGetClass + Error Prone + + + InvalidDependencyTypes + Error Prone + + + InvalidLogMessageFormat + Error Prone + + + JspEncoding + Error Prone + + + JumbledIncrementer + Error Prone + + + JUnitSpelling + Error Prone + + + JUnitStaticSuite + Error Prone + + + MethodWithSameNameAsEnclosingClass + Error Prone + + + MethodWithSameNameAsEnclosingClass + Error Prone + + + MisplacedNullCheck + Error Prone + + + MissingSerialVersionUID + Error Prone + + + MissingStaticMethodInNonInstantiatableClass + Error Prone + + + MistypedCDATASection + Error Prone + + + MoreThanOneLogger + Error Prone + + + NonCaseLabelInSwitch + Error Prone + + + NonSerializableClass + Error Prone + + + NonStaticInitializer + Error Prone + + + NullAssignment + Error Prone + + + OverrideBothEqualsAndHashcode + Error Prone + + + OverrideBothEqualsAndHashcode + Error Prone + + + OverrideBothEqualsAndHashcode + Error Prone + + + ProjectVersionAsDependencyVersion + Error Prone + + + ProperCloneImplementation + Error Prone + + + ProperLogger + Error Prone + + + ReturnEmptyCollectionRatherThanNull + Error Prone + + + ReturnFromFinallyBlock + Error Prone + + + SimpleDateFormatNeedsLocale + Error Prone + + + SingleMethodSingleton + Error Prone + + + SingletonClassReturningNewInstance + Error Prone + + + StaticEJBFieldShouldBeFinal + Error Prone + + + StringBufferInstantiationWithChar + Error Prone + + + SuspiciousEqualsMethodName + Error Prone + + + SuspiciousHashcodeMethodName + Error Prone + + + SuspiciousOctalEscape + Error Prone + + + TestClassWithoutTestCases + Error Prone + + + TestMethodsMustBeInTestClasses + Error Prone + + + TO_DATEWithoutDateFormat + Error Prone + + + TO_DATE_TO_CHAR + Error Prone + + + TO_TIMESTAMPWithoutDateFormat + Error Prone + + + UnconditionalIfStatement + Error Prone + + + UnnecessaryBooleanAssertion + Error Prone + + + UnnecessaryCaseChange + Error Prone + + + UnnecessaryConversionTemporary + Error Prone + + + UnusedNullCheckInEquals + Error Prone + + + UseCorrectExceptionLogging + Error Prone + + + UseEqualsToCompareStrings + Error Prone + + + UselessOperationOnImmutable + Error Prone + + + UseLocaleWithCaseConversions + Error Prone + + + UseProperClassLoader + Error Prone + + + AvoidSynchronizedAtMethodLevel + Multithreading + + + AvoidSynchronizedStatement + Multithreading + + + AvoidThreadGroup + Multithreading + + + AvoidUsingVolatile + Multithreading + + + DoNotUseThreads + Multithreading + + + DontCallThreadRun + Multithreading + + + DoubleCheckedLocking + Multithreading + + + NonThreadSafeSingleton + Multithreading + + + UnsynchronizedStaticFormatter + Multithreading + + + UseConcurrentHashMap + Multithreading + + + UseNotifyAllInsteadOfNotify + Multithreading + + + AddEmptyString + Performance + + + AppendCharacterWithChar + Performance + + + AvoidArrayLoops + Performance + + + AvoidAxisNavigation + Performance + + + AvoidCalendarDateCreation + Performance + + + AvoidConsoleStatements + Performance + + + AvoidDebugStatements + Performance + + + AvoidFileStream + Performance + + + AvoidInstantiatingObjectsInLoops + Performance + + + AvoidNonRestrictiveQueries + Performance + + + BigIntegerInstantiation + Performance + + + ConsecutiveAppendsShouldReuse + Performance + + + ConsecutiveLiteralAppends + Performance + + + EagerlyLoadedDescribeSObjectResult + Performance + + + InefficientEmptyStringCheck + Performance + + + InefficientStringBuffering + Performance + + + InsufficientStringBufferDeclaration + Performance + + + OperationWithHighCostInLoop + Performance + + + OperationWithLimitsInLoop + Performance + + + OptimizableToArrayCall + Performance + + + RedundantFieldInitializer + Performance + + + StringInstantiation + Performance + + + StringToString + Performance + + + TooFewBranchesForSwitch + Performance + + + UseArrayListInsteadOfVector + Performance + + + UseArraysAsList + Performance + + + UseIndexOfChar + Performance + + + UseIOStreamsWithApacheCommonsFileItem + Performance + + + UselessStringValueOf + Performance + + + UseStringBufferForStringAppends + Performance + + + UseStringBufferLength + Performance + + + ApexBadCrypto + Security + + + ApexCRUDViolation + Security + + + ApexDangerousMethods + Security + + + ApexInsecureEndpoint + Security + + + ApexOpenRedirect + Security + + + ApexSharingViolations + Security + + + ApexSOQLInjection + Security + + + ApexSuggestUsingNamedCred + Security + + + ApexXSSFromEscapeFalse + Security + + + ApexXSSFromURLParam + Security + + + HardCodedCryptoKey + Security + + + IframeMissingSrcAttribute + Security + + + InsecureCryptoIv + Security + + + NoUnsanitizedJSPExpression + Security + + + VfCsrf + Security + + + VfHtmlStyleTagXss + Security + + + VfUnescapeEl + Security + + + false + true + true + From 887fe22934641bed3800470e24f731297c88ef54 Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Wed, 26 Feb 2025 10:45:07 +0100 Subject: [PATCH 03/11] fix: update the javascript callback functions --- .../io/snyk/eclipse/plugin/html/CodeHtmlProvider.java | 8 ++------ .../eclipse/plugin/views/snyktoolview/BrowserHandler.java | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java index 748c0630..20be898b 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java @@ -86,15 +86,11 @@ private String getReplaceAIFixScripts(String html) { } private String getGenerateAiFixScript() { - // TODO this script is broken, does not trigger a generate - return "const issueId = generateAIFixButton.getAttribute('issue-id');\n" - + "const folderPath = generateAIFixButton.getAttribute('folder-path');\n" - + "const filePath = generateAIFixButton.getAttribute('file-path');\n" + "console.log(filePath);\n" - + "window.generateAIFix(folderPath + \"@|@\" + filePath + \"@|@\" + issueId);"; + return "window.ideGenerateAIFix(generateFixQueryString)\n;"; } private String getApplyAiFixScript() { - return "window.applyAIFix(fixId + '|@' + filePath + '|@' + patch);\n"; + return "window.ideApplyFix(fixId + '|@' + filePath + '|@' + patch);\n"; } } diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java index 7bdcb3ea..70bd1e8a 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java @@ -99,7 +99,7 @@ public Object function(Object[] arguments) { } }; - new BrowserFunction(browser, "generateAIFix") { + new BrowserFunction(browser, "ideGenerateAIFix") { @Override public Object function(Object[] arguments) { browser.execute("debugger;"); // Triggers a breakpoint for debugging @@ -118,7 +118,7 @@ public Object function(Object[] arguments) { } }; - new BrowserFunction(browser, "applyAIFix") { + new BrowserFunction(browser, "ideApplyFix") { @Override public Object function(Object[] arguments) { System.out.println("applyAIFix"); From 5b9d3d24744cf55f01f61628bd682e40749ad4ac Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Wed, 26 Feb 2025 10:56:01 +0100 Subject: [PATCH 04/11] fix: rename replace script function --- .../java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java | 4 ++-- .../eclipse/plugin/views/snyktoolview/BrowserHandler.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java index 20be898b..e545a6c8 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java @@ -73,12 +73,12 @@ public String replaceCssVariables(String html) { htmlStyled = htmlStyled.replace("var(--disabled-background-color)", super.getColorAsHex("ADDITION_COLOR", "#00ff00")); - String htmlWithScripts = getReplaceAIFixScripts(htmlStyled); + String htmlWithScripts = replaceAIFixScripts(htmlStyled); return htmlWithScripts; } - private String getReplaceAIFixScripts(String html) { + private String replaceAIFixScripts(String html) { String htmlWithGenerateFunc = html.replace("${ideGenerateAIFix}", getGenerateAiFixScript()); String htmlWithApplyFunc = htmlWithGenerateFunc.replace("${ideApplyAIFix}", getApplyAiFixScript()); diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java index 70bd1e8a..a3d86c8d 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java @@ -102,7 +102,7 @@ public Object function(Object[] arguments) { new BrowserFunction(browser, "ideGenerateAIFix") { @Override public Object function(Object[] arguments) { - browser.execute("debugger;"); // Triggers a breakpoint for debugging + //browser.execute("debugger;"); // Triggers a breakpoint for debugging System.out.println("generateAIFix"); SnykLogger.logInfo("generateAIFix"); From 296567a67ca1b817cdd48f57f7bd34c79d7d1f31 Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Wed, 26 Feb 2025 19:30:06 +0100 Subject: [PATCH 05/11] fix: color on generate fix button --- .../java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java index e545a6c8..6a2623de 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java @@ -68,10 +68,9 @@ public String replaceCssVariables(String html) { htmlStyled = htmlStyled.replace("var(--example-line-added-color)", super.getColorAsHex("ADDITION_COLOR", "#00ff00")); htmlStyled = htmlStyled.replace("var(--generated-ai-fix-button-background-color)", -// super.getColorAsHex("org.eclipse.ui.workbench.INACTIVE_TAB_BG_START", "#F0F0F0")); - super.getColorAsHex("ADDITION_COLOR", "#00ff00")); + super.getColorAsHex("BUTTON_COLOR", "#375578")); htmlStyled = htmlStyled.replace("var(--disabled-background-color)", - super.getColorAsHex("ADDITION_COLOR", "#00ff00")); + super.getColorAsHex("ADDITION_COLOR", "#6e6e6e")); String htmlWithScripts = replaceAIFixScripts(htmlStyled); From 5a780e74443df31fb8dbaf2120eb389cf8367895 Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Thu, 27 Feb 2025 10:28:29 +0100 Subject: [PATCH 06/11] fix: generate ai fix button calls Snyk Language Server --- .../eclipse/plugin/html/CodeHtmlProvider.java | 4 ++-- .../views/snyktoolview/BrowserHandler.java | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java index 6a2623de..548f3ba3 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java @@ -85,11 +85,11 @@ private String replaceAIFixScripts(String html) { } private String getGenerateAiFixScript() { - return "window.ideGenerateAIFix(generateFixQueryString)\n;"; + return "window.ideGenAIFix(generateFixQueryString)\n;"; } private String getApplyAiFixScript() { - return "window.ideApplyFix(fixId + '|@' + filePath + '|@' + patch);\n"; + return "window.ideApplyFix(fixId);\n"; } } diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java index a3d86c8d..4269335f 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java @@ -99,19 +99,21 @@ public Object function(Object[] arguments) { } }; - new BrowserFunction(browser, "ideGenerateAIFix") { + new BrowserFunction(browser, "ideGenAIFix") { @Override public Object function(Object[] arguments) { - //browser.execute("debugger;"); // Triggers a breakpoint for debugging + // browser.execute("debugger;"); // Triggers a breakpoint for debugging System.out.println("generateAIFix"); SnykLogger.logInfo("generateAIFix"); - String folderURI = (String) arguments[0]; - String fileURI = (String) arguments[1]; - String issueID = (String) arguments[2]; + String params = (String) arguments[0]; + String[] parts = params.split("@|@"); - // Do we want to capture and do something with the responseDiffs here? - List responseDiffs = SnykExtendedLanguageClient.getInstance().sendCodeFixDiffsCommand(folderURI, + String folderURI = (String) parts[0]; + String fileURI = (String) parts[2]; + String issueID = (String) parts[4]; + + SnykExtendedLanguageClient.getInstance().sendCodeFixDiffsCommand(folderURI, fileURI, issueID); return null; @@ -123,7 +125,7 @@ public Object function(Object[] arguments) { public Object function(Object[] arguments) { System.out.println("applyAIFix"); SnykLogger.logInfo("applyAIFix"); - + String fixId = (String) arguments[0]; SnykExtendedLanguageClient.getInstance().sendCodeApplyAiFixEditCommand(fixId); return null; From 0cf1a0a8fd6349d73a89ce2e8a1a0cf99d9faf2b Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Thu, 27 Feb 2025 10:58:50 +0100 Subject: [PATCH 07/11] fix: call the correct command identifier --- .../eclipse/plugin/html/CodeHtmlProvider.java | 2 +- .../views/snyktoolview/BrowserHandler.java | 20 ++++++------------- .../io/snyk/languageserver/LsConstants.java | 2 +- .../SnykExtendedLanguageClient.java | 4 +--- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java index 548f3ba3..b7514fdf 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java @@ -70,7 +70,7 @@ public String replaceCssVariables(String html) { htmlStyled = htmlStyled.replace("var(--generated-ai-fix-button-background-color)", super.getColorAsHex("BUTTON_COLOR", "#375578")); htmlStyled = htmlStyled.replace("var(--disabled-background-color)", - super.getColorAsHex("ADDITION_COLOR", "#6e6e6e")); + super.getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_OUTER_KEYLINE_COLOR", "#CCCCCC")); String htmlWithScripts = replaceAIFixScripts(htmlStyled); diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java index 4269335f..8ba977f6 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java @@ -3,7 +3,7 @@ import static org.apache.commons.lang3.StringUtils.isEmpty; import java.nio.file.Paths; -import java.util.List; +import java.util.Collections; import java.util.concurrent.CompletableFuture; import org.eclipse.core.commands.common.CommandException; @@ -33,7 +33,6 @@ import io.snyk.eclipse.plugin.views.snyktoolview.handlers.IHandlerCommands; import io.snyk.eclipse.plugin.wizards.SnykWizard; import io.snyk.languageserver.protocolextension.SnykExtendedLanguageClient; -import io.snyk.languageserver.protocolextension.messageObjects.Fix; @SuppressWarnings("restriction") public class BrowserHandler { @@ -102,33 +101,26 @@ public Object function(Object[] arguments) { new BrowserFunction(browser, "ideGenAIFix") { @Override public Object function(Object[] arguments) { - // browser.execute("debugger;"); // Triggers a breakpoint for debugging - System.out.println("generateAIFix"); - SnykLogger.logInfo("generateAIFix"); - String params = (String) arguments[0]; String[] parts = params.split("@|@"); - String folderURI = (String) parts[0]; String fileURI = (String) parts[2]; String issueID = (String) parts[4]; - SnykExtendedLanguageClient.getInstance().sendCodeFixDiffsCommand(folderURI, - fileURI, issueID); + SnykExtendedLanguageClient.getInstance().sendCodeFixDiffsCommand(folderURI, fileURI, issueID); - return null; + return Collections.emptyList(); } }; new BrowserFunction(browser, "ideApplyFix") { @Override public Object function(Object[] arguments) { - System.out.println("applyAIFix"); - SnykLogger.logInfo("applyAIFix"); - String fixId = (String) arguments[0]; + SnykExtendedLanguageClient.getInstance().sendCodeApplyAiFixEditCommand(fixId); - return null; + + return Collections.emptyList(); } }; diff --git a/plugin/src/main/java/io/snyk/languageserver/LsConstants.java b/plugin/src/main/java/io/snyk/languageserver/LsConstants.java index ad39821d..d9fd926d 100644 --- a/plugin/src/main/java/io/snyk/languageserver/LsConstants.java +++ b/plugin/src/main/java/io/snyk/languageserver/LsConstants.java @@ -17,7 +17,7 @@ private LsConstants() { public static final String COMMAND_REPORT_ANALYTICS = "snyk.reportAnalytics"; public static final String COMMAND_GET_FEATURE_FLAG_STATUS = "snyk.getFeatureFlagStatus"; public static final String COMMAND_CODE_FIX_DIFFS = "snyk.code.fixDiffs"; - public static final String COMMAND_CODE_FIX_APPLY_AI_EDIT = "$/snyk.code.fixApplyEdit"; + public static final String COMMAND_CODE_FIX_APPLY_AI_EDIT = "snyk.code.fixApplyEdit"; public static final String COMMAND_CODE_SUBMIT_FIX_FEEDBACK = "snyk.code.submitFixFeedback"; public static final String COMMAND_SNYK_CLI = "snyk.executeCLI"; public static final String SNYK_HAS_AUTHENTICATED = "$/snyk.hasAuthenticated"; diff --git a/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java b/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java index cae674f5..d0456ea2 100644 --- a/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java +++ b/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java @@ -334,10 +334,8 @@ public String getIssueDescription(String issueId) { return String.valueOf(result); } - public List sendCodeFixDiffsCommand(String folderURI, String fileURI, String issueID) { - // TODO: capture and return results + public void sendCodeFixDiffsCommand(String folderURI, String fileURI, String issueID) { executeCommand(LsConstants.COMMAND_CODE_FIX_DIFFS, List.of(folderURI, fileURI, issueID)); - return null; } public void sendCodeApplyAiFixEditCommand(String fixId) { From 7f8aefbcac5d1f583d72ca25b781dbb52079d710 Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Fri, 28 Feb 2025 10:46:04 +0100 Subject: [PATCH 08/11] fix: code review comments --- .../java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java index b7514fdf..bac2a28a 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/html/CodeHtmlProvider.java @@ -78,10 +78,10 @@ public String replaceCssVariables(String html) { } private String replaceAIFixScripts(String html) { - String htmlWithGenerateFunc = html.replace("${ideGenerateAIFix}", getGenerateAiFixScript()); - String htmlWithApplyFunc = htmlWithGenerateFunc.replace("${ideApplyAIFix}", getApplyAiFixScript()); + String htmlWithAiFixScripts = html.replace("${ideGenerateAIFix}", getGenerateAiFixScript()); + htmlWithAiFixScripts = htmlWithAiFixScripts.replace("${ideApplyAIFix}", getApplyAiFixScript()); - return htmlWithApplyFunc; + return htmlWithAiFixScripts; } private String getGenerateAiFixScript() { From a025a01c53063314b676c6719e0b6d17317f7df3 Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Fri, 28 Feb 2025 10:53:08 +0100 Subject: [PATCH 09/11] fix: remove files --- .pmd | 1699 ---------------------------------------------------- tests/.pmd | 1699 ---------------------------------------------------- 2 files changed, 3398 deletions(-) delete mode 100644 .pmd delete mode 100644 tests/.pmd diff --git a/.pmd b/.pmd deleted file mode 100644 index 09e37c6e..00000000 --- a/.pmd +++ /dev/null @@ -1,1699 +0,0 @@ - - - false - - - - - AbstractClassWithoutAbstractMethod - Best Practices - - - AccessorClassGeneration - Best Practices - - - AccessorMethodGeneration - Best Practices - - - AmbiguousResolution - Best Practices - - - ApexAssertionsShouldIncludeMessage - Best Practices - - - ApexUnitTestClassShouldHaveAsserts - Best Practices - - - ApexUnitTestClassShouldHaveRunAs - Best Practices - - - ApexUnitTestMethodShouldHaveIsTestAnnotation - Best Practices - - - ApexUnitTestShouldNotUseSeeAllDataTrue - Best Practices - - - ArrayIsStoredDirectly - Best Practices - - - AvoidGlobalModifier - Best Practices - - - AvoidInlineStyles - Best Practices - - - AvoidLogicInTrigger - Best Practices - - - AvoidMessageDigestField - Best Practices - - - AvoidPrintStackTrace - Best Practices - - - AvoidReassigningCatchVariables - Best Practices - - - AvoidReassigningLoopVariables - Best Practices - - - AvoidReassigningParameters - Best Practices - - - AvoidReassigningParameters - Best Practices - - - AvoidStringBufferField - Best Practices - - - AvoidUsingHardCodedIP - Best Practices - - - AvoidWithStatement - Best Practices - - - CheckResultSet - Best Practices - - - ClassStartNameEqualsEndName - Best Practices - - - ConnectUsingNonConnector - Best Practices - - - ConsistentReturn - Best Practices - - - ConstantsInInterface - Best Practices - - - DebugsShouldUseLoggingLevel - Best Practices - - - DefaultLabelNotLastInSwitch - Best Practices - - - DontNestJsfInJstlIteration - Best Practices - - - DoubleBraceInitialization - Best Practices - - - ForLoopCanBeForeach - Best Practices - - - ForLoopVariableCount - Best Practices - - - FunctionNameTooShort - Best Practices - - - GlobalVariable - Best Practices - - - GuardLogStatement - Best Practices - - - JUnit4SuitesShouldUseSuiteAnnotation - Best Practices - - - JUnit5TestShouldBePackagePrivate - Best Practices - - - JUnitUseExpected - Best Practices - - - LiteralsFirstInComparisons - Best Practices - - - LooseCoupling - Best Practices - - - MethodReturnsInternalArray - Best Practices - - - MissingEncoding - Best Practices - - - MissingOverride - Best Practices - - - NoClassAttribute - Best Practices - - - NoHtmlComments - Best Practices - - - NoJspForward - Best Practices - - - NonExhaustiveSwitch - Best Practices - - - OneDeclarationPerLine - Best Practices - - - PreserveStackTrace - Best Practices - - - PrimitiveWrapperInstantiation - Best Practices - - - ProhibitedInterfaceBuilder - Best Practices - - - QueueableWithoutFinalizer - Best Practices - - - ReplaceEnumerationWithIterator - Best Practices - - - ReplaceHashtableWithMap - Best Practices - - - ReplaceVectorWithList - Best Practices - - - ScopeForInVariable - Best Practices - - - SimplifiableTestAssertion - Best Practices - - - SystemPrintln - Best Practices - - - TomKytesDespair - Best Practices - - - UnavailableFunction - Best Practices - - - UnitTestAssertionsShouldIncludeMessage - Best Practices - - - UnitTestContainsTooManyAsserts - Best Practices - - - UnitTestShouldIncludeAssert - Best Practices - - - UnitTestShouldUseAfterAnnotation - Best Practices - - - UnitTestShouldUseBeforeAnnotation - Best Practices - - - UnitTestShouldUseTestAnnotation - Best Practices - - - UnnecessaryTypeAttribute - Best Practices - - - UnnecessaryVarargsArrayCreation - Best Practices - - - UnusedAssignment - Best Practices - - - UnusedFormalParameter - Best Practices - - - UnusedLocalVariable - Best Practices - - - UnusedLocalVariable - Best Practices - - - UnusedMacroParameter - Best Practices - - - UnusedPrivateField - Best Practices - - - UnusedPrivateMethod - Best Practices - - - UseAltAttributeForImages - Best Practices - - - UseBaseWithParseInt - Best Practices - - - UseCollectionIsEmpty - Best Practices - - - UseEnumCollections - Best Practices - - - UseStandardCharsets - Best Practices - - - UseTryWithResources - Best Practices - - - UseVarargs - Best Practices - - - WhileLoopWithLiteralBoolean - Best Practices - - - AssignmentInOperand - Code Style - - - AtLeastOneConstructor - Code Style - - - AvoidDollarSigns - Code Style - - - AvoidProtectedFieldInFinalClass - Code Style - - - AvoidProtectedMethodInFinalClassNotExtending - Code Style - - - AvoidTabCharacter - Code Style - - - AvoidUsingNativeCode - Code Style - - - BooleanGetMethodName - Code Style - - - CallSuperInConstructor - Code Style - - - ClassNamingConventions - Code Style - - - ClassNamingConventions - Code Style - - - CodeFormat - Code Style - - - CommentDefaultAccessModifier - Code Style - - - ConfusingTernary - Code Style - - - ControlStatementBraces - Code Style - - - DuplicateJspImports - Code Style - - - EmptyControlStatement - Code Style - - - EmptyMethodInAbstractClassShouldBeAbstract - Code Style - - - ExtendsObject - Code Style - - - FieldDeclarationsShouldBeAtStart - Code Style - - - FieldDeclarationsShouldBeAtStartOfClass - Code Style - - - FieldNamingConventions - Code Style - - - FieldNamingConventions - Code Style - - - FinalParameterInAbstractMethod - Code Style - - - ForLoopNaming - Code Style - - - ForLoopShouldBeWhileLoop - Code Style - - - ForLoopsMustUseBraces - Code Style - - - ForLoopsMustUseBraces - Code Style - - - FormalParameterNamingConventions - Code Style - - - FormalParameterNamingConventions - Code Style - - - GenericsNaming - Code Style - - - IdenticalCatchBranches - Code Style - - - IfElseStmtsMustUseBraces - Code Style - - - IfElseStmtsMustUseBraces - Code Style - - - IfStmtsMustUseBraces - Code Style - - - IfStmtsMustUseBraces - Code Style - - - LambdaCanBeMethodReference - Code Style - - - LineLength - Code Style - - - LinguisticNaming - Code Style - - - LocalHomeNamingConvention - Code Style - - - LocalInterfaceSessionNamingConvention - Code Style - - - LocalVariableCouldBeFinal - Code Style - - - LocalVariableNamingConventions - Code Style - - - LocalVariableNamingConventions - Code Style - - - LongVariable - Code Style - - - MDBAndSessionBeanNamingConvention - Code Style - - - MethodArgumentCouldBeFinal - Code Style - - - MethodNamingConventions - Code Style - - - MethodNamingConventions - Code Style - - - MisplacedPragma - Code Style - - - NoElseReturn - Code Style - - - NoPackage - Code Style - - - OneDeclarationPerLine - Code Style - - - OnlyOneReturn - Code Style - - - PackageCase - Code Style - - - PrematureDeclaration - Code Style - - - PropertyNamingConventions - Code Style - - - RemoteInterfaceNamingConvention - Code Style - - - RemoteSessionInterfaceNamingConvention - Code Style - - - ShortClassName - Code Style - - - ShortMethodName - Code Style - - - ShortVariable - Code Style - - - TooManyStaticImports - Code Style - - - UnnecessaryAnnotationValueElement - Code Style - - - UnnecessaryBlock - Code Style - - - UnnecessaryBoxing - Code Style - - - UnnecessaryCast - Code Style - - - UnnecessaryConstructor - Code Style - - - UnnecessaryFullyQualifiedName - Code Style - - - UnnecessaryImport - Code Style - - - UnnecessaryLocalBeforeReturn - Code Style - - - UnnecessaryModifier - Code Style - - - UnnecessaryParentheses - Code Style - - - UnnecessaryReturn - Code Style - - - UnnecessarySemicolon - Code Style - - - UnreachableCode - Code Style - - - UseConcatOnce - Code Style - - - UseDiamondOperator - Code Style - - - UseExplicitTypes - Code Style - - - UselessParentheses - Code Style - - - UselessQualifiedThis - Code Style - - - UseShortArrayInitializer - Code Style - - - UseUnderscoresInNumericLiterals - Code Style - - - WhileLoopsMustUseBraces - Code Style - - - WhileLoopsMustUseBraces - Code Style - - - AbstractClassWithoutAnyMethod - Design - - - AvoidCatchingGenericException - Design - - - AvoidDeeplyNestedIfStmts - Design - - - AvoidDeeplyNestedIfStmts - Design - - - AvoidDeeplyNestedIfStmts - Design - - - AvoidRethrowingException - Design - - - AvoidThrowingNewInstanceOfSameException - Design - - - AvoidThrowingNullPointerException - Design - - - AvoidThrowingRawExceptionTypes - Design - - - AvoidUncheckedExceptionsInSignatures - Design - - - ClassWithOnlyPrivateConstructorsShouldBeFinal - Design - - - CognitiveComplexity - Design - - - CognitiveComplexity - Design - - - CollapsibleIfStatements - Design - - - CollapsibleIfStatements - Design - - - CouplingBetweenObjects - Design - - - CyclomaticComplexity - Design - - - CyclomaticComplexity - Design - - - CyclomaticComplexity - Design - - - DataClass - Design - - - DoNotExtendJavaLangError - Design - - - ExceptionAsFlowControl - Design - - - ExcessiveClassLength - Design - - - ExcessiveImports - Design - - - ExcessiveMethodLength - Design - - - ExcessiveObjectLength - Design - - - ExcessivePackageBodyLength - Design - - - ExcessivePackageSpecificationLength - Design - - - ExcessiveParameterList - Design - - - ExcessiveParameterList - Design - - - ExcessiveParameterList - Design - - - ExcessivePublicCount - Design - - - ExcessivePublicCount - Design - - - ExcessiveTemplateLength - Design - - - ExcessiveTypeLength - Design - - - FinalFieldCouldBeStatic - Design - - - GodClass - Design - - - ImmutableField - Design - - - InvalidJavaBean - Design - - - LawOfDemeter - Design - - - LogicInversion - Design - - - LoosePackageCoupling - Design - - - MutableStaticState - Design - - - NcssConstructorCount - Design - - - NcssCount - Design - - - NcssMethodCount - Design - - - NcssMethodCount - Design - - - NcssObjectCount - Design - - - NcssTypeCount - Design - - - NoInlineJavaScript - Design - - - NoInlineScript - Design - - - NoInlineStyleInformation - Design - - - NoInlineStyles - Design - - - NoLongScripts - Design - - - NoScriptlets - Design - - - NPathComplexity - Design - - - NPathComplexity - Design - - - SignatureDeclareThrowsException - Design - - - SimplifiedTernary - Design - - - SimplifyBooleanExpressions - Design - - - SimplifyBooleanReturns - Design - - - SimplifyConditional - Design - - - SingularField - Design - - - StdCyclomaticComplexity - Design - - - SwitchDensity - Design - - - TooManyFields - Design - - - TooManyFields - Design - - - TooManyFields - Design - - - TooManyMethods - Design - - - TooManyMethods - Design - - - UnusedMethod - Design - - - UselessOverridingMethod - Design - - - UseObjectForClearerAPI - Design - - - UseUtilityClass - Design - - - ApexDoc - Documentation - - - CommentContent - Documentation - - - CommentRequired - Documentation - - - CommentSize - Documentation - - - UncommentedEmptyConstructor - Documentation - - - UncommentedEmptyMethodBody - Documentation - - - ApexCSRF - Error Prone - - - AssignmentInOperand - Error Prone - - - AssignmentToNonFinalStatic - Error Prone - - - AvoidAccessibilityAlteration - Error Prone - - - AvoidAssertAsIdentifier - Error Prone - - - AvoidBranchingStatementAsLastInLoop - Error Prone - - - AvoidCallingFinalize - Error Prone - - - AvoidCatchingNPE - Error Prone - - - AvoidCatchingThrowable - Error Prone - - - AvoidDecimalLiteralsInBigDecimalConstructor - Error Prone - - - AvoidDirectAccessTriggerMap - Error Prone - - - AvoidDuplicateLiterals - Error Prone - - - AvoidEnumAsIdentifier - Error Prone - - - AvoidFieldNameMatchingMethodName - Error Prone - - - AvoidFieldNameMatchingTypeName - Error Prone - - - AvoidHardcodingId - Error Prone - - - AvoidInstanceofChecksInCatchClause - Error Prone - - - AvoidLiteralsInIfCondition - Error Prone - - - AvoidLosingExceptionInformation - Error Prone - - - AvoidMultipleUnaryOperators - Error Prone - - - AvoidNonExistentAnnotations - Error Prone - - - AvoidTrailingComma - Error Prone - - - AvoidUsingOctalValues - Error Prone - - - BrokenNullCheck - Error Prone - - - CallSuperFirst - Error Prone - - - CallSuperLast - Error Prone - - - CheckSkipResult - Error Prone - - - ClassCastExceptionWithToArray - Error Prone - - - CloneMethodMustBePublic - Error Prone - - - CloneMethodMustImplementCloneable - Error Prone - - - CloneMethodReturnTypeMustMatchClassName - Error Prone - - - CloseResource - Error Prone - - - CompareObjectsWithEquals - Error Prone - - - ComparisonWithNaN - Error Prone - - - ConfusingArgumentToVarargsMethod - Error Prone - - - ConstructorCallsOverridableMethod - Error Prone - - - DetachedTestCase - Error Prone - - - DoNotCallGarbageCollectionExplicitly - Error Prone - - - DoNotExtendJavaLangThrowable - Error Prone - - - DoNotHardCodeSDCard - Error Prone - - - DoNotTerminateVM - Error Prone - - - DoNotThrowExceptionInFinally - Error Prone - - - DontImportSun - Error Prone - - - DontUseFloatTypeForLoopIndices - Error Prone - - - EmptyCatchBlock - Error Prone - - - EmptyCatchBlock - Error Prone - - - EmptyFinalizer - Error Prone - - - EmptyForeachStmt - Error Prone - - - EmptyIfStmt - Error Prone - - - EmptyIfStmt - Error Prone - - - EmptyStatementBlock - Error Prone - - - EmptyTryOrFinallyBlock - Error Prone - - - EmptyWhileStmt - Error Prone - - - EqualComparison - Error Prone - - - EqualsNull - Error Prone - - - FinalizeDoesNotCallSuperFinalize - Error Prone - - - FinalizeOnlyCallsSuperFinalize - Error Prone - - - FinalizeOverloaded - Error Prone - - - FinalizeShouldBeProtected - Error Prone - - - ForceCast - Error Prone - - - ForceTry - Error Prone - - - IdempotentOperations - Error Prone - - - ImplicitSwitchFallThrough - Error Prone - - - InaccessibleAuraEnabledGetter - Error Prone - - - InaccurateNumericLiteral - Error Prone - - - InstantiationToGetClass - Error Prone - - - InvalidDependencyTypes - Error Prone - - - InvalidLogMessageFormat - Error Prone - - - JspEncoding - Error Prone - - - JumbledIncrementer - Error Prone - - - JUnitSpelling - Error Prone - - - JUnitStaticSuite - Error Prone - - - MethodWithSameNameAsEnclosingClass - Error Prone - - - MethodWithSameNameAsEnclosingClass - Error Prone - - - MisplacedNullCheck - Error Prone - - - MissingSerialVersionUID - Error Prone - - - MissingStaticMethodInNonInstantiatableClass - Error Prone - - - MistypedCDATASection - Error Prone - - - MoreThanOneLogger - Error Prone - - - NonCaseLabelInSwitch - Error Prone - - - NonSerializableClass - Error Prone - - - NonStaticInitializer - Error Prone - - - NullAssignment - Error Prone - - - OverrideBothEqualsAndHashcode - Error Prone - - - OverrideBothEqualsAndHashcode - Error Prone - - - OverrideBothEqualsAndHashcode - Error Prone - - - ProjectVersionAsDependencyVersion - Error Prone - - - ProperCloneImplementation - Error Prone - - - ProperLogger - Error Prone - - - ReturnEmptyCollectionRatherThanNull - Error Prone - - - ReturnFromFinallyBlock - Error Prone - - - SimpleDateFormatNeedsLocale - Error Prone - - - SingleMethodSingleton - Error Prone - - - SingletonClassReturningNewInstance - Error Prone - - - StaticEJBFieldShouldBeFinal - Error Prone - - - StringBufferInstantiationWithChar - Error Prone - - - SuspiciousEqualsMethodName - Error Prone - - - SuspiciousHashcodeMethodName - Error Prone - - - SuspiciousOctalEscape - Error Prone - - - TestClassWithoutTestCases - Error Prone - - - TestMethodsMustBeInTestClasses - Error Prone - - - TO_DATEWithoutDateFormat - Error Prone - - - TO_DATE_TO_CHAR - Error Prone - - - TO_TIMESTAMPWithoutDateFormat - Error Prone - - - UnconditionalIfStatement - Error Prone - - - UnnecessaryBooleanAssertion - Error Prone - - - UnnecessaryCaseChange - Error Prone - - - UnnecessaryConversionTemporary - Error Prone - - - UnusedNullCheckInEquals - Error Prone - - - UseCorrectExceptionLogging - Error Prone - - - UseEqualsToCompareStrings - Error Prone - - - UselessOperationOnImmutable - Error Prone - - - UseLocaleWithCaseConversions - Error Prone - - - UseProperClassLoader - Error Prone - - - AvoidSynchronizedAtMethodLevel - Multithreading - - - AvoidSynchronizedStatement - Multithreading - - - AvoidThreadGroup - Multithreading - - - AvoidUsingVolatile - Multithreading - - - DoNotUseThreads - Multithreading - - - DontCallThreadRun - Multithreading - - - DoubleCheckedLocking - Multithreading - - - NonThreadSafeSingleton - Multithreading - - - UnsynchronizedStaticFormatter - Multithreading - - - UseConcurrentHashMap - Multithreading - - - UseNotifyAllInsteadOfNotify - Multithreading - - - AddEmptyString - Performance - - - AppendCharacterWithChar - Performance - - - AvoidArrayLoops - Performance - - - AvoidAxisNavigation - Performance - - - AvoidCalendarDateCreation - Performance - - - AvoidConsoleStatements - Performance - - - AvoidDebugStatements - Performance - - - AvoidFileStream - Performance - - - AvoidInstantiatingObjectsInLoops - Performance - - - AvoidNonRestrictiveQueries - Performance - - - BigIntegerInstantiation - Performance - - - ConsecutiveAppendsShouldReuse - Performance - - - ConsecutiveLiteralAppends - Performance - - - EagerlyLoadedDescribeSObjectResult - Performance - - - InefficientEmptyStringCheck - Performance - - - InefficientStringBuffering - Performance - - - InsufficientStringBufferDeclaration - Performance - - - OperationWithHighCostInLoop - Performance - - - OperationWithLimitsInLoop - Performance - - - OptimizableToArrayCall - Performance - - - RedundantFieldInitializer - Performance - - - StringInstantiation - Performance - - - StringToString - Performance - - - TooFewBranchesForSwitch - Performance - - - UseArrayListInsteadOfVector - Performance - - - UseArraysAsList - Performance - - - UseIndexOfChar - Performance - - - UseIOStreamsWithApacheCommonsFileItem - Performance - - - UselessStringValueOf - Performance - - - UseStringBufferForStringAppends - Performance - - - UseStringBufferLength - Performance - - - ApexBadCrypto - Security - - - ApexCRUDViolation - Security - - - ApexDangerousMethods - Security - - - ApexInsecureEndpoint - Security - - - ApexOpenRedirect - Security - - - ApexSharingViolations - Security - - - ApexSOQLInjection - Security - - - ApexSuggestUsingNamedCred - Security - - - ApexXSSFromEscapeFalse - Security - - - ApexXSSFromURLParam - Security - - - HardCodedCryptoKey - Security - - - IframeMissingSrcAttribute - Security - - - InsecureCryptoIv - Security - - - NoUnsanitizedJSPExpression - Security - - - VfCsrf - Security - - - VfHtmlStyleTagXss - Security - - - VfUnescapeEl - Security - - - false - true - true - diff --git a/tests/.pmd b/tests/.pmd deleted file mode 100644 index 09e37c6e..00000000 --- a/tests/.pmd +++ /dev/null @@ -1,1699 +0,0 @@ - - - false - - - - - AbstractClassWithoutAbstractMethod - Best Practices - - - AccessorClassGeneration - Best Practices - - - AccessorMethodGeneration - Best Practices - - - AmbiguousResolution - Best Practices - - - ApexAssertionsShouldIncludeMessage - Best Practices - - - ApexUnitTestClassShouldHaveAsserts - Best Practices - - - ApexUnitTestClassShouldHaveRunAs - Best Practices - - - ApexUnitTestMethodShouldHaveIsTestAnnotation - Best Practices - - - ApexUnitTestShouldNotUseSeeAllDataTrue - Best Practices - - - ArrayIsStoredDirectly - Best Practices - - - AvoidGlobalModifier - Best Practices - - - AvoidInlineStyles - Best Practices - - - AvoidLogicInTrigger - Best Practices - - - AvoidMessageDigestField - Best Practices - - - AvoidPrintStackTrace - Best Practices - - - AvoidReassigningCatchVariables - Best Practices - - - AvoidReassigningLoopVariables - Best Practices - - - AvoidReassigningParameters - Best Practices - - - AvoidReassigningParameters - Best Practices - - - AvoidStringBufferField - Best Practices - - - AvoidUsingHardCodedIP - Best Practices - - - AvoidWithStatement - Best Practices - - - CheckResultSet - Best Practices - - - ClassStartNameEqualsEndName - Best Practices - - - ConnectUsingNonConnector - Best Practices - - - ConsistentReturn - Best Practices - - - ConstantsInInterface - Best Practices - - - DebugsShouldUseLoggingLevel - Best Practices - - - DefaultLabelNotLastInSwitch - Best Practices - - - DontNestJsfInJstlIteration - Best Practices - - - DoubleBraceInitialization - Best Practices - - - ForLoopCanBeForeach - Best Practices - - - ForLoopVariableCount - Best Practices - - - FunctionNameTooShort - Best Practices - - - GlobalVariable - Best Practices - - - GuardLogStatement - Best Practices - - - JUnit4SuitesShouldUseSuiteAnnotation - Best Practices - - - JUnit5TestShouldBePackagePrivate - Best Practices - - - JUnitUseExpected - Best Practices - - - LiteralsFirstInComparisons - Best Practices - - - LooseCoupling - Best Practices - - - MethodReturnsInternalArray - Best Practices - - - MissingEncoding - Best Practices - - - MissingOverride - Best Practices - - - NoClassAttribute - Best Practices - - - NoHtmlComments - Best Practices - - - NoJspForward - Best Practices - - - NonExhaustiveSwitch - Best Practices - - - OneDeclarationPerLine - Best Practices - - - PreserveStackTrace - Best Practices - - - PrimitiveWrapperInstantiation - Best Practices - - - ProhibitedInterfaceBuilder - Best Practices - - - QueueableWithoutFinalizer - Best Practices - - - ReplaceEnumerationWithIterator - Best Practices - - - ReplaceHashtableWithMap - Best Practices - - - ReplaceVectorWithList - Best Practices - - - ScopeForInVariable - Best Practices - - - SimplifiableTestAssertion - Best Practices - - - SystemPrintln - Best Practices - - - TomKytesDespair - Best Practices - - - UnavailableFunction - Best Practices - - - UnitTestAssertionsShouldIncludeMessage - Best Practices - - - UnitTestContainsTooManyAsserts - Best Practices - - - UnitTestShouldIncludeAssert - Best Practices - - - UnitTestShouldUseAfterAnnotation - Best Practices - - - UnitTestShouldUseBeforeAnnotation - Best Practices - - - UnitTestShouldUseTestAnnotation - Best Practices - - - UnnecessaryTypeAttribute - Best Practices - - - UnnecessaryVarargsArrayCreation - Best Practices - - - UnusedAssignment - Best Practices - - - UnusedFormalParameter - Best Practices - - - UnusedLocalVariable - Best Practices - - - UnusedLocalVariable - Best Practices - - - UnusedMacroParameter - Best Practices - - - UnusedPrivateField - Best Practices - - - UnusedPrivateMethod - Best Practices - - - UseAltAttributeForImages - Best Practices - - - UseBaseWithParseInt - Best Practices - - - UseCollectionIsEmpty - Best Practices - - - UseEnumCollections - Best Practices - - - UseStandardCharsets - Best Practices - - - UseTryWithResources - Best Practices - - - UseVarargs - Best Practices - - - WhileLoopWithLiteralBoolean - Best Practices - - - AssignmentInOperand - Code Style - - - AtLeastOneConstructor - Code Style - - - AvoidDollarSigns - Code Style - - - AvoidProtectedFieldInFinalClass - Code Style - - - AvoidProtectedMethodInFinalClassNotExtending - Code Style - - - AvoidTabCharacter - Code Style - - - AvoidUsingNativeCode - Code Style - - - BooleanGetMethodName - Code Style - - - CallSuperInConstructor - Code Style - - - ClassNamingConventions - Code Style - - - ClassNamingConventions - Code Style - - - CodeFormat - Code Style - - - CommentDefaultAccessModifier - Code Style - - - ConfusingTernary - Code Style - - - ControlStatementBraces - Code Style - - - DuplicateJspImports - Code Style - - - EmptyControlStatement - Code Style - - - EmptyMethodInAbstractClassShouldBeAbstract - Code Style - - - ExtendsObject - Code Style - - - FieldDeclarationsShouldBeAtStart - Code Style - - - FieldDeclarationsShouldBeAtStartOfClass - Code Style - - - FieldNamingConventions - Code Style - - - FieldNamingConventions - Code Style - - - FinalParameterInAbstractMethod - Code Style - - - ForLoopNaming - Code Style - - - ForLoopShouldBeWhileLoop - Code Style - - - ForLoopsMustUseBraces - Code Style - - - ForLoopsMustUseBraces - Code Style - - - FormalParameterNamingConventions - Code Style - - - FormalParameterNamingConventions - Code Style - - - GenericsNaming - Code Style - - - IdenticalCatchBranches - Code Style - - - IfElseStmtsMustUseBraces - Code Style - - - IfElseStmtsMustUseBraces - Code Style - - - IfStmtsMustUseBraces - Code Style - - - IfStmtsMustUseBraces - Code Style - - - LambdaCanBeMethodReference - Code Style - - - LineLength - Code Style - - - LinguisticNaming - Code Style - - - LocalHomeNamingConvention - Code Style - - - LocalInterfaceSessionNamingConvention - Code Style - - - LocalVariableCouldBeFinal - Code Style - - - LocalVariableNamingConventions - Code Style - - - LocalVariableNamingConventions - Code Style - - - LongVariable - Code Style - - - MDBAndSessionBeanNamingConvention - Code Style - - - MethodArgumentCouldBeFinal - Code Style - - - MethodNamingConventions - Code Style - - - MethodNamingConventions - Code Style - - - MisplacedPragma - Code Style - - - NoElseReturn - Code Style - - - NoPackage - Code Style - - - OneDeclarationPerLine - Code Style - - - OnlyOneReturn - Code Style - - - PackageCase - Code Style - - - PrematureDeclaration - Code Style - - - PropertyNamingConventions - Code Style - - - RemoteInterfaceNamingConvention - Code Style - - - RemoteSessionInterfaceNamingConvention - Code Style - - - ShortClassName - Code Style - - - ShortMethodName - Code Style - - - ShortVariable - Code Style - - - TooManyStaticImports - Code Style - - - UnnecessaryAnnotationValueElement - Code Style - - - UnnecessaryBlock - Code Style - - - UnnecessaryBoxing - Code Style - - - UnnecessaryCast - Code Style - - - UnnecessaryConstructor - Code Style - - - UnnecessaryFullyQualifiedName - Code Style - - - UnnecessaryImport - Code Style - - - UnnecessaryLocalBeforeReturn - Code Style - - - UnnecessaryModifier - Code Style - - - UnnecessaryParentheses - Code Style - - - UnnecessaryReturn - Code Style - - - UnnecessarySemicolon - Code Style - - - UnreachableCode - Code Style - - - UseConcatOnce - Code Style - - - UseDiamondOperator - Code Style - - - UseExplicitTypes - Code Style - - - UselessParentheses - Code Style - - - UselessQualifiedThis - Code Style - - - UseShortArrayInitializer - Code Style - - - UseUnderscoresInNumericLiterals - Code Style - - - WhileLoopsMustUseBraces - Code Style - - - WhileLoopsMustUseBraces - Code Style - - - AbstractClassWithoutAnyMethod - Design - - - AvoidCatchingGenericException - Design - - - AvoidDeeplyNestedIfStmts - Design - - - AvoidDeeplyNestedIfStmts - Design - - - AvoidDeeplyNestedIfStmts - Design - - - AvoidRethrowingException - Design - - - AvoidThrowingNewInstanceOfSameException - Design - - - AvoidThrowingNullPointerException - Design - - - AvoidThrowingRawExceptionTypes - Design - - - AvoidUncheckedExceptionsInSignatures - Design - - - ClassWithOnlyPrivateConstructorsShouldBeFinal - Design - - - CognitiveComplexity - Design - - - CognitiveComplexity - Design - - - CollapsibleIfStatements - Design - - - CollapsibleIfStatements - Design - - - CouplingBetweenObjects - Design - - - CyclomaticComplexity - Design - - - CyclomaticComplexity - Design - - - CyclomaticComplexity - Design - - - DataClass - Design - - - DoNotExtendJavaLangError - Design - - - ExceptionAsFlowControl - Design - - - ExcessiveClassLength - Design - - - ExcessiveImports - Design - - - ExcessiveMethodLength - Design - - - ExcessiveObjectLength - Design - - - ExcessivePackageBodyLength - Design - - - ExcessivePackageSpecificationLength - Design - - - ExcessiveParameterList - Design - - - ExcessiveParameterList - Design - - - ExcessiveParameterList - Design - - - ExcessivePublicCount - Design - - - ExcessivePublicCount - Design - - - ExcessiveTemplateLength - Design - - - ExcessiveTypeLength - Design - - - FinalFieldCouldBeStatic - Design - - - GodClass - Design - - - ImmutableField - Design - - - InvalidJavaBean - Design - - - LawOfDemeter - Design - - - LogicInversion - Design - - - LoosePackageCoupling - Design - - - MutableStaticState - Design - - - NcssConstructorCount - Design - - - NcssCount - Design - - - NcssMethodCount - Design - - - NcssMethodCount - Design - - - NcssObjectCount - Design - - - NcssTypeCount - Design - - - NoInlineJavaScript - Design - - - NoInlineScript - Design - - - NoInlineStyleInformation - Design - - - NoInlineStyles - Design - - - NoLongScripts - Design - - - NoScriptlets - Design - - - NPathComplexity - Design - - - NPathComplexity - Design - - - SignatureDeclareThrowsException - Design - - - SimplifiedTernary - Design - - - SimplifyBooleanExpressions - Design - - - SimplifyBooleanReturns - Design - - - SimplifyConditional - Design - - - SingularField - Design - - - StdCyclomaticComplexity - Design - - - SwitchDensity - Design - - - TooManyFields - Design - - - TooManyFields - Design - - - TooManyFields - Design - - - TooManyMethods - Design - - - TooManyMethods - Design - - - UnusedMethod - Design - - - UselessOverridingMethod - Design - - - UseObjectForClearerAPI - Design - - - UseUtilityClass - Design - - - ApexDoc - Documentation - - - CommentContent - Documentation - - - CommentRequired - Documentation - - - CommentSize - Documentation - - - UncommentedEmptyConstructor - Documentation - - - UncommentedEmptyMethodBody - Documentation - - - ApexCSRF - Error Prone - - - AssignmentInOperand - Error Prone - - - AssignmentToNonFinalStatic - Error Prone - - - AvoidAccessibilityAlteration - Error Prone - - - AvoidAssertAsIdentifier - Error Prone - - - AvoidBranchingStatementAsLastInLoop - Error Prone - - - AvoidCallingFinalize - Error Prone - - - AvoidCatchingNPE - Error Prone - - - AvoidCatchingThrowable - Error Prone - - - AvoidDecimalLiteralsInBigDecimalConstructor - Error Prone - - - AvoidDirectAccessTriggerMap - Error Prone - - - AvoidDuplicateLiterals - Error Prone - - - AvoidEnumAsIdentifier - Error Prone - - - AvoidFieldNameMatchingMethodName - Error Prone - - - AvoidFieldNameMatchingTypeName - Error Prone - - - AvoidHardcodingId - Error Prone - - - AvoidInstanceofChecksInCatchClause - Error Prone - - - AvoidLiteralsInIfCondition - Error Prone - - - AvoidLosingExceptionInformation - Error Prone - - - AvoidMultipleUnaryOperators - Error Prone - - - AvoidNonExistentAnnotations - Error Prone - - - AvoidTrailingComma - Error Prone - - - AvoidUsingOctalValues - Error Prone - - - BrokenNullCheck - Error Prone - - - CallSuperFirst - Error Prone - - - CallSuperLast - Error Prone - - - CheckSkipResult - Error Prone - - - ClassCastExceptionWithToArray - Error Prone - - - CloneMethodMustBePublic - Error Prone - - - CloneMethodMustImplementCloneable - Error Prone - - - CloneMethodReturnTypeMustMatchClassName - Error Prone - - - CloseResource - Error Prone - - - CompareObjectsWithEquals - Error Prone - - - ComparisonWithNaN - Error Prone - - - ConfusingArgumentToVarargsMethod - Error Prone - - - ConstructorCallsOverridableMethod - Error Prone - - - DetachedTestCase - Error Prone - - - DoNotCallGarbageCollectionExplicitly - Error Prone - - - DoNotExtendJavaLangThrowable - Error Prone - - - DoNotHardCodeSDCard - Error Prone - - - DoNotTerminateVM - Error Prone - - - DoNotThrowExceptionInFinally - Error Prone - - - DontImportSun - Error Prone - - - DontUseFloatTypeForLoopIndices - Error Prone - - - EmptyCatchBlock - Error Prone - - - EmptyCatchBlock - Error Prone - - - EmptyFinalizer - Error Prone - - - EmptyForeachStmt - Error Prone - - - EmptyIfStmt - Error Prone - - - EmptyIfStmt - Error Prone - - - EmptyStatementBlock - Error Prone - - - EmptyTryOrFinallyBlock - Error Prone - - - EmptyWhileStmt - Error Prone - - - EqualComparison - Error Prone - - - EqualsNull - Error Prone - - - FinalizeDoesNotCallSuperFinalize - Error Prone - - - FinalizeOnlyCallsSuperFinalize - Error Prone - - - FinalizeOverloaded - Error Prone - - - FinalizeShouldBeProtected - Error Prone - - - ForceCast - Error Prone - - - ForceTry - Error Prone - - - IdempotentOperations - Error Prone - - - ImplicitSwitchFallThrough - Error Prone - - - InaccessibleAuraEnabledGetter - Error Prone - - - InaccurateNumericLiteral - Error Prone - - - InstantiationToGetClass - Error Prone - - - InvalidDependencyTypes - Error Prone - - - InvalidLogMessageFormat - Error Prone - - - JspEncoding - Error Prone - - - JumbledIncrementer - Error Prone - - - JUnitSpelling - Error Prone - - - JUnitStaticSuite - Error Prone - - - MethodWithSameNameAsEnclosingClass - Error Prone - - - MethodWithSameNameAsEnclosingClass - Error Prone - - - MisplacedNullCheck - Error Prone - - - MissingSerialVersionUID - Error Prone - - - MissingStaticMethodInNonInstantiatableClass - Error Prone - - - MistypedCDATASection - Error Prone - - - MoreThanOneLogger - Error Prone - - - NonCaseLabelInSwitch - Error Prone - - - NonSerializableClass - Error Prone - - - NonStaticInitializer - Error Prone - - - NullAssignment - Error Prone - - - OverrideBothEqualsAndHashcode - Error Prone - - - OverrideBothEqualsAndHashcode - Error Prone - - - OverrideBothEqualsAndHashcode - Error Prone - - - ProjectVersionAsDependencyVersion - Error Prone - - - ProperCloneImplementation - Error Prone - - - ProperLogger - Error Prone - - - ReturnEmptyCollectionRatherThanNull - Error Prone - - - ReturnFromFinallyBlock - Error Prone - - - SimpleDateFormatNeedsLocale - Error Prone - - - SingleMethodSingleton - Error Prone - - - SingletonClassReturningNewInstance - Error Prone - - - StaticEJBFieldShouldBeFinal - Error Prone - - - StringBufferInstantiationWithChar - Error Prone - - - SuspiciousEqualsMethodName - Error Prone - - - SuspiciousHashcodeMethodName - Error Prone - - - SuspiciousOctalEscape - Error Prone - - - TestClassWithoutTestCases - Error Prone - - - TestMethodsMustBeInTestClasses - Error Prone - - - TO_DATEWithoutDateFormat - Error Prone - - - TO_DATE_TO_CHAR - Error Prone - - - TO_TIMESTAMPWithoutDateFormat - Error Prone - - - UnconditionalIfStatement - Error Prone - - - UnnecessaryBooleanAssertion - Error Prone - - - UnnecessaryCaseChange - Error Prone - - - UnnecessaryConversionTemporary - Error Prone - - - UnusedNullCheckInEquals - Error Prone - - - UseCorrectExceptionLogging - Error Prone - - - UseEqualsToCompareStrings - Error Prone - - - UselessOperationOnImmutable - Error Prone - - - UseLocaleWithCaseConversions - Error Prone - - - UseProperClassLoader - Error Prone - - - AvoidSynchronizedAtMethodLevel - Multithreading - - - AvoidSynchronizedStatement - Multithreading - - - AvoidThreadGroup - Multithreading - - - AvoidUsingVolatile - Multithreading - - - DoNotUseThreads - Multithreading - - - DontCallThreadRun - Multithreading - - - DoubleCheckedLocking - Multithreading - - - NonThreadSafeSingleton - Multithreading - - - UnsynchronizedStaticFormatter - Multithreading - - - UseConcurrentHashMap - Multithreading - - - UseNotifyAllInsteadOfNotify - Multithreading - - - AddEmptyString - Performance - - - AppendCharacterWithChar - Performance - - - AvoidArrayLoops - Performance - - - AvoidAxisNavigation - Performance - - - AvoidCalendarDateCreation - Performance - - - AvoidConsoleStatements - Performance - - - AvoidDebugStatements - Performance - - - AvoidFileStream - Performance - - - AvoidInstantiatingObjectsInLoops - Performance - - - AvoidNonRestrictiveQueries - Performance - - - BigIntegerInstantiation - Performance - - - ConsecutiveAppendsShouldReuse - Performance - - - ConsecutiveLiteralAppends - Performance - - - EagerlyLoadedDescribeSObjectResult - Performance - - - InefficientEmptyStringCheck - Performance - - - InefficientStringBuffering - Performance - - - InsufficientStringBufferDeclaration - Performance - - - OperationWithHighCostInLoop - Performance - - - OperationWithLimitsInLoop - Performance - - - OptimizableToArrayCall - Performance - - - RedundantFieldInitializer - Performance - - - StringInstantiation - Performance - - - StringToString - Performance - - - TooFewBranchesForSwitch - Performance - - - UseArrayListInsteadOfVector - Performance - - - UseArraysAsList - Performance - - - UseIndexOfChar - Performance - - - UseIOStreamsWithApacheCommonsFileItem - Performance - - - UselessStringValueOf - Performance - - - UseStringBufferForStringAppends - Performance - - - UseStringBufferLength - Performance - - - ApexBadCrypto - Security - - - ApexCRUDViolation - Security - - - ApexDangerousMethods - Security - - - ApexInsecureEndpoint - Security - - - ApexOpenRedirect - Security - - - ApexSharingViolations - Security - - - ApexSOQLInjection - Security - - - ApexSuggestUsingNamedCred - Security - - - ApexXSSFromEscapeFalse - Security - - - ApexXSSFromURLParam - Security - - - HardCodedCryptoKey - Security - - - IframeMissingSrcAttribute - Security - - - InsecureCryptoIv - Security - - - NoUnsanitizedJSPExpression - Security - - - VfCsrf - Security - - - VfHtmlStyleTagXss - Security - - - VfUnescapeEl - Security - - - false - true - true - From 91c3093a6e5bd85659932c1c72aa1d8207283f37 Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Fri, 28 Feb 2025 10:57:49 +0100 Subject: [PATCH 10/11] fix: revert unneeded change in .project file --- plugin/.project | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/.project b/plugin/.project index 287e3027..8ccae640 100644 --- a/plugin/.project +++ b/plugin/.project @@ -21,12 +21,12 @@ - net.sourceforge.pmd.eclipse.plugin.pmdBuilder + org.eclipse.m2e.core.maven2Builder - org.eclipse.m2e.core.maven2Builder + net.sourceforge.pmd.eclipse.plugin.pmdBuilder From e7ca24c49b2cfb490e97d368d770f574ecd18f20 Mon Sep 17 00:00:00 2001 From: Knut Funkel Date: Fri, 28 Feb 2025 11:04:14 +0100 Subject: [PATCH 11/11] fix: added a NOPMD exception --- .../io/snyk/languageserver/protocolextension/SnykUriUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykUriUtils.java b/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykUriUtils.java index daf10b85..71bf3766 100644 --- a/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykUriUtils.java +++ b/plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykUriUtils.java @@ -38,7 +38,7 @@ static Map getQueryParameters(String queryString) { if (!param.isEmpty()) { String[] keyValue = param.split("="); - if (keyValue.length == 2) { // TODO add the no pmd here + if (keyValue.length == 2) { // NOPMD, AvoidLiteralsInIfCondition try { paramMap.put(keyValue[0], URLDecoder.decode(keyValue[1], "UTF-8"));