diff --git a/CHANGELOG.md b/CHANGELOG.md index 49410e8..ed387f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Experimental mode to ignore recorded violations (#9) + ## [0.0.4] - 2023-07-21 ### Added diff --git a/gradle.properties b/gradle.properties index 81a4d5d..8df9b3b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.vinted.packwerkintellij pluginName = packwerk-intellij pluginRepositoryUrl = https://github.com/vinted/packwerk-intellij # SemVer format -> https://semver.org -pluginVersion = 0.0.4 +pluginVersion = 0.0.5 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 223 diff --git a/src/main/kotlin/com/vinted/packwerkintellij/PackwerkSettingsConfigurable.kt b/src/main/kotlin/com/vinted/packwerkintellij/PackwerkSettingsConfigurable.kt index 905b42b..0934db5 100644 --- a/src/main/kotlin/com/vinted/packwerkintellij/PackwerkSettingsConfigurable.kt +++ b/src/main/kotlin/com/vinted/packwerkintellij/PackwerkSettingsConfigurable.kt @@ -12,12 +12,14 @@ class PackwerkSettingsConfigurable(private val project: Project) : BoundConfigur private var packwerkPath: String = "" private var enabled = true private var lintUnsavedFiles = false + private var ignoreRecordedViolations = false override fun createPanel(): DialogPanel = panel { val settings = project.service() packwerkPath = settings.packwerkPath enabled = settings.enabled lintUnsavedFiles = settings.lintUnsavedFiles + ignoreRecordedViolations = settings.ignoreRecordedViolations row("Packwerk path:") { textField() @@ -41,11 +43,20 @@ class PackwerkSettingsConfigurable(private val project: Project) : BoundConfigur "which is currently only supported by Packs and not Packwerk." ) } + row { + checkBox("Experimental: Ignore recorded violations") + .bindSelected(::ignoreRecordedViolations) + .comment( + "Show violations in the editor even if they're recorded in package_todo.yml. " + + "Warning: not widely supported." + ) + } onApply { settings.packwerkPath = packwerkPath settings.enabled = enabled settings.lintUnsavedFiles = lintUnsavedFiles + settings.ignoreRecordedViolations = ignoreRecordedViolations } } } diff --git a/src/main/kotlin/com/vinted/packwerkintellij/PackwerkSettingsState.kt b/src/main/kotlin/com/vinted/packwerkintellij/PackwerkSettingsState.kt index af5f61b..6f34825 100644 --- a/src/main/kotlin/com/vinted/packwerkintellij/PackwerkSettingsState.kt +++ b/src/main/kotlin/com/vinted/packwerkintellij/PackwerkSettingsState.kt @@ -11,6 +11,7 @@ class PackwerkSettingsState : PersistentStateComponent { var packwerkPath: String = "bin/packwerk" var enabled = true var lintUnsavedFiles = false + var ignoreRecordedViolations = false override fun getState(): PackwerkSettingsState { return this @@ -20,5 +21,6 @@ class PackwerkSettingsState : PersistentStateComponent { this.packwerkPath = state.packwerkPath this.enabled = state.enabled this.lintUnsavedFiles = state.lintUnsavedFiles + this.ignoreRecordedViolations = state.ignoreRecordedViolations } } diff --git a/src/main/kotlin/com/vinted/packwerkintellij/annotators/PackwerkAnnotator.kt b/src/main/kotlin/com/vinted/packwerkintellij/annotators/PackwerkAnnotator.kt index 1422bf9..668683f 100644 --- a/src/main/kotlin/com/vinted/packwerkintellij/annotators/PackwerkAnnotator.kt +++ b/src/main/kotlin/com/vinted/packwerkintellij/annotators/PackwerkAnnotator.kt @@ -32,7 +32,9 @@ internal class PackwerkAnnotator : ExternalAnnotator) internal class Problem(var line: Int, var column: Int, var explanation: String) @@ -59,24 +61,33 @@ internal class PackwerkAnnotator : ExternalAnnotator() + val useStdin = collectedInfo.fileText != null - val packwerkSubcommand = if (useStdin) { - "check-contents" + if (useStdin) { + cmdParams.push("check-contents") } else { - "check" + cmdParams.push("check") } + if (collectedInfo.ignoreRecordedViolations) { + cmdParams.push("--ignore-recorded-violations") + } + + cmdParams.push("--") + cmdParams.push(relativePath) + val cmd = GeneralCommandLine(collectedInfo.packwerkPath) .withWorkDirectory(root.path) .withCharset(Charset.forName("UTF-8")) - .withParameters(packwerkSubcommand, relativePath) + .withParameters(cmdParams) val process: Process try { @@ -137,7 +148,9 @@ internal class PackwerkAnnotator : ExternalAnnotator