Skip to content

BC: improv license#547

Merged
jkowalleck merged 7 commits intomainfrom
improv-license
May 15, 2023
Merged

BC: improv license#547
jkowalleck merged 7 commits intomainfrom
improv-license

Conversation

@jkowalleck
Copy link
Member

@jkowalleck jkowalleck commented Mar 15, 2023

this is a blob of improvements for license handling.

needs to be split and introduced separately,
some might be breaking changes or regressions.

see annotations

"dependencies": {
"packageurl-js": ">=0.0.6 <0.0.8 || ^1"
"packageurl-js": ">=0.0.6 <0.0.8 || ^1",
"spdx-expression-parse": "^3.0.1"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ new dep must be communicated in HISTORY

@@ -23,11 +23,19 @@ import { fixupSpdxId } from '../spdx'

export class LicenseFactory {
makeFromString (value: string): License {
Copy link
Member Author

@jkowalleck jkowalleck Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ behavioral change. breaking change.

import type { Attachment } from './attachment'

export class LicenseExpression {
static isEligibleExpression (expression: string | any): boolean {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes #271

export interface OptionalNamedLicenseProperties {
text?: NamedLicense['text']
url?: NamedLicense['url']
class DisjunctiveLicenseBase {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonbreaking optimization

suite('Factories.LicenseFactory', () => {
test('makeFromString() -> LicenseExpression', () => {
const sut = new LicenseFactory()
const expression = '(MIT OR Apache-2.0)'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@jkowalleck jkowalleck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contains breaking changes

return false
}
try {
spdxExpressionParse(expression)
Copy link
Member Author

@jkowalleck jkowalleck Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

behavioral change.
BREAKING CHNAGE ⚡

@jkowalleck jkowalleck added this to the v2 milestone Mar 15, 2023
}

makeDisjunctiveWithName (value: string | any): NamedLicense {
makeNamedLicense (value: string | any): NamedLicense {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ BC

const spdxId = fixupSpdxId(String(value))
if (undefined === spdxId) {
throw new RangeError('Unsupported SPDX id')
makeSpdxLicense (value: string | any): SpdxLicense {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ BC

* You may assert valid objects with {@link Factories.LicenseFactory.makeExpression | Factories.LicenseFactory.makeExpression()}.
*/
export class LicenseExpression {
static isEligibleExpression (expression: string | any): boolean {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ BC


/**
* @throws {@link RangeError} if `expression` is not {@link LicenseExpression.isEligibleExpression | eligible}
* @throws {@link RangeError} if `expression` is empty string
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ BC


/**
* @throws {@link RangeError} if value is not {@link LicenseExpression.isEligibleExpression | eligible}
* @throws {@link RangeError} if `value` is empty string
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ BC


/**
* @throws {@link RangeError} if `id` is not {@link isSupportedSpdxId | supported}
* @throws {@link RangeError} if `id` is empy string
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ BC

@jkowalleck jkowalleck force-pushed the improv-license branch 2 times, most recently from 6281c2c to 1f35a28 Compare March 22, 2023 15:22
@jkowalleck jkowalleck changed the title Improv license BC: improv license Mar 22, 2023
@codacy-production
Copy link

codacy-production bot commented Mar 25, 2023

Coverage summary from Codacy

Merging #547 (8f2e1f0) into main (3d3ef13) - See PR on Codacy

Coverage variation Diff coverage
-0.14% (target: -1.00%) 94.44% (target: 90.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (3d3ef13) 6675 6568 98.40%
Head commit (8f2e1f0) 6728 (+53) 6611 (+43) 98.26% (-0.14%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#547) 108 102 94.44%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@jkowalleck jkowalleck marked this pull request as ready for review March 27, 2023 22:29
@jkowalleck jkowalleck requested a review from a team as a code owner March 27, 2023 22:29
@jkowalleck jkowalleck force-pushed the improv-license branch 2 times, most recently from a43f5f1 to dc1f01f Compare April 5, 2023 10:44
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>

/**
* @throws {@link RangeError} if value is not {@link isSupportedSpdxId | supported}
* @throws {@link RangeError} if `value` is empy string
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ BC

@jkowalleck jkowalleck merged commit 8c467ee into main May 15, 2023
@jkowalleck jkowalleck deleted the improv-license branch May 15, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rework license models feat: complete SPDX expression detection

1 participant