Skip to content

Remove warning suppressions and clean up dead code#12

Closed
Copilot wants to merge 5 commits into
mainfrom
copilot/remove-allow-dead-code-suppressions
Closed

Remove warning suppressions and clean up dead code#12
Copilot wants to merge 5 commits into
mainfrom
copilot/remove-allow-dead-code-suppressions

Conversation

Copilot AI commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

The codebase contained 25+ #[allow(dead_code)] and #[allow(unused_imports)] attributes suppressing compiler warnings. This hides useful signals and makes the code harder to maintain.

Changes

Deleted dead code:

  • Removed unused DEFAULT_ADMIN_ROLE constant

Commented out preserved code:

  • API struct fields (logo_url, os_compatibility, id, url, created_at, decompress, last_restored_at, is_instance_deleted, region_id) - preserved for future features
  • Unused API functions (get_iso, delete_iso, get_image, delete_image, get_backup_profile, update_backup_profile, delete_backup_profile) - preserved for future use
  • Helper functions (ensure_logged_in, load_instances_for_user_wrapper) - reserved for future route guards
  • Model methods (ConfirmationAction::to_str()) - reserved for future serialization
  • Update module items (PermissionDenied variant, Channel::should_include_prerelease()) - reserved for future features
  • Unused structs (SshKeySelectionFormStep7) - reserved for future wizard steps
  • Pagination fields in templates and API structs - reserved for future pagination UI

Removed incorrect suppressions:

  • Update module: Platform, Asset, and Error handling code that is actively used
  • Services: get_instance_for_action called by check_instance_block
  • GitHub Release: Both prerelease and assets fields consumed by update logic

Retained suppressions (2):

  • BaseTemplate trait: #[allow(dead_code)] - used by impl_base_template! macro (compiler can't detect macro usage)
  • PermissionsExt import: #[allow(unused_imports)] in #[cfg(unix)] block - compiler doesn't detect trait usage within conditional compilation

Result

Achieved zero compile-time warnings by commenting out all preserved items instead of suppressing warnings. All unused code is clearly marked with inline comments explaining why it's preserved. The build completes cleanly in both debug and release modes with no warnings.

Original prompt

Remove #[allow(dead_code)] suppressions and clean up unused/redundant properties

Problem

The codebase contains multiple #[allow(dead_code)] and #[allow(unused_imports)] attributes that suppress compiler warnings rather than properly addressing the underlying issues. This is not a good practice as it:

  1. Hides potentially useful compiler warnings
  2. Makes the code harder to maintain
  3. Keeps dead/unused code in the codebase
  4. May indicate misalignment with the actual API schema

OpenAPI Schema Reference

The API schema has been provided in openapi.json and defines the actual structure of API responses. Properties in the Rust structs should align with this schema.

Files to Fix

1. src/config.rs

  • Issue: DEFAULT_ADMIN_ROLE constant is marked with #[allow(dead_code)] but is never used
  • Fix: Remove this constant entirely or document why it's kept for future use

2. src/api/applications.rs

  • Issue: Application struct has logo_url and os_compatibility fields marked with #[allow(dead_code)]
  • Analysis: According to the OpenAPI schema (ApplicationSchema), these fields exist in the API response:
    • logoUrl maps to logo_url
    • osList maps to os_compatibility
  • Fix: These fields ARE actually part of the API response, so they should remain in the struct. However, since they're not currently used in the UI, either:
    • Remove the #[allow(dead_code)] and actually use them in the display logic, OR
    • Document why they're preserved (for future use), OR
    • Remove them if they're truly not needed

3. src/api/iso.rs

  • Issue: IsoView struct has created_at field marked with #[allow(dead_code)]
  • Analysis: According to OpenAPI schema, ISOs don't have a documented createdAt field in the main schema
  • Fix: Remove this field entirely or verify it exists in actual API responses

