Skip to content

Commit 8c44641

Browse files
committed
chore(scancode): Document interface design
As part of following the new docs, rearrange data properties where needed. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 4724cda commit 8c44641

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

plugins/scanners/scancode/src/main/kotlin/ScanCodeResultModel.kt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ data class HeaderEntry(
6666
}
6767
}
6868

69+
/**
70+
* An interface to be able to treat all versions of file entries the same.
71+
*
72+
* Note that the data class constructors of the individual version's implementation of this interface should contain
73+
* only those properties which are actually present in the data, in the order used in the data, to exactly resemble that
74+
* version's data model. Other properties required to implement the interface should be added to the body of the data
75+
* class to clearly separate data model properties from "synthetic" interface properties.
76+
*/
6977
sealed interface FileEntry {
7078
val path: String
7179
val type: String
@@ -142,6 +150,14 @@ data class LicenseDetection(
142150
val matches: List<LicenseEntry>
143151
)
144152

153+
/**
154+
* An interface to be able to treat all versions of license entries the same.
155+
*
156+
* Note that the data class constructors of the individual version's implementation of this interface should contain
157+
* only those properties which are actually present in the data, in the order used in the data, to exactly resemble that
158+
* version's data model. Other properties required to implement the interface should be added to the body of the data
159+
* class to clearly separate data model properties from "synthetic" interface properties.
160+
*/
145161
sealed interface LicenseEntry {
146162
val licenseExpression: String
147163
val startLine: Int
@@ -164,23 +180,23 @@ sealed interface LicenseEntry {
164180

165181
@Serializable
166182
data class Version3(
167-
override val score: Float,
168-
override val startLine: Int,
169-
override val endLine: Int,
170183
override val licenseExpression: String,
171184
val spdxLicenseExpression: String? = null,
172185
val fromFile: String? = null,
186+
override val startLine: Int,
187+
override val endLine: Int,
188+
override val score: Float,
173189
override val matchedText: String? = null
174190
) : LicenseEntry
175191

176192
@Serializable
177193
data class Version4(
178-
override val score: Float,
179-
override val startLine: Int,
180-
override val endLine: Int,
181194
override val licenseExpression: String,
182195
val licenseExpressionSpdx: String? = null,
183196
val fromFile: String? = null,
197+
override val startLine: Int,
198+
override val endLine: Int,
199+
override val score: Float,
184200
override val matchedText: String? = null
185201
) : LicenseEntry
186202
}
@@ -190,6 +206,14 @@ data class LicenseRule(
190206
val licenseExpression: String
191207
)
192208

209+
/**
210+
* An interface to be able to treat all versions of copyright entries the same.
211+
*
212+
* Note that the data class constructors of the individual version's implementation of this interface should contain
213+
* only those properties which are actually present in the data, in the order used in the data, to exactly resemble that
214+
* version's data model. Other properties required to implement the interface should be added to the body of the data
215+
* class to clearly separate data model properties from "synthetic" interface properties.
216+
*/
193217
sealed interface CopyrightEntry {
194218
val statement: String
195219
val startLine: Int

0 commit comments

Comments
 (0)