Skip to content

feat: document zip flags as enum#639

Merged
Pr0methean merged 7 commits intomasterfrom
document-flags
Feb 14, 2026
Merged

feat: document zip flags as enum#639
Pr0methean merged 7 commits intomasterfrom
document-flags

Conversation

@Its-Just-Nans
Copy link
Copy Markdown
Member

feat: document flags as enum

The best approach would be to use bitflags but it would be a breaking change

The best approach would be to use bitflags but it would be a breaking change
@Its-Just-Nans Its-Just-Nans self-assigned this Feb 7, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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 focuses on enhancing the clarity and maintainability of the codebase by formalizing the representation of ZIP archive flags. It introduces a dedicated enum to replace hardcoded bitwise operations, making the intent of flag manipulations more explicit. The changes also include minor code style refinements and updated linting configurations to ensure better code quality.

Highlights

  • New Flags Enum for ZIP Flags: Introduced a Flags enum in src/spec.rs to explicitly define and document various ZIP archive flags, replacing previous magic number usage.
  • Refactored Flag Handling: Updated flag checks and assignments across src/read.rs and src/types.rs to leverage the new Flags enum, significantly improving code readability and maintainability.
  • Code Style and Linting Improvements: Added new Clippy lints (decimal_literal_representation, multiple_crate_versions) and converted some decimal literals to hexadecimal in src/write.rs test cases for consistency and clarity.
Changelog
  • src/lib.rs
    • Added clippy::decimal_literal_representation to the allow list.
    • Added clippy::multiple_crate_versions to the warn list.
  • src/read.rs
    • Imported the new Flags enum from crate::spec.
    • Replaced direct bitwise operations with Flags enum variants for encrypted, is_utf8, and using_data_descriptor checks.
  • src/spec.rs
    • Introduced the Flags enum with #[repr(u16)] to define various ZIP flags, each with a descriptive name and binary literal value.
    • Added documentation comments for each flag explaining its purpose.
  • src/types.rs
    • Imported the Flags enum from crate::spec.
    • Modified the is_leap_year function to use the is_multiple_of method for improved readability.
    • Updated flag checks within ZipFileData methods to use Flags enum variants for encrypted, using_data_descriptor, and is_utf8.
  • src/write.rs
    • Converted several decimal integer literals (e.g., 65535, 65521) to their hexadecimal equivalents (e.g., 0xFFFF, 0xFFF1) in test cases for alignment and compression_method.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

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

Summary

This PR introduces a Flags enum to document ZIP file flags, improving code readability. However, there is a critical logic error in src/types.rs at line 806 that will cause all files to be incorrectly identified as using data descriptors, which will break ZIP file reading functionality.

Critical Issues

  1. Logic Error (line 806, src/types.rs): The comparison flags & (Flags::UsingDataDescriptor as u16) == 1 << 3 is incorrect. It compares the masked value (which equals 8) with 8, resulting in true for all files regardless of whether the flag is actually set. This must be changed to != 0.

Minor Issues

  1. Typo (line 75, src/spec.rs): "sett" should be "set" in the documentation comment.

The rest of the changes appropriately replace magic numbers with named enum values, which improves code maintainability.


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.

Comment thread src/types.rs Outdated
Comment thread src/spec.rs Outdated
Its-Just-Nans and others added 2 commits February 7, 2026 18:03
Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com>
Signed-off-by: n4n5 <[email protected]>
Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com>
Signed-off-by: n4n5 <[email protected]>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 introduces a Flags enum to replace magic numbers for ZIP flags, which significantly improves code readability and maintainability. The changes also include enabling new clippy lints and using more idiomatic Rust code in a few places. Overall, this is a solid improvement. I've kept the suggestion to make the flag checking logic more consistent across the codebase, as it aligns with improving code clarity through explicit bitwise operations.

Comment thread src/types.rs Outdated
@Pr0methean Pr0methean added this to the 8.0.0 milestone Feb 12, 2026
Pr0methean
Pr0methean previously approved these changes Feb 12, 2026
@Pr0methean Pr0methean added this pull request to the merge queue Feb 12, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 12, 2026
@Pr0methean Pr0methean enabled auto-merge February 12, 2026 03:49
@Pr0methean Pr0methean added this pull request to the merge queue Feb 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Feb 13, 2026
@Pr0methean Pr0methean added this pull request to the merge queue Feb 14, 2026
Merged via the queue into master with commit 8b8c20f Feb 14, 2026
129 checks passed
@Pr0methean Pr0methean deleted the document-flags branch February 14, 2026 04:50
@Pr0methean Pr0methean mentioned this pull request Feb 13, 2026
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