4. src/api/images.rs

  • Issue: ImageView struct has decompress and created_at fields marked with #[allow(dead_code)]
  • Analysis: These fields are not documented in the OpenAPI schema
  • Fix: Remove these fields or verify they exist in actual API responses and document them

5. src/api/backups.rs

  • Issue: BackupProfileView struct has created_at field marked with #[allow(dead_code)]
  • Fix: Remove this field or use it in display logic

6. src/update/mod.rs

  • Issue: Multiple #[allow(unused_imports)] suppressions
  • Fix: Either use these imports or remove them:
    #[allow(unused_imports)]
    pub use platform::Platform;
    #[allow(unused_imports)]
    pub use asset::{Asset, parse_asset_name, select_asset_for_platform};

7. src/update/error.rs

  • Issue: UpdateError enum variants marked with #[allow(dead_code)]:
    • NoAssetFound
    • UnsupportedPlatform
    • PermissionDenied
  • Fix: These are part of an error enum and may be used in future error handling. Either remove them if they're truly never used, or keep them documented as "reserved for future use"

8. src/update/channel.rs

  • Issue: Channel::should_include_prerelease() method marked with #[allow(dead_code)]
  • Fix: Either use this method in the update logic or remove it

9. src/update/asset.rs

  • Issue: Functions marked with #[allow(dead_code)]:
    • parse_asset_name()
    • select_asset_for_platform()
  • Fix: These appear to be utility functions for the update feature. Either use them or remove them

10. src/update/platform.rs

  • Issue: Entire Platform struct and its implementation marked with #[allow(dead_code)]
  • Fix: This is core update functionality. Either complete the update feature implementation or remove dead update code

11. src/templates/base_template.rs

  • Issue: BaseTemplate trait marked with #[allow(dead_code)] with comment "Used by impl_base_template! macro, but compiler doesn't detect it"
  • Fix: This is actually used by the macro system, so the allow is justified. However, add a more detailed comment explaining why this is necessary

12. src/models/confirmation.rs

  • Issue: ConfirmationAction::to_str() method marked with #[allow(dead_code)]
  • Fix: Either use this method for serialization or remove it (use derive serialize instead)

13. src/handlers/helpers.rs

  • Issue: ensure_logged_in() function marked with #[allow(dead_code)]
  • Fix: Either use this function in route guards or remove it

Action Items

For each file above:

  1. Remove the #[allow(dead_code)] or #[allow(unused_imports)] attribute
  2. Choose one of the following:
    • Use it: If the code should be used, integrate it into the application
    • Remove it: If the code is truly dead, delete it entirely
    • Document it: If keeping for future use, add clear documentation explaining why

Testing

After making changes:

  1. Run cargo build to ensure no compilation errors
  2. Run cargo clippy to check for warnings
  3. Run exist...

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Remove #[allow(dead_code)] suppressions and clean up properties Remove warning suppressions and clean up dead code Jan 22, 2026
Copilot AI requested a review from tayyebi January 22, 2026 12:54
@tayyebi

tayyebi commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

@copilot compile it and ensure there are no warnings.

@tayyebi

tayyebi commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

@copilot if there is a preseved line, comment out the line itself instead of adding another line of comment to say it is preseved! we dont want compile-time warnings.

Copilot AI commented Jan 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot if there is a preseved line, comment out the line itself instead of adding another line of comment to say it is preseved! we dont want compile-time warnings.

Done. All preserved items are now commented out instead of documented. The build completes with zero warnings. Commit: bf71c0c

@tayyebi tayyebi marked this pull request as ready for review January 22, 2026 14:04
@tayyebi

tayyebi commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

@copilot check conflicts.

Copilot stopped work on behalf of tayyebi due to an error January 22, 2026 14:05
@tayyebi tayyebi closed this Jan 22, 2026
@tayyebi tayyebi deleted the copilot/remove-allow-dead-code-suppressions branch January 24, 2026 11:36
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