Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter license when undefined to fix error in /discussions/1255 #1256

Merged
merged 8 commits into from
Jul 18, 2024

Conversation

fitzmx6
Copy link
Contributor

@fitzmx6 fitzmx6 commented Jul 18, 2024

filter license when undefined to fix error in /discussions/1255, add unit tests for undefined license and multiple licenses and update git ignore to add line for IntelliJ module files

@fitzmx6 fitzmx6 force-pushed the fix-for-undefined-license branch 2 times, most recently from d559111 to cb214ac Compare July 18, 2024 15:21
@prabhu
Copy link
Contributor

prabhu commented Jul 18, 2024

Can you run pnpm lint && pnpm run gen-types to fix the linting errors. Regarding the tests, we combine multiple license expressions using the OR clause after a recent commit.

@fitzmx6 fitzmx6 force-pushed the fix-for-undefined-license branch 2 times, most recently from 346e3d5 to 2915364 Compare July 18, 2024 15:42
@fitzmx6
Copy link
Contributor Author

fitzmx6 commented Jul 18, 2024

Can you run pnpm lint && pnpm run gen-types to fix the linting errors. Regarding the tests, we combine multiple license expressions using the OR clause after a recent commit.

I removed the failing test since I now see one already exists for multi lines. I thought it was missing so I was adding to get better coverage but it is not needed.

@prabhu
Copy link
Contributor

prabhu commented Jul 18, 2024

@fitzmx6 Can we add a test specifically for the issue faced? Like capture the api output from maven central and invoke the particular logic? I have a feeling this particular attribute could be undefined.

cdxgen/utils.js

Line 4207 in 39e3ac8

let licenseId = license.spdx_id;

@fitzmx6
Copy link
Contributor Author

fitzmx6 commented Jul 18, 2024

@fitzmx6 Can we add a test specifically for the issue faced? Like capture the api output from maven central and invoke the particular logic? I have a feeling this particular attribute could be undefined.

cdxgen/utils.js

Line 4207 in 39e3ac8

let licenseId = license.spdx_id;

All of the tests for utils.getRepoLicense are commented out. Was/Is there something with them?

@prabhu
Copy link
Contributor

prabhu commented Jul 18, 2024

Hmm, no idea. May be an api limit thingy. Do they work if we uncomment them?

…ons/1255, add unite tests for undefined license and multiple licenses and update git ignore to add line for IntelliJ module files - Signed-off-by: Cory Fitzpatrick [email protected]

Signed-off-by: Cory Fitzpatrick <[email protected]>
@fitzmx6
Copy link
Contributor Author

fitzmx6 commented Jul 18, 2024

@fitzmx6 Can we add a test specifically for the issue faced? Like capture the api output from maven central and invoke the particular logic? I have a feeling this particular attribute could be undefined.

cdxgen/utils.js

Line 4207 in 39e3ac8

let licenseId = license.spdx_id;

I enabled the tests for this method and debugged the code a bit. This can be undefined but ,when it is the tests still pass so from my perspective this works as intended but I do not have all that much context to what all this means. If all my checks pass I think this is as far as I would like to go with this PR if that ok?

… Signed-off-by: Cory Fitzpatrick [email protected]

Signed-off-by: Cory Fitzpatrick <[email protected]>
@fitzmx6 fitzmx6 marked this pull request as ready for review July 18, 2024 20:02
if (!licenseContent.name && !licenseContent.id) {
licenseContent.name = "CUSTOM";
license
.filter((l) => l !== undefined)
Copy link
Contributor Author

@fitzmx6 fitzmx6 Jul 18, 2024

Choose a reason for hiding this comment

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

Aside from formatting this was my only real change in this file

@@ -2398,6 +2406,11 @@ test("get licenses", () => {
expression: "GPL-3.0-only WITH Classpath-exception-2.0",
},
]);

licenses = getLicenses({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the test for my code change. The rest of the changes are me uncommenting some other tests and fixing them so they pass.

Copy link
Contributor

@prabhu prabhu left a comment

Choose a reason for hiding this comment

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

Thank you!

@prabhu prabhu merged commit f0ea9bb into CycloneDX:master Jul 18, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants