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

Refactor toml and lock file in cargo parsing using @iarna/toml(#1592) #1595

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Code-Agitator
Copy link

No description provided.

@Code-Agitator Code-Agitator requested a review from prabhu as a code owner January 24, 2025 09:57
// like `libc = 0.2.79`
version = dependencyNode;
} else if (
Object.prototype.toString.call(dependencyNode) === "[object Object]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we use Object.keys(dependencyNode).length and the existing logic that use instanceOf operator to determine string for consistency?

Object.prototype.toString.call(dependencyNode) === "[object Object]"
) {
// like `libc = { version = "0.2.79", features = ['rustc-dep-of-std'], default-features = false }`
version = dependencyNode["version"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need dependencyNode?.version and dependencyNode?.git here or are those values always present?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, the value of dependencyNode always present here. But you're right, using dependencyNode?.version can make the code less prone to exceptions.

// parse `[[package]]`
if (
packageNode &&
Object.prototype.toString.call(packageNode) === "[object Array]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we use Array.isArray here?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, using Array.isArray would indeed be better here.

@prabhu
Copy link
Collaborator

prabhu commented Jan 24, 2025

Looks very good. Just few minor comments.

pkg.repository = { url: pkgRepository };
}
if (pkgLicense) {
pkg.license = pkgLicense;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Repotests is complaining about this line. Any ideas?

@Code-Agitator
Copy link
Author

@prabhu Thank you so much for taking the time to review my code and provide such feedback.

@prabhu
Copy link
Collaborator

prabhu commented Jan 26, 2025

Looking forward to the updates. Will be a great improvement.

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