Skip to content

Add a check for unused private declarations - #8

Merged
IntegratedQuantum merged 8 commits into
PixelGuys:masterfrom
IntegratedQuantum:unused_declarations
Jul 19, 2026
Merged

IntegratedQuantum merged 8 commits into
PixelGuys:masterfrom
IntegratedQuantum:unused_declarations

Conversation

@IntegratedQuantum

@IntegratedQuantum IntegratedQuantum commented May 30, 2026 •

Copy link
Copy Markdown
Member

I see many PRs that eventually generate an unused container-level variable or function somewhere.
This does however have the (possibly annoying) side effect of having to clean up the import section.

  • ignore imports (until there is better IDE support, it would be rather annoying to deal with unused imports)
  • Also check declarations inside of structs
  • Fix false positives
  • Also check functions
  • fix these in the game

fixes #17

Comment thread src/rules/unused_local_variables.zig Outdated
Comment thread src/rules/unused_local_variables.zig Outdated
Comment thread src/main.zig
@Wunka Wunka mentioned this pull request May 31, 2026
Comment thread src/rules/unused_private_decls.zig Outdated
Comment on lines +11 to +12
identifiers.put(main.allocator, "std", {}) catch @panic("OOM");
identifiers.put(main.allocator, "main", {}) catch @panic("OOM");

@Wunka Wunka Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
identifiers.put(main.allocator, "std", {}) catch @panic("OOM");
identifiers.put(main.allocator, "main", {}) catch @panic("OOM");

Without this, this also works.
Else you would have to add every import we ever do. Like c etc

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, now that I ignore all imports anyways this is no longer needed

@IntegratedQuantum
IntegratedQuantum requested a review from Wunka July 19, 2026 11:52
IntegratedQuantum added a commit to PixelGuys/Cubyz that referenced this pull request Jul 19, 2026
@IntegratedQuantum
IntegratedQuantum merged commit 1b315c9 into PixelGuys:master Jul 19, 2026
1 check passed
@IntegratedQuantum
IntegratedQuantum deleted the unused_declarations branch July 19, 2026 11:54
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.

Add check for unused functions, constants

2 participants