diff --git a/.github/readme/qodana.png b/.github/readme/qodana.png new file mode 100644 index 0000000..40f8452 Binary files /dev/null and b/.github/readme/qodana.png differ diff --git a/.github/readme/run-debug-configurations.png b/.github/readme/run-debug-configurations.png index a83484a..e6e436f 100644 Binary files a/.github/readme/run-debug-configurations.png and b/.github/readme/run-debug-configurations.png differ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fa4e37..da3618f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,6 +74,10 @@ jobs: path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }} + # Run Qodana inspections + - name: Qodana - Code Inspection + uses: JetBrains/qodana-action@v2.1-eap + # Run tests - name: Run Tests run: ./gradlew test diff --git a/.gitignore b/.gitignore index e0d53d8..e2e5d94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .gradle .idea +.qodana build diff --git a/.run/Run Qodana.run.xml b/.run/Run Qodana.run.xml new file mode 100644 index 0000000..9603583 --- /dev/null +++ b/.run/Run Qodana.run.xml @@ -0,0 +1,26 @@ + + + + + + + + true + true + false + + + \ No newline at end of file diff --git a/README.md b/README.md index b4ddd7e..40c68ba 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ In this README, we will highlight the following elements of template-project cre - listeners – project and dynamic plugin lifecycle - services – project-related and application-related services - actions – basic action with shortcut binding +- [Qodana integration](#qodana-integration) - [Predefined Run/Debug configurations](#predefined-rundebug-configurations) - [Continuous integration](#continuous-integration) based on GitHub Actions - [Dependencies management](#dependencies-management) with Dependabot @@ -159,6 +160,7 @@ A generated IntelliJ Platform Plugin Template repository contains the following ├── gradlew *nix Gradle Wrapper binary ├── gradlew.bat Windows Gradle Wrapper binary ├── LICENSE License, MIT by default +├── qodana.yml Qodana configuration file ├── README.md README └── settings.gradle.kts Grade project settings ``` @@ -218,19 +220,41 @@ To start with the actual implementation, you may check our [IntelliJ Platform SD For those, who value example codes the most, there are also available [IntelliJ SDK Code Samples][gh:code-samples] and [IntelliJ Platform Explorer][jb:ipe] – a search tool for browsing Extension Points inside existing implementations of open-source IntelliJ Platform plugins. +## Qodana integration + +To increase the project value, the IntelliJ Platform Plugin Template got integrated with [Qodana][docs:qodana], a code quality monitoring platform that allows you to check the condition of your implementation and find any possible problems that may require enhancing. + +Qodana brings into your CI/CD pipelines all the smart features you love in the JetBrains IDEs and generates an HTML report with the actual inspection status. + +Qodana inspections are accessible within the project on two levels: + +- using the [Qodana IntelliJ GitHub Action][docs:qodana-github-action], run automatically within the [Build](.github/workflows/build.yml) workflow, +- with the [Gradle Qodana Plugin][gh:gradle-qodana-plugin], so you can use it on the local environment or any CI other than GitHub Actions. + +Qodana inspection is configured with the `qodana { ... }` section in the Gradle build file, and [`qodana.yml`][file:qodana.yml] YAML configuration file. + +> **NOTE:** Qodana requires Docker to be installed and available in your environment. + +To run inspections, you can use a predefined *Run Qodana* configuration, which will provide a full report on `http://localhost:8080`, or invoke the Gradle task directly with the `./gradlew runInspections` command. + +A final report is available in the `./build/reports/inspections/` directory. + +![Qodana][file:qodana.png] + + ## Predefined Run/Debug configurations Within the default project structure, there is a `.run` directory provided containing three predefined *Run/Debug configurations* that expose corresponding Gradle tasks: ![Run/Debug configurations][file:run-debug-configurations.png] -| Configuration name | Description | -| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Run Plugin | Runs [`:runIde`][gh:gradle-intellij-plugin-running-dsl] Gradle IntelliJ Plugin task. Use the *Debug* icon for plugin debugging. | -| Run Tests | Runs [`:test`][gradle-lifecycle-tasks] Gradle task. | -| Run Verifications | Runs [`:runPluginVerifier`][gh:gradle-intellij-plugin-verifier-dsl] Gradle IntelliJ Plugin task to check the plugin compatibility against the specified IntelliJ IDEs. | -| Publish Plugin | Runs `signPlugin` and `publishPlugin` Gradle tasks. Check [Environment variables](#environment-variables) section for more details on how to configure it. | - +| Configuration name | Description | +| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Run Plugin | Runs [`:runIde`][gh:gradle-intellij-plugin-running-dsl] Gradle IntelliJ Plugin task. Use the *Debug* icon for plugin debugging. | +| Run Tests | Runs [`:test`][gradle-lifecycle-tasks] Gradle task. | +| Run Qodana | Runs [`:runInspections`][gh:gradle-qodana-plugin] Gradle Qodana Plugin task. Starts Qodana inspections in a Docker container and serves generated report on `localhost:8080`. | +| Run Verifications | Runs [`:runPluginVerifier`][gh:gradle-intellij-plugin-verifier-dsl] Gradle IntelliJ Plugin task to check the plugin compatibility against the specified IntelliJ IDEs. | +| Publish Plugin | Runs `signPlugin` and `publishPlugin` Gradle tasks. Check [Environment variables](#environment-variables) section for more details on how to configure it. | > **TIP:** You can find the logs from the running task in the `idea.log` tab. > @@ -273,7 +297,7 @@ Keeping the project in good shape and having all the dependencies up-to-date req Dependabot is a bot provided by GitHub for checking the build configuration files and reviewing any outdated or insecure dependencies of yours – in case if any update is available, it creates a new pull request providing [the proper change][gh:dependabot-pr]. -> **Note:** Dependabot doesn't yet support checking of the Gradle Wrapper. +> **NOTE:** Dependabot doesn't yet support checking of the Gradle Wrapper. > Check the [Gradle Releases][gradle-releases] page and update your `gradle.properties` file with: > ```properties > gradleVersion = 7.2 @@ -412,6 +436,8 @@ If the message contains one of the following strings: `[skip ci]`, `[ci skip]`, [docs:release-channel]: https://plugins.jetbrains.com/docs/intellij/deployment.html?from=IJPluginTemplate#specifying-a-release-channel [docs:using-gradle]: https://plugins.jetbrains.com/docs/intellij/gradle-build-system.html?from=IJPluginTemplate [docs:plugin-signing]: https://plugins.jetbrains.com/docs/intellij/plugin-signing.html?from=IJPluginTemplate +[docs:qodana]: https://www.jetbrains.com/help/qodana +[docs:qodana-github-action]: https://www.jetbrains.com/help/qodana/qodana-intellij-github-action.html [file:use-this-template.png]: .github/readme/use-this-template.png [file:draft-release.png]: .github/readme/draft-release.png @@ -423,11 +449,14 @@ If the message contains one of the following strings: `[skip ci]`, `[ci skip]`, [file:run-debug-env.png]: .github/readme/run-debug-env.png [file:template_cleanup.yml]: ./.github/workflows/template-cleanup.yml [file:intellij-platform-plugin-template.png]: ./.github/readme/intellij-platform-plugin-template.png +[file:qodana.yml]: ./qodana.yml +[file:qodana.png]: .github/readme/qodana.png [gh:actions]: https://help.github.com/en/actions [gh:dependabot]: https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/keeping-your-dependencies-updated-automatically [gh:code-samples]: https://github.com/JetBrains/intellij-sdk-code-samples [gh:gradle-changelog-plugin]: https://github.com/JetBrains/gradle-changelog-plugin +[gh:gradle-qodana-plugin]: https://github.com/JetBrains/gradle-qodana-plugin [gh:gradle-intellij-plugin]: https://github.com/JetBrains/gradle-intellij-plugin [gh:gradle-intellij-plugin-running-dsl]: https://github.com/JetBrains/gradle-intellij-plugin#running-dsl [gh:gradle-intellij-plugin-verifier-dsl]: https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl diff --git a/build.gradle.kts b/build.gradle.kts index f183d94..f6356c7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,10 +8,12 @@ plugins { id("java") // Kotlin support id("org.jetbrains.kotlin.jvm") version "1.5.30" - // gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin + // Gradle IntelliJ Plugin id("org.jetbrains.intellij") version "1.1.4" - // gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin + // Gradle Changelog Plugin id("org.jetbrains.changelog") version "1.3.0" + // Gradle Qodana Plugin + id("org.jetbrains.qodana") version "0.1.12" } group = properties("pluginGroup") @@ -22,8 +24,7 @@ repositories { mavenCentral() } -// Configure gradle-intellij-plugin plugin. -// Read more: https://github.com/JetBrains/gradle-intellij-plugin +// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin intellij { pluginName.set(properties("pluginName")) version.set(properties("platformVersion")) @@ -35,13 +36,20 @@ intellij { plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) } -// Configure gradle-changelog-plugin plugin. -// Read more: https://github.com/JetBrains/gradle-changelog-plugin +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin changelog { version.set(properties("pluginVersion")) groups.set(emptyList()) } +// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin +qodana { + cachePath.set(projectDir.resolve(".qodana").canonicalPath) + reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath) + saveReport.set(true) + showReport.set(System.getenv("QODANA_SHOW_REPORT").toBoolean()) +} + tasks { // Set the JVM compatibility versions properties("javaVersion").let { @@ -65,7 +73,7 @@ tasks { // Extract the section from README.md and provide for the plugin's manifest pluginDescription.set( - File(projectDir, "README.md").readText().lines().run { + projectDir.resolve("README.md").readText().lines().run { val start = "" val end = "" diff --git a/qodana.yml b/qodana.yml new file mode 100644 index 0000000..dac95d3 --- /dev/null +++ b/qodana.yml @@ -0,0 +1,6 @@ +# Qodana configuration: +# https://www.jetbrains.com/help/qodana/qodana-yaml.html + +version: 1.0 +profile: + name: qodana.recommended diff --git a/src/main/kotlin/org/jetbrains/plugins/template/MyBundle.kt b/src/main/kotlin/org/jetbrains/plugins/template/MyBundle.kt index ad56e35..66efe9a 100644 --- a/src/main/kotlin/org/jetbrains/plugins/template/MyBundle.kt +++ b/src/main/kotlin/org/jetbrains/plugins/template/MyBundle.kt @@ -1,6 +1,5 @@ package org.jetbrains.plugins.template -import com.intellij.AbstractBundle import com.intellij.DynamicBundle import org.jetbrains.annotations.NonNls import org.jetbrains.annotations.PropertyKey @@ -15,7 +14,7 @@ object MyBundle : DynamicBundle(BUNDLE) { fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = getMessage(key, *params) - @Suppress("SpreadOperator") + @Suppress("SpreadOperator", "unused") @JvmStatic fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = getLazyMessage(key, *params)