Skip to content

Commit 6e5a7b5

Browse files
fviernautsteenbe
authored andcommitted
feat(evaluator): Add API's for backwards compatibility
Ensure the previous change is backwards compatible. Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
1 parent 74f8178 commit 6e5a7b5

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

evaluator/src/main/kotlin/PackageRule.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,16 @@ open class PackageRule(
268268
}
269269
}
270270

271+
/** Backwards compatibility */
272+
@Suppress("unused") // This is intended to be used by rule implementations.
273+
val licenseSource by lazy {
274+
require(licenseSources.size == 1) {
275+
"The license source is ambiguous. Please use the licenseSources property instead."
276+
}
277+
278+
licenseSources.single()
279+
}
280+
271281
/**
272282
* A shortcut for the [license][ResolvedLicense.license] in [resolvedLicense].
273283
*/

evaluator/src/main/kotlin/Rule.kt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,52 @@ abstract class Rule(
197197
}
198198
}
199199
}
200+
201+
/**
202+
* Backward compatibility for [Rule.issue()].
203+
*/
204+
@Suppress("unused") // This is intended to be used by rule implementations.
205+
fun Rule.issue(
206+
severity: Severity,
207+
pkgId: Identifier?,
208+
license: SpdxSingleLicenseExpression?,
209+
licenseSource: LicenseSource?,
210+
message: String,
211+
howToFix: String
212+
) = issue(severity, pkgId, license, setOfNotNull(licenseSource), message, howToFix)
213+
214+
/**
215+
* Backward compatibility for [Rule.hint()].
216+
*/
217+
@Suppress("unused") // This is intended to be used by rule implementations.
218+
fun Rule.hint(
219+
pkgId: Identifier?,
220+
license: SpdxSingleLicenseExpression?,
221+
licenseSource: LicenseSource?,
222+
message: String,
223+
howToFix: String
224+
) = hint(pkgId, license, setOfNotNull(licenseSource), message, howToFix)
225+
226+
/**
227+
* Backward compatibility for [Rule.warning()].
228+
*/
229+
@Suppress("unused") // This is intended to be used by rule implementations.
230+
fun Rule.warning(
231+
pkgId: Identifier?,
232+
license: SpdxSingleLicenseExpression?,
233+
licenseSource: LicenseSource?,
234+
message: String,
235+
howToFix: String
236+
) = warning(pkgId, license, setOfNotNull(licenseSource), message, howToFix)
237+
238+
/**
239+
* Backward compatibility for [Rule.error()].
240+
*/
241+
@Suppress("unused") // This is intended to be used by rule implementations.
242+
fun Rule.error(
243+
pkgId: Identifier?,
244+
license: SpdxSingleLicenseExpression?,
245+
licenseSource: LicenseSource?,
246+
message: String,
247+
howToFix: String
248+
) = warning(pkgId, license, setOfNotNull(licenseSource), message, howToFix)

0 commit comments

Comments
 (0)