Skip to content

Commit

Permalink
refactor(cargo): Move serializers to their respective model classes
Browse files Browse the repository at this point in the history
Model classes and serializers are tightly coupled, e.g. because of the
naming strategy, so put them together.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Apr 8, 2024
1 parent 5e701a8 commit acb18cb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
11 changes: 0 additions & 11 deletions plugins/package-managers/cargo/src/main/kotlin/Cargo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ package org.ossreviewtoolkit.plugins.packagemanagers.cargo

import java.io.File

import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonNamingStrategy

import net.peanuuutz.tomlkt.Toml
import net.peanuuutz.tomlkt.decodeFromNativeReader

import org.apache.logging.log4j.kotlin.logger
Expand Down Expand Up @@ -57,13 +53,6 @@ import org.ossreviewtoolkit.utils.ort.ProcessedDeclaredLicense
import org.ossreviewtoolkit.utils.spdx.SpdxConstants
import org.ossreviewtoolkit.utils.spdx.SpdxOperator

private val json = Json {
ignoreUnknownKeys = true
namingStrategy = JsonNamingStrategy.SnakeCase
}

private val toml = Toml { ignoreUnknownKeys = true }

private const val DEV_KIND_NAME = "dev"
private const val BUILD_KIND_NAME = "build"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ package org.ossreviewtoolkit.plugins.packagemanagers.cargo
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

import net.peanuuutz.tomlkt.Toml

internal val toml = Toml { ignoreUnknownKeys = true }

/**
* See https://docs.rs/cargo-lock/latest/cargo_lock/struct.Lockfile.html.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
package org.ossreviewtoolkit.plugins.packagemanagers.cargo

import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonNamingStrategy

internal val json = Json {
ignoreUnknownKeys = true
namingStrategy = JsonNamingStrategy.SnakeCase
}

/**
* See https://doc.rust-lang.org/cargo/commands/cargo-metadata.html.
Expand Down

0 comments on commit acb18cb

Please sign in to comment.