-
Notifications
You must be signed in to change notification settings - Fork 103
fix: make zip crate safer and more readable #536
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @Its-Just-Nans, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the robustness and readability of the codebase by implementing stricter error handling, enforcing comprehensive Clippy lints, and refining type conversions. The changes aim to make the code safer and more maintainable, particularly in areas involving cryptographic operations, data decompression, and string conversions, without altering the core functionality. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
This PR makes significant improvements to code safety by eliminating unwrap() calls and adding strict clippy lints. However, there are several critical issues that need to be addressed before merging:
Critical Issues ⚠️
-
Breaking API Change: The
data_start()method inZipFilenow returnsOption<u64>instead ofu64, which is a breaking change requiring a major version bump. -
Logic Error in CP437 Conversion: The change from
maptofilter_mapinsrc/cp437.rssilently drops invalid characters instead of properly handling conversion errors, potentially causing data loss.
Positive Changes ✅
- Proper error handling replacing unwrap() calls throughout the codebase
- Addition of strict clippy lints to prevent future unsafe code
- Improved error messages in many places
- Better use of explicit type conversions
Recommendations
-
For the API breaking change: Either revert the
data_start()signature change or document this as a breaking change requiring a major version bump. -
For CP437 conversion: Fix the logic to properly handle conversion errors instead of silently dropping invalid characters.
-
Error messages: Consider providing more descriptive error messages in places like
clamp_size_field().
The overall direction of this PR is excellent for improving code safety, but the critical issues need to be resolved before merging.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
src/read.rs
Outdated
| pub fn data_start(&self) -> Option<u64> { | ||
| Some(*self.data.data_start.get()?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛑 Breaking API Change: Changing data_start() from returning u64 to Option<u64> is a breaking change that will cause compilation failures for existing users of this public API.
This method is part of the public API and changing its return type requires a major version bump. Consider deprecating the old method and adding a new one with a different name, or document this as a breaking change in the changelog.
Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com> Signed-off-by: n4n5 <git@n4n5.dev>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request does a great job of improving code safety and readability by removing unwrap() calls and enforcing stricter clippy lints. The changes are well-executed across the codebase. I've found a couple of remaining unwrap() calls that were likely missed and a minor inconsistency with the new casting style. Addressing these will fully align the code with the goals of this PR.
Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com> Signed-off-by: n4n5 <git@n4n5.dev>
|
I'm still working on it until all tests pass Just note that this cannot be inside the |
|
If successful, this is mergeable note: need a bump to 7.3.0 (the Cargo.toml is already modified for the CI to pass) |
fix: make create safer and more readable
Less
#[cfg(feature...)]for the importsEnforce no unwrap with clippy lints