Skip to content

Commit

Permalink
Support inline fixers for fix and warn plugin
Browse files Browse the repository at this point in the history
What's done:
* Added support inline fixers for fix and warn plugin
Closes #221
  • Loading branch information
Cheshiriks committed Aug 31, 2021
1 parent c22931f commit 8ef8558
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class FixAndWarnPlugin(
fileSystem,
useInternalRedirections,
redirectTo) {
private val fixPluginConfig: FixPluginConfig =
testConfig.pluginConfigs.filterIsInstance<FixAndWarnPluginConfig>().single().fix
private val warnPluginConfig: WarnPluginConfig =
testConfig.pluginConfigs.filterIsInstance<FixAndWarnPluginConfig>().single().warn
private val fixAndWarnPluginConfig: FixAndWarnPluginConfig = testConfig.pluginConfigs.filterIsInstance<FixAndWarnPluginConfig>().single()
private val fixPluginConfig: FixPluginConfig = fixAndWarnPluginConfig.fix
private val warnPluginConfig: WarnPluginConfig = fixAndWarnPluginConfig.warn
private val generalConfig: GeneralConfig =
testConfig.pluginConfigs.filterIsInstance<GeneralConfig>().single()
private val inlineFixer = fixAndWarnPluginConfig.inlineFixer
private lateinit var fixPlugin: FixPlugin
private lateinit var warnPlugin: WarnPlugin

Expand Down Expand Up @@ -96,6 +96,10 @@ class FixAndWarnPlugin(
}
}

if (inlineFixer == true) {
1 == 1
}

// TODO: If we receive just one command for execution, and want to avoid extra executions
// TODO: then warn plugin should look at the fix plugin output for actual warnings, and not execute command one more time.
// TODO: However it's required changes in warn plugin logic (it's should be able to compare expected and actual warnings from different places),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import kotlinx.serialization.Transient
@Serializable
data class FixAndWarnPluginConfig(
val fix: FixPluginConfig,
val warn: WarnPluginConfig
val warn: WarnPluginConfig,
val inlineFixer: Boolean? = null,
) : PluginConfig {
override val type = TestConfigSections.`FIX AND WARN`

Expand All @@ -31,7 +32,8 @@ data class FixAndWarnPluginConfig(
val mergedWarnPluginConfig = warn.mergeWith(other.warn)
return FixAndWarnPluginConfig(
mergedFixPluginConfig as FixPluginConfig,
mergedWarnPluginConfig as WarnPluginConfig
mergedWarnPluginConfig as WarnPluginConfig,
this.inlineFixer ?: otherConfig.inlineFixer
)
}

Expand All @@ -45,7 +47,8 @@ data class FixAndWarnPluginConfig(
}
return FixAndWarnPluginConfig(
fix.validateAndSetDefaults(),
warn.validateAndSetDefaults()
warn.validateAndSetDefaults(),
inlineFixer ?: false,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class FixAndWarnPluginTest {
WarnPluginConfig(warnExecutionCmd,
Regex("(.+):(\\d+):(\\d+): (.+)"),
true, true, 1, ", ", 1, 2, 3, 1, 2, 3, 4
)
),
false,
),
GeneralConfig("", listOf(""), "", "", expectedWarningsPattern = Regex("// ;warn:(\\d+):(\\d+): (.*)"))
),
Expand Down

0 comments on commit 8ef8558

Please sign in to comment.