Skip to content

Commit 1e4d928

Browse files
committed
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 75128d3 commit 1e4d928

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

evaluator/src/main/kotlin/PackageRule.kt

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

271+
/** Backwards compatibility */
272+
val licenseSource by lazy {
273+
require(licenseSources.size == 1) {
274+
"The license source is ambiguous. Please use the licenseSources property instead."
275+
}
276+
277+
licenseSources.single()
278+
}
279+
271280
/**
272281
* A shortcut for the [license][ResolvedLicense.license] in [resolvedLicense].
273282
*/

evaluator/src/main/kotlin/Rule.kt

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

0 commit comments

Comments
 (0)