Skip to content

chore(lint): enable forcetypeassert#298

Merged
kmannislands merged 3 commits intomainfrom
chore-lint-forcetypeassert
Feb 4, 2026
Merged

chore(lint): enable forcetypeassert#298
kmannislands merged 3 commits intomainfrom
chore-lint-forcetypeassert

Conversation

@janishorsts
Copy link
Collaborator

No description provided.

@janishorsts janishorsts self-assigned this Jan 27, 2026
@janishorsts janishorsts requested a review from a team as a code owner January 27, 2026 23:54
@janishorsts janishorsts requested review from kmannislands and removed request for a team January 27, 2026 23:54
@github-actions
Copy link

github-actions bot commented Jan 27, 2026

➖ Are we earthbuild yet?

No change in "earthly" occurrences

📈 Overall Progress

Branch Total Count
main 5704
This PR 5704
Difference +0

Keep up the great work migrating from Earthly to Earthbuild! 🚀

💡 Tips for finding more occurrences

Run locally to see detailed breakdown:

./.github/scripts/count-earthly.sh

Note that the goal is not to reach 0.
There is anticipated to be at least some occurences of earthly in the source code due to backwards compatibility with config files and language constructs.

@gemini-code-assist
Copy link

Summary of Changes

Hello @janishorsts, 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 reliability of the codebase by enabling the forcetypeassert linter and systematically refactoring type assertions. The changes ensure that type conversions are handled safely with explicit error checks, preventing unexpected runtime panics and providing clearer error messages. This effort contributes to a more stable and maintainable application.

Highlights

  • Linter Configuration Update: The forcetypeassert linter has been enabled in the .golangci.yaml configuration, enforcing stricter type assertion checks across the codebase.
  • Enhanced Type Assertion Safety: Numerous direct type assertions (e.g., value.(Type)) have been refactored to include ok checks (e.g., value, ok := value.(Type); if !ok { ... }). This change improves runtime safety by converting potential panics into explicit error conditions with informative messages.
  • Simplified Error Hinting Logic: The getHintErr function's return signature and usage have been simplified, removing a redundant boolean return value and directly returning *hint.Error or nil.
  • Improved Constant Parsing: The variables/reserved/names_test.go file now uses //go:embed to load source code and includes more robust type checks during constant parsing.
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

@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 enables the forcetypeassert linter and applies the necessary fixes across the codebase. The changes systematically replace unsafe type assertions with safe ones, primarily using the two-value value, ok := ... pattern to handle potential type mismatches gracefully and prevent panics. In some cases where a zero value is an acceptable fallback, the value, _ := ... pattern is used. Additionally, there are some related refactorings, such as in util/hint/hinterror.go to improve the API and avoid type assertions in calling code, and in variables/reserved/names_test.go to use go:embed for more robust testing. All changes are correct and significantly improve the code's robustness. The pull request is well-executed and ready to be merged.

@janishorsts janishorsts requested a review from gilescope January 29, 2026 15:32
@kmannislands kmannislands merged commit d05e1d5 into main Feb 4, 2026
88 checks passed
@kmannislands kmannislands deleted the chore-lint-forcetypeassert branch February 4, 2026 17:10
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