Skip to content

Remove all unnecessary #[allow(...)] annotations and fix underlying issues#52

Merged
leszek3737 merged 3 commits into
mainfrom
fix/lint
May 19, 2026
Merged

Remove all unnecessary #[allow(...)] annotations and fix underlying issues#52
leszek3737 merged 3 commits into
mainfrom
fix/lint

Conversation

@leszek3737

@leszek3737 leszek3737 commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

This PR removes suppression annotations across 19 files by either deleting dead #[allow(...)] attributes or fixing the underlying lint issues they were masking.

  • Annotation-to-fix conversions: #[allow(dead_code)] on test-only items becomes #[cfg(test)] (file_ops.rs, natsort.rs); #[allow(clippy::field_reassign_with_default)] in tests becomes struct-update syntax; #[allow(clippy::unwrap_used)] in watcher.rs becomes a let-else; deprecated Theme::DIRECTORY-style constants in theme.rs are replaced with Theme::directory() accessors.
  • Function extraction to satisfy too_many_lines: Large functions in directory_tree.rs, menu_actions.rs, mouse.rs, search.rs, ui/dir_tree.rs, and viewer.rs are split into focused helpers; context structs (MousePosition, FileSearchContext, ContentSearchContext) replace long argument lists.
  • Pass-by-reference fixes: cancel: Option<Arc<AtomicBool>> and ProgressSnapshot in batch.rs are now taken by reference, with all call-sites updated accordingly.

Confidence Score: 4/5

Safe to merge — all changes are lint clean-up or equivalent refactors with no functional impact on production paths.

The two style observations (unreachable error branch in watcher.rs and partial MousePosition adoption in mouse.rs) are cosmetic and cannot affect runtime behavior. The apply_metadata and natsort cfg(test) gates are consistent with their callers, and the extracted helpers preserve original logic exactly.

src/fs/watcher.rs (unreachable let-else error branch) and src/input/mouse.rs (two functions not yet migrated to &MousePosition) are worth a quick glance, but neither poses a correctness risk.

Important Files Changed

Filename Overview
src/fs/watcher.rs Replaces unwrap() in create_fallback with a let-else that returns Err. The error branch is logically unreachable.
src/input/mouse.rs Introduces MousePosition context struct. handle_mouse_menu_bar and handle_mouse_menu_dropdown were not updated, leaving a minor inconsistency.
src/input/menu_actions.rs Splits the large execute_menu_action into four helpers. All original MenuAction variants are accounted for.
src/ops/batch.rs Changes cancel and ProgressSnapshot to be passed by reference. All call-sites updated consistently.
src/ops/file_ops.rs Converts #[allow(dead_code)] on five test-only functions to #[cfg(test)]. No production path affected.
src/ops/natsort.rs Gates natsort and helpers with #[cfg(test)]. Production natsort_key is unaffected.
src/ui/dir_tree.rs Extracts render_tree_entries but recomputes visible_height and has_scrollbar redundantly inside the helper.
src/ui/viewer.rs Extracts push_match_segments to deduplicate the hex-search match-segment loop. Logic is identical to both originals.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[execute_menu_action] --> B{MenuAction type}
    B -->|ToggleListingMode CycleSortOrder OpenFilter ResetPanelFilter TogglePermissions| C[execute_panel_config_action]
    B -->|DirectoryTree FindFile CompareDirs History Hotlist CommandLine| D[execute_nav_action]
    B -->|Rename Chmod| E[execute_dialog_action]
    B -->|ViewFile EditFile Copy Move MakeDir Delete RefreshPanel ToggleHidden| F[Return KeyCode]
    B -->|SwapPanels SwitchPanels SaveSetup Quit OpenUserMenu| G[Inline handler]
    C --> H[Option result]
    D --> H
    E --> H
    F --> H
    G --> H
Loading

…ssues

Remove dead annotations where lint would not fire (too_many_lines on
functions well under 100 lines, unwrap_used with zero unwrap calls).
Replace #[allow(dead_code)] with #[cfg(test)] for test-only functions.
Extract helpers to resolve too_many_lines. Introduce context structs
for too_many_arguments. Take parameters by reference for
needless_pass_by_value. Migrate deprecated Theme constants to new API.
Replace panic! with assert!, unwrap with let-else pattern, and fix
field_reassign_with_default in test code.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @leszek3737, you have reached your weekly rate limit of 1500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

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 refactors the codebase to eliminate various Clippy lint suppressions, specifically targeting too_many_lines, too_many_arguments, and unwrap_used. Key changes include extracting logic into helper functions in directory_tree.rs and menu_actions.rs, introducing a MousePosition struct in mouse.rs, and utilizing context structs in search.rs. Additionally, several instances of #[allow(dead_code)] were replaced with #[cfg(test)]. Reviewer feedback suggests further streamlining job_runner.rs by removing an unnecessary intermediate variable, grouping the excessive arguments in process_batch_entry into a state struct to fully satisfy the PR's objectives, and restoring a maintainability comment regarding UTF-8 logic in viewer.rs.

Comment thread src/app/job_runner.rs Outdated
Comment thread src/ops/batch.rs Outdated
Comment thread src/ui/viewer.rs
Comment thread src/fs/watcher.rs
Comment thread src/input/mouse.rs Outdated
Comment thread src/ui/dir_tree.rs
@leszek3737
leszek3737 merged commit 38f17b5 into main May 19, 2026
5 checks passed
@leszek3737
leszek3737 deleted the fix/lint branch May 19, 2026 12:50
Repository owner deleted a comment from greptile-apps Bot May 19, 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.

1 participant