Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency com.github.ajalt.clikt:clikt to v5 #903

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package de.fraunhofer.aisec.codyze.backends.cpg
import com.github.ajalt.clikt.core.BadParameterValue
import com.github.ajalt.clikt.core.MultiUsageError
import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.parse
import com.github.ajalt.clikt.parameters.groups.provideDelegate
import de.fraunhofer.aisec.codyze.core.config.combineSources
import de.fraunhofer.aisec.cpg.passes.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package de.fraunhofer.aisec.codyze.cli

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.context
import com.github.ajalt.clikt.core.findOrSetObject
import com.github.ajalt.clikt.output.MordantHelpFormatter
Expand Down Expand Up @@ -51,7 +51,10 @@
* config[[Path]] as context to the [[CodyzeCli]] command.
*/
@Suppress("Unused")
class ConfigFileParser : CliktCommand(treatUnknownOptionsAsArgs = true) {
class ConfigFileParser : CliktCommand() {

Check warning on line 54 in codyze-cli/src/main/kotlin/de/fraunhofer/aisec/codyze/cli/CodyzeCli.kt

View check run for this annotation

Codecov / codecov/patch

codyze-cli/src/main/kotlin/de/fraunhofer/aisec/codyze/cli/CodyzeCli.kt#L54

Added line #L54 was not covered by tests

override val treatUnknownOptionsAsArgs: Boolean = true

Check warning on line 56 in codyze-cli/src/main/kotlin/de/fraunhofer/aisec/codyze/cli/CodyzeCli.kt

View check run for this annotation

Codecov / codecov/patch

codyze-cli/src/main/kotlin/de/fraunhofer/aisec/codyze/cli/CodyzeCli.kt#L56

Added line #L56 was not covered by tests

val configFile: Path by configFileOption()

// necessary when using 'treatUnknownOptionsAsArgs'. Contains all given arguments except for configFile
Expand All @@ -70,11 +73,17 @@
*/
@Suppress("Unused", "UnusedPrivateMember")
class CodyzeCli(val configFile: Path?) :
NoOpCliktCommand(
help = "Codyze finds security flaws in source code",
printHelpOnEmptyArgs = true,
allowMultipleSubcommands = true
) {
CliktCommand() {

/*
* Configure Clikt command
*/
override val printHelpOnEmptyArgs: Boolean = true
override val allowMultipleSubcommands: Boolean = true

override fun help(context: Context): String {
return "Codyze finds security flaws in source code"

Check warning on line 85 in codyze-cli/src/main/kotlin/de/fraunhofer/aisec/codyze/cli/CodyzeCli.kt

View check run for this annotation

Codecov / codecov/patch

codyze-cli/src/main/kotlin/de/fraunhofer/aisec/codyze/cli/CodyzeCli.kt#L85

Added line #L85 was not covered by tests
}

init {
versionOption(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package de.fraunhofer.aisec.codyze.cli

import com.github.ajalt.clikt.core.main
import com.github.ajalt.clikt.core.parse
import com.github.ajalt.clikt.core.subcommands
import de.fraunhofer.aisec.codyze.core.backend.BackendCommand
import de.fraunhofer.aisec.codyze.core.executor.ExecutorCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package de.fraunhofer.aisec.codyze.cli

import com.github.ajalt.clikt.core.parse
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.options.multiple
import com.github.ajalt.clikt.parameters.options.option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package de.fraunhofer.aisec.codyze.cli

import com.github.ajalt.clikt.core.BadParameterValue
import com.github.ajalt.clikt.core.parse
import de.fraunhofer.aisec.codyze.core.output.SarifBuilder
import org.junit.jupiter.api.*
import org.junit.jupiter.api.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
* This abstract class must be implemented by all [Backend]s that want to be selectable in the codyze-cli.
* Remember to add the newly created [BackendCommand] to the dependency injection.
*/
abstract class BackendCommand<T : Backend>(cliName: String? = null) : NoOpCliktCommand(hidden = true, name = cliName) {
abstract class BackendCommand<T : Backend>(cliName: String? = null) : NoOpCliktCommand(name = cliName) {

Check warning on line 25 in codyze-core/src/main/kotlin/de/fraunhofer/aisec/codyze/core/backend/BackendCommand.kt

View check run for this annotation

Codecov / codecov/patch

codyze-core/src/main/kotlin/de/fraunhofer/aisec/codyze/core/backend/BackendCommand.kt#L25

Added line #L25 was not covered by tests

/*
* Configure Clikt command
*/
override val hiddenFromHelp: Boolean = true

Check warning on line 30 in codyze-core/src/main/kotlin/de/fraunhofer/aisec/codyze/core/backend/BackendCommand.kt

View check run for this annotation

Codecov / codecov/patch

codyze-core/src/main/kotlin/de/fraunhofer/aisec/codyze/core/backend/BackendCommand.kt#L30

Added line #L30 was not covered by tests

abstract val backend: KClass<T>
abstract fun getBackend(): T
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ import org.koin.java.KoinJavaComponent.getKoin
* Remember to add the newly created [ExecutorCommand] to the dependency injection.
*/
abstract class ExecutorCommand<T : Executor>(cliName: String? = null) :
NoOpCliktCommand(hidden = true, name = cliName) {
CliktCommand(name = cliName) {

/*
* Configure Clikt command
*/
override val hiddenFromHelp: Boolean = true

/** Use the global context set in [CodyzeCli] */
private val usedExecutors by findOrSetObject { mutableListOf<ExecutorCommand<*>>() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package de.fraunhofer.aisec.codyze.core.plugin

import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.groups.provideDelegate
import de.fraunhofer.aisec.codyze.core.output.aggregator.Aggregate
import de.fraunhofer.aisec.codyze.core.output.aggregator.extractLastRun
Expand All @@ -34,7 +34,13 @@ val logger = KotlinLogging.logger { }
* Also, remember to add a page to docs/plugins.
*/
abstract class Plugin(private val cliName: String) :
NoOpCliktCommand(hidden = true, name = cliName) {
CliktCommand(name = cliName) {

/*
* Configure Clikt command
*/
override val hiddenFromHelp: Boolean = true

private val options by PluginOptionGroup(cliName)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package de.fraunhofer.aisec.codyze.specificationLanguages.coko.dsl.cli

import com.github.ajalt.clikt.core.parse
import org.junit.jupiter.api.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cpg-language-java = { module = "de.fraunhofer.aisec:cpg-language-java", version.

kotlin-logging = { module = "io.github.oshai:kotlin-logging-jvm", version = "7.0.0" }
log4j-impl = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version = "2.24.0"}
clikt = { module = "com.github.ajalt.clikt:clikt", version = "4.4.0"}
clikt = { module = "com.github.ajalt.clikt:clikt", version = "5.0.0"}
koin = { module = "io.insert-koin:koin-core", version.ref = "koin"}
koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin-test"}
koin-junit5 = { module = "io.insert-koin:koin-test-junit5", version.ref = "koin-test"}
Expand Down