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

node: Port all remaining Jackson-based code to KxS #9125

Merged
merged 7 commits into from
Sep 12, 2024

Conversation

fviernau
Copy link
Member

See individual commits.

@fviernau fviernau requested a review from a team as a code owner September 11, 2024 15:40
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 67.15%. Comparing base (d06e12e) to head (de0df1b).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...ckage-managers/node/src/main/kotlin/yarn2/Yarn2.kt 84.61% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9125      +/-   ##
============================================
+ Coverage     67.14%   67.15%   +0.01%     
+ Complexity     1193     1191       -2     
============================================
  Files           239      239              
  Lines          7892     7898       +6     
  Branches        914      916       +2     
============================================
+ Hits           5299     5304       +5     
  Misses         2225     2225              
- Partials        368      369       +1     
Flag Coverage Δ
funTest-docker 59.60% <76.92%> (+0.16%) ⬆️
funTest-non-docker 34.59% <ø> (ø)
test 36.61% <46.15%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -146,7 +141,8 @@ class Yarn2(
*/
private fun isCorepackEnabledInManifest(workingDir: File): Boolean =
runCatching {
PACKAGE_MANAGER_PROPERTY in jsonMapper.readTree(workingDir.resolve(MANIFEST_FILE))
val packageJson = parsePackageJson(workingDir.resolve(MANIFEST_FILE))
packageJson.packageManger.orEmpty().isNotBlank()
Copy link
Member

Choose a reason for hiding this comment

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

How about !packageJson.packageManger.isNullOrEmpty() instead? There is also isNullOrBlank(), but I'm not sure whether we need to cover the rather pathological blank case here.

Comment on lines 739 to 740
when {
type == YarnDependencyType.DEPENDENCIES -> dependencies
else -> devDependencies
}
Copy link
Member

Choose a reason for hiding this comment

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

Better use

when (type) {
    YarnDependencyType.DEPENDENCIES -> dependencies
    YarnDependencyType.DEV_DEPENDENCIES -> devDependencies
}

Kotlin will recognize that the when is exhaustive, so no else is needed.

@@ -61,8 +59,11 @@ import org.ossreviewtoolkit.plugins.packagemanagers.node.utils.mapNpmLicenses
import org.ossreviewtoolkit.plugins.packagemanagers.node.utils.parseNpmAuthor
import org.ossreviewtoolkit.plugins.packagemanagers.node.utils.parseNpmVcsInfo
import org.ossreviewtoolkit.plugins.packagemanagers.node.utils.splitNpmNamespaceAndName
import org.ossreviewtoolkit.plugins.packagemanagers.node.yarn2.Yarn2.Companion.YARN2_RESOURCE_FILE
Copy link
Member

Choose a reason for hiding this comment

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

Commit message: Typo in .yarn*r*c.yml.

Comment on lines 745 to 747
val yarnPath = yarnConfig.get<YamlScalar>(YARN_PATH_PROPERTY_NAME)?.content.orEmpty().ifBlank { null }

requireNotNull(yarnPath) { "No Yarn 2+ executable could be found in '$YARN2_RESOURCE_FILE'." }
Copy link
Member

Choose a reason for hiding this comment

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

While at it, maybe simplify to

val yarnPath = yarnConfig.get<YamlScalar>(YARN_PATH_PROPERTY_NAME)?.content

require(!yarnPath.isNullOrEmpty()) { "No Yarn 2+ executable could be found in '$YARN2_RESOURCE_FILE'." }

Again, I'm unsure whether we need to cover the pathological bank case.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
sschuberth
sschuberth previously approved these changes Sep 11, 2024
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Separate the parsing of '.yarnrc.yml' a bit.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
@sschuberth sschuberth merged commit f654747 into main Sep 12, 2024
21 of 22 checks passed
@sschuberth sschuberth deleted the node-finish-porting-to-kxs branch September 12, 2024 07:21
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.

3 participants