From e145f25ba4f3125a4ac0fe6a000d52be8629132a Mon Sep 17 00:00:00 2001 From: Ludy Date: Wed, 19 Feb 2025 22:41:02 +0100 Subject: [PATCH] Enhance Java Development Configuration and Code Formatting (#2991) # Description of Changes Please provide a summary of the changes, including: This PR improves Java development settings and code formatting by: - Removing the deprecated `Checkstyle` extension from `.vscode/extensions.json`. - Updating `.vscode/settings.json` with: - Structured formatting for better readability. - Improved Java formatting with `google-java-format`. - Enhanced auto-save behavior. - Additional Java cleanup actions for better code quality. - Optimized project resource filtering. - More precise import sorting and ordering. - Refining `build.gradle` to: - Extend the `importOrder` rule to include `jakarta`, `lombok`, `me`, and `stirling`. - Improve `spotless` formatting configurations. These changes streamline the development workflow, enhance code consistency, and improve maintainability. --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details. --- .vscode/extensions.json | 1 - .vscode/settings.json | 116 +++++++++++++++++++++++++++++++++++----- build.gradle | 10 ++-- 3 files changed, 108 insertions(+), 19 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 7dc2bc1f..cc11d6a1 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -9,7 +9,6 @@ // "ms-vscode-remote.vscode-remote-extensionpack", // Remote Development Pack for SSH, WSL, and Containers "Oracle.oracle-java", // Oracle Java extension with additional features for Java development "redhat.java", // Java support by Red Hat with IntelliSense, debugging, and code navigation - "shengchen.vscode-checkstyle", // Checkstyle integration for Java code quality checks "streetsidesoftware.code-spell-checker", // Spell checker for code to avoid typos "vmware.vscode-boot-dev-pack", // Developer tools for Spring Boot by VMware "vmware.vscode-spring-boot", // Spring Boot tools by VMware for enhanced Spring development diff --git a/.vscode/settings.json b/.vscode/settings.json index b7ac1b3c..34f41eb4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,57 +2,147 @@ "java.compile.nullAnalysis.mode": "automatic", "files.eol": "auto", "java.configuration.updateBuildConfiguration": "interactive", - "black-formatter.args": ["--line-length", "127"], - "flake8.args": ["--max-line-length", "127"], - "pylint.args": ["max-line-length", "127"], + "black-formatter.args": [ + "--line-length", + "127" + ], + "flake8.args": [ + "--max-line-length", + "127" + ], "[java]": { "editor.tabSize": 4, "editor.detectIndentation": false, - "editor.rulers": [127] + "editor.rulers": [ + 127 + ], + "editor.defaultFormatter": "josevseb.google-java-format-for-vs-code" }, "[python]": { "editor.tabSize": 2, "editor.detectIndentation": false, - "editor.rulers": [127] + "editor.rulers": [ + 127 + ] }, "[gradle-build]": { "editor.tabSize": 4, "editor.detectIndentation": false, - "editor.rulers": [127] + "editor.rulers": [ + 127 + ] }, "[gradle]": { "editor.tabSize": 4, "editor.detectIndentation": false, - "editor.rulers": [127] + "editor.rulers": [ + 127 + ] }, "[html]": { "editor.tabSize": 2, - "editor.rulers": [127], + "editor.rulers": [ + 127 + ], "files.trimFinalNewlines": false, "files.insertFinalNewline": false }, "[javascript]": { "editor.tabSize": 2, - "editor.rulers": [127] + "editor.rulers": [ + 127 + ] }, "[yaml]": { "files.trimFinalNewlines": false, "files.insertFinalNewline": false }, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "files.trimTrailingWhitespace": true, + "files.autoSave": "onFocusChange", + "files.autoSaveWhenNoErrors": true, "diffEditor.maxComputationTime": 0, "editor.wordSegmenterLocales": "", "editor.guides.bracketPairs": "active", "editor.guides.bracketPairsHorizontal": "active", - "files.insertFinalNewline": true, - "files.trimFinalNewlines": true, - "files.trimTrailingWhitespace": true, "editor.indentSize": "tabSize", "editor.stickyScroll.enabled": false, "editor.minimap.enabled": false, "editor.formatOnSave": true, + "editor.insertSpaces": true, "java.format.enabled": true, "java.format.settings.profile": "GoogleStyle", "java.format.settings.google.version": "1.25.2", "java.format.settings.google.mode": "jar-file", - "java.format.settings.google.extra": "--aosp --skip-sorting-imports" + "java.format.settings.google.extra": "--aosp --skip-sorting-imports --skip-javadoc-formatting", + // (DE) Aktiviert Kommentare im Java-Format. + // (EN) Enables comments in Java formatting. + // "java.format.comments.enabled": true, + // (DE) Generiert automatisch Kommentare im Code. + // (EN) Automatically generates comments in code. + // "java.codeGeneration.generateComments": true, + // https://github.com/redhat-developer/vscode-java/blob/master/document/_java.learnMoreAboutCleanUps.md#java-clean-ups + "java.saveActions.cleanup": true, + "java.cleanup.actions": [ + "invertEquals", // Inverts calls to Object.equals(Object) and String.equalsIgnoreCase(String) to avoid useless null pointer exception. + "instanceofPatternMatch" // Replaces instanceof checks with pattern matching. + ], + // (DE) Aktiviert die Code-Vervollständigung für Java. + // (EN) Enables code completion for Java. + "java.completion.engine": "dom", + "java.completion.enabled": true, + "java.completion.importOrder": [ + "java", + "javax", + "org", + "com", + "net", + "io", + "jakarta", + "lombok", + "me", + "stirling", + ], + "java.project.resourceFilters": [ + ".devcontainer/", + ".git/", + ".github/", + ".gradle/", + ".venv/", + ".venv*/", + ".vscode/", + "bin/", + "build/", + "configs/", + "customFiles/", + "docs/", + "exampleYmlFiles", + "gradle/", + "images/", + "logs/", + "pipeline/", + "scripts/", + "testings/", + ".git-blame-ignore-revs", + ".gitattributes", + ".gitignore", + ".pre-commit-config.yaml", + ], + // Enables signature help in Java. + "java.signatureHelp.enabled": true, + // Enables detailed signature help descriptions. + "java.signatureHelp.description.enabled": true, + // Downloads sources for Maven dependencies. + "java.maven.downloadSources": true, + // Enables Gradle project import. + "java.import.gradle.enabled": true, + // Downloads sources for Eclipse projects. + "java.eclipse.downloadSources": true, + // Enables import of the Gradle wrapper. + "java.import.gradle.wrapper.enabled": true, + "spring.initializr.defaultLanguage": "Java", + "spring.initializr.defaultGroupId": "stirling.software.SPDF", + "spring.initializr.defaultArtifactId": "SPDF", + "cSpell.enabled": false, } diff --git a/build.gradle b/build.gradle index 182e91f4..7c13593a 100644 --- a/build.gradle +++ b/build.gradle @@ -260,7 +260,7 @@ spotless { googleJavaFormat("1.25.2").aosp().reorderImports(false) - importOrder("java", "javax", "org", "com", "net", "io") + importOrder("java", "javax", "org", "com", "net", "io", "jakarta", "lombok", "me", "stirling") toggleOffOn() trimTrailingWhitespace() leadingTabsToSpaces() @@ -272,7 +272,7 @@ sonar { properties { property "sonar.projectKey", "Stirling-Tools_Stirling-PDF" property "sonar.organization", "stirling-tools" - + property "sonar.exclusions", "**/build-wrapper-dump.json, src/main/java/org/apache/**, src/main/resources/static/pdfjs/**, src/main/resources/static/pdfjs-legacy/**, src/main/resources/static/js/thirdParty/**" property "sonar.coverage.exclusions", "src/main/java/org/apache/**, src/main/resources/static/pdfjs/**, src/main/resources/static/pdfjs-legacy/**, src/main/resources/static/js/thirdParty/**" property "sonar.cpd.exclusions", "src/main/java/org/apache/**, src/main/resources/static/pdfjs/**, src/main/resources/static/pdfjs-legacy/**, src/main/resources/static/js/thirdParty/**" @@ -297,14 +297,14 @@ dependencies { implementation 'ch.qos.logback:logback-core:1.5.15' implementation 'ch.qos.logback:logback-classic:1.5.15' - - // Exclude vulnerable BouncyCastle version used in tableau + + // Exclude vulnerable BouncyCastle version used in tableau configurations.all { exclude group: 'org.bouncycastle', module: 'bcpkix-jdk15on' exclude group: 'org.bouncycastle', module: 'bcutil-jdk15on' exclude group: 'org.bouncycastle', module: 'bcmail-jdk15on' } - + if (System.getenv("STIRLING_PDF_DESKTOP_UI") != "false") { implementation 'org.apache.commons:commons-compress:1.26.0' implementation "me.friwi:jcefmaven:127.3.1"