Skip to content

Improvements flagged by gopls' modernize#543

Merged
frenck merged 3 commits into
home-assistant:masterfrom
scop:refactor/modernize
Feb 28, 2025
Merged

Improvements flagged by gopls' modernize#543
frenck merged 3 commits into
home-assistant:masterfrom
scop:refactor/modernize

Conversation

@scop
Copy link
Copy Markdown
Member

@scop scop commented Feb 27, 2025

Here's a set of improvements flagged by gopls' modernize, curated a bit.

See individual commits for details.

Summary by CodeRabbit

  • Refactor
    • Modernized internal type declarations and variable initializations for improved flexibility and maintainability.
    • Streamlined iteration and string handling in the spinner module to enhance code clarity and efficiency.

These updates keep the underlying logic intact while aligning the code with modern Go conventions, ensuring consistent behavior for all functionalities.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 27, 2025

📝 Walkthrough

Walkthrough

The changes consist of replacing Go’s generic empty interface usage with its alias any across the codebase. Function parameters, variable declarations, type assertions, and struct fields have been updated from using interface{} (and []interface{}) to any (and []any) in both client and command modules. Additionally, minor refactorings have been applied in the spinner code to simplify loop iterations and string construction.

Changes

File(s) Change Summary
client/client.go Updated function signatures to change the body parameter from map[string]interface{} to map[string]any.
client/helper.go Modified the Response struct’s Data field from map[string]interface{} to map[string]any.
cmd/{addons*.go, audio*.go, backups*.go, banner.go, cli_update.go, core*.go, dns*.go, docker_registries_delete.go, host*.go, jobs_options.go, mounts*.go, multicast_update.go, network*.go, observer_update.go, os*.go, resolution*.go, security_options.go, store*.go, supervisor*.go} Bulk updates in command modules: revised variable declarations, function parameters, and type assertions from map[string]interface{} to map[string]any and from []interface{} to []any for broader type flexibility.
spinner/spinner.go Refactored loop iteration in the Start method (using a range loop) and optimized the string clearing in erase with strings.Repeat.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2fced2 and 0351e43.

📒 Files selected for processing (59)
  • client/client.go (2 hunks)
  • client/helper.go (1 hunks)
  • cmd/addons.go (1 hunks)
  • cmd/addons_uninstall.go (1 hunks)
  • cmd/addons_update.go (1 hunks)
  • cmd/audio_default_input.go (1 hunks)
  • cmd/audio_default_output.go (1 hunks)
  • cmd/audio_profile.go (1 hunks)
  • cmd/audio_update.go (1 hunks)
  • cmd/audio_volume_input.go (1 hunks)
  • cmd/audio_volume_output.go (1 hunks)
  • cmd/auth_reset.go (1 hunks)
  • cmd/backups.go (2 hunks)
  • cmd/backups_freeze.go (1 hunks)
  • cmd/backups_new.go (1 hunks)
  • cmd/backups_options.go (1 hunks)
  • cmd/backups_remove.go (1 hunks)
  • cmd/backups_restore.go (1 hunks)
  • cmd/banner.go (4 hunks)
  • cmd/cli_update.go (1 hunks)
  • cmd/core_options.go (1 hunks)
  • cmd/core_rebuild.go (1 hunks)
  • cmd/core_restart.go (1 hunks)
  • cmd/core_stop.go (1 hunks)
  • cmd/core_update.go (1 hunks)
  • cmd/dns_options.go (1 hunks)
  • cmd/dns_update.go (1 hunks)
  • cmd/docker_registries_delete.go (1 hunks)
  • cmd/host_logs_boots.go (1 hunks)
  • cmd/host_options.go (1 hunks)
  • cmd/host_reboot.go (1 hunks)
  • cmd/host_shutdown.go (1 hunks)
  • cmd/jobs_options.go (1 hunks)
  • cmd/mounts.go (2 hunks)
  • cmd/mounts_add.go (1 hunks)
  • cmd/mounts_options.go (1 hunks)
  • cmd/mounts_update.go (1 hunks)
  • cmd/multicast_update.go (1 hunks)
  • cmd/network.go (1 hunks)
  • cmd/network_update.go (4 hunks)
  • cmd/network_vlan.go (1 hunks)
  • cmd/observer_update.go (1 hunks)
  • cmd/os.go (2 hunks)
  • cmd/os_boards_green_options.go (1 hunks)
  • cmd/os_boards_yellow_options.go (1 hunks)
  • cmd/os_boot_slot.go (2 hunks)
  • cmd/os_datadisk_move.go (1 hunks)
  • cmd/os_update.go (1 hunks)
  • cmd/resolution_check.go (1 hunks)
  • cmd/resolution_check_options.go (1 hunks)
  • cmd/resolution_issue.go (1 hunks)
  • cmd/resolution_suggestion.go (1 hunks)
  • cmd/security_options.go (1 hunks)
  • cmd/store_addons.go (1 hunks)
  • cmd/store_addons_update.go (1 hunks)
  • cmd/store_repositories_delete.go (1 hunks)
  • cmd/supervisor_options.go (1 hunks)
  • cmd/supervisor_update.go (1 hunks)
  • spinner/spinner.go (3 hunks)
✅ Files skipped from review due to trivial changes (17)
  • cmd/backups_new.go
  • cmd/audio_profile.go
  • cmd/core_restart.go
  • cmd/backups_freeze.go
  • cmd/core_rebuild.go
  • cmd/security_options.go
  • cmd/mounts_options.go
  • cmd/host_reboot.go
  • cmd/core_stop.go
  • cmd/audio_volume_output.go
  • cmd/supervisor_update.go
  • cmd/os_boards_yellow_options.go
  • cmd/addons_uninstall.go
  • cmd/host_shutdown.go
  • cmd/core_options.go
  • cmd/audio_update.go
  • cmd/supervisor_options.go
🧰 Additional context used
📓 Path-based instructions (6)
`*/**(html|markdown|md)`: - For instructional content in doc...

*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
  • cmd/audio_volume_input.go
  • cmd/auth_reset.go
  • cmd/dns_options.go
  • cmd/core_update.go
  • cmd/network_vlan.go
  • cmd/jobs_options.go
  • cmd/store_addons.go
  • cmd/os_datadisk_move.go
  • cmd/addons_update.go
  • cmd/resolution_check_options.go
  • cmd/resolution_suggestion.go
  • cmd/audio_default_input.go
  • cmd/backups_options.go
  • cmd/mounts_update.go
  • client/helper.go
  • cmd/audio_default_output.go
  • cmd/resolution_check.go
  • cmd/host_options.go
  • cmd/multicast_update.go
  • cmd/os_boards_green_options.go
  • cmd/host_logs_boots.go
  • cmd/network.go
  • cmd/cli_update.go
  • cmd/os_update.go
  • cmd/store_repositories_delete.go
  • cmd/observer_update.go
  • cmd/backups.go
  • cmd/resolution_issue.go
  • cmd/addons.go
  • cmd/mounts_add.go
  • cmd/os.go
  • cmd/docker_registries_delete.go
  • spinner/spinner.go
  • cmd/store_addons_update.go
  • cmd/backups_restore.go
  • cmd/mounts.go
  • client/client.go
  • cmd/backups_remove.go
  • cmd/banner.go
  • cmd/dns_update.go
  • cmd/network_update.go
  • cmd/os_boot_slot.go
`*/**(html|markdown|md)`: - Use bold to mark UI strings. - I...

*/**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.
  • cmd/audio_volume_input.go
  • cmd/auth_reset.go
  • cmd/dns_options.go
  • cmd/core_update.go
  • cmd/network_vlan.go
  • cmd/jobs_options.go
  • cmd/store_addons.go
  • cmd/os_datadisk_move.go
  • cmd/addons_update.go
  • cmd/resolution_check_options.go
  • cmd/resolution_suggestion.go
  • cmd/audio_default_input.go
  • cmd/backups_options.go
  • cmd/mounts_update.go
  • client/helper.go
  • cmd/audio_default_output.go
  • cmd/resolution_check.go
  • cmd/host_options.go
  • cmd/multicast_update.go
  • cmd/os_boards_green_options.go
  • cmd/host_logs_boots.go
  • cmd/network.go
  • cmd/cli_update.go
  • cmd/os_update.go
  • cmd/store_repositories_delete.go
  • cmd/observer_update.go
  • cmd/backups.go
  • cmd/resolution_issue.go
  • cmd/addons.go
  • cmd/mounts_add.go
  • cmd/os.go
  • cmd/docker_registries_delete.go
  • spinner/spinner.go
  • cmd/store_addons_update.go
  • cmd/backups_restore.go
  • cmd/mounts.go
  • client/client.go
  • cmd/backups_remove.go
  • cmd/banner.go
  • cmd/dns_update.go
  • cmd/network_update.go
  • cmd/os_boot_slot.go
`*/**(html|markdown|md)`: - Be brief in your replies and don...

*/**(html|markdown|md): - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

  • cmd/audio_volume_input.go
  • cmd/auth_reset.go
  • cmd/dns_options.go
  • cmd/core_update.go
  • cmd/network_vlan.go
  • cmd/jobs_options.go
  • cmd/store_addons.go
  • cmd/os_datadisk_move.go
  • cmd/addons_update.go
  • cmd/resolution_check_options.go
  • cmd/resolution_suggestion.go
  • cmd/audio_default_input.go
  • cmd/backups_options.go
  • cmd/mounts_update.go
  • client/helper.go
  • cmd/audio_default_output.go
  • cmd/resolution_check.go
  • cmd/host_options.go
  • cmd/multicast_update.go
  • cmd/os_boards_green_options.go
  • cmd/host_logs_boots.go
  • cmd/network.go
  • cmd/cli_update.go
  • cmd/os_update.go
  • cmd/store_repositories_delete.go
  • cmd/observer_update.go
  • cmd/backups.go
  • cmd/resolution_issue.go
  • cmd/addons.go
  • cmd/mounts_add.go
  • cmd/os.go
  • cmd/docker_registries_delete.go
  • spinner/spinner.go
  • cmd/store_addons_update.go
  • cmd/backups_restore.go
  • cmd/mounts.go
  • client/client.go
  • cmd/backups_remove.go
  • cmd/banner.go
  • cmd/dns_update.go
  • cmd/network_update.go
  • cmd/os_boot_slot.go
`*/**(html|markdown|md)`: - Use sentence-style capitalizatio...

*/**(html|markdown|md): - Use sentence-style capitalization also in headings.

  • cmd/audio_volume_input.go
  • cmd/auth_reset.go
  • cmd/dns_options.go
  • cmd/core_update.go
  • cmd/network_vlan.go
  • cmd/jobs_options.go
  • cmd/store_addons.go
  • cmd/os_datadisk_move.go
  • cmd/addons_update.go
  • cmd/resolution_check_options.go
  • cmd/resolution_suggestion.go
  • cmd/audio_default_input.go
  • cmd/backups_options.go
  • cmd/mounts_update.go
  • client/helper.go
  • cmd/audio_default_output.go
  • cmd/resolution_check.go
  • cmd/host_options.go
  • cmd/multicast_update.go
  • cmd/os_boards_green_options.go
  • cmd/host_logs_boots.go
  • cmd/network.go
  • cmd/cli_update.go
  • cmd/os_update.go
  • cmd/store_repositories_delete.go
  • cmd/observer_update.go
  • cmd/backups.go
  • cmd/resolution_issue.go
  • cmd/addons.go
  • cmd/mounts_add.go
  • cmd/os.go
  • cmd/docker_registries_delete.go
  • spinner/spinner.go
  • cmd/store_addons_update.go
  • cmd/backups_restore.go
  • cmd/mounts.go
  • client/client.go
  • cmd/backups_remove.go
  • cmd/banner.go
  • cmd/dns_update.go
  • cmd/network_update.go
  • cmd/os_boot_slot.go
`*/**(html|markdown|md)`: do not comment on HTML used for ic...

*/**(html|markdown|md): do not comment on HTML used for icons

  • cmd/audio_volume_input.go
  • cmd/auth_reset.go
  • cmd/dns_options.go
  • cmd/core_update.go
  • cmd/network_vlan.go
  • cmd/jobs_options.go
  • cmd/store_addons.go
  • cmd/os_datadisk_move.go
  • cmd/addons_update.go
  • cmd/resolution_check_options.go
  • cmd/resolution_suggestion.go
  • cmd/audio_default_input.go
  • cmd/backups_options.go
  • cmd/mounts_update.go
  • client/helper.go
  • cmd/audio_default_output.go
  • cmd/resolution_check.go
  • cmd/host_options.go
  • cmd/multicast_update.go
  • cmd/os_boards_green_options.go
  • cmd/host_logs_boots.go
  • cmd/network.go
  • cmd/cli_update.go
  • cmd/os_update.go
  • cmd/store_repositories_delete.go
  • cmd/observer_update.go
  • cmd/backups.go
  • cmd/resolution_issue.go
  • cmd/addons.go
  • cmd/mounts_add.go
  • cmd/os.go
  • cmd/docker_registries_delete.go
  • spinner/spinner.go
  • cmd/store_addons_update.go
  • cmd/backups_restore.go
  • cmd/mounts.go
  • client/client.go
  • cmd/backups_remove.go
  • cmd/banner.go
  • cmd/dns_update.go
  • cmd/network_update.go
  • cmd/os_boot_slot.go
`*/**(html|markdown|md)`: Avoid flagging inline HTML for emb...

*/**(html|markdown|md): Avoid flagging inline HTML for embedding videos in future reviews for this repository.

  • cmd/audio_volume_input.go
  • cmd/auth_reset.go
  • cmd/dns_options.go
  • cmd/core_update.go
  • cmd/network_vlan.go
  • cmd/jobs_options.go
  • cmd/store_addons.go
  • cmd/os_datadisk_move.go
  • cmd/addons_update.go
  • cmd/resolution_check_options.go
  • cmd/resolution_suggestion.go
  • cmd/audio_default_input.go
  • cmd/backups_options.go
  • cmd/mounts_update.go
  • client/helper.go
  • cmd/audio_default_output.go
  • cmd/resolution_check.go
  • cmd/host_options.go
  • cmd/multicast_update.go
  • cmd/os_boards_green_options.go
  • cmd/host_logs_boots.go
  • cmd/network.go
  • cmd/cli_update.go
  • cmd/os_update.go
  • cmd/store_repositories_delete.go
  • cmd/observer_update.go
  • cmd/backups.go
  • cmd/resolution_issue.go
  • cmd/addons.go
  • cmd/mounts_add.go
  • cmd/os.go
  • cmd/docker_registries_delete.go
  • spinner/spinner.go
  • cmd/store_addons_update.go
  • cmd/backups_restore.go
  • cmd/mounts.go
  • client/client.go
  • cmd/backups_remove.go
  • cmd/banner.go
  • cmd/dns_update.go
  • cmd/network_update.go
  • cmd/os_boot_slot.go
🔇 Additional comments (71)
cmd/audio_volume_input.go (1)

34-34: Great modernization improvement!

Replacing map[string]interface{} with map[string]any follows Go's modern best practices. The any type alias was introduced in Go 1.18 as a more concise and readable way to express the empty interface.

cmd/os_datadisk_move.go (1)

34-34: Well-applied modernization!

Good use of Go's any type alias instead of interface{}. This improves code readability while maintaining identical functionality.

cmd/auth_reset.go (1)

31-31: Appropriate use of modern Go syntax!

The change from interface{} to any follows Go's modern idioms and maintains the same behavior while making the code more concise.

cmd/backups_restore.go (1)

32-32: Good modernization update!

Using any instead of interface{} is a positive change that follows Go's current best practices. This makes the code more readable while keeping identical functionality.

cmd/backups_options.go (1)

29-29: Modernized map declaration using Go's any type alias

This change replaces interface{} with the more concise any type alias, which was introduced in Go 1.18 as a built-in alias for interface{}.

cmd/jobs_options.go (1)

30-30: Modernized map declaration using Go's any type alias

This change replaces interface{} with any, following modern Go conventions while maintaining identical functionality.

cmd/network_vlan.go (1)

38-38: Updated to use Go's any type alias

This change switches from interface{} to the more concise and modern any type alias introduced in Go 1.18.

cmd/dns_options.go (1)

30-30: Modernized map declaration using Go's any type alias

This change replaces interface{} with any, improving code readability while maintaining the same functionality.

cmd/docker_registries_delete.go (1)

72-72: Appropriate use of any type alias

The change from interface{} to any aligns with modern Go practices introduced in Go 1.18+. This improves code readability while maintaining identical functionality.

cmd/core_update.go (1)

29-29: Good use of any type for options map

Updating the map declaration from map[string]interface{} to map[string]any follows modern Go conventions and improves code readability while maintaining the same behavior.

cmd/backups_remove.go (1)

37-37: Consistent use of any type alias

The change from map[string]interface{} to map[string]any is consistent with modern Go conventions and aligns with the other similar updates in the codebase.

cmd/audio_default_output.go (1)

29-29: Consistent modernization of type declarations

The map type change from map[string]interface{} to map[string]any is aligned with Go's modern type system and maintains consistency with similar changes throughout the codebase.

cmd/os_boards_green_options.go (1)

29-29: Good use of Go's any type instead of interface{}.

The change from map[string]interface{} to map[string]any improves code readability while maintaining the same functionality. This aligns with modern Go practices since any was introduced as an alias for interface{}.

client/helper.go (1)

31-33: Good modernization of the Response struct.

Updating the Data field from map[string]interface{} to map[string]any aligns with modern Go practices. Since any is just an alias for interface{}, this change improves readability without changing the underlying functionality.

cmd/host_logs_boots.go (1)

56-56: Good update to type assertion using any.

The change from asserting data.Data["boots"] as map[string]interface{} to map[string]any improves code readability while maintaining the same type checking functionality.

cmd/addons_update.go (1)

48-48: Good consistent use of any type.

The change from map[string]interface{} to map[string]any for the options map maintains consistency with the other updated files while improving readability.

cmd/audio_default_input.go (1)

29-29: Type updated to use modern Go idiom

The change from map[string]interface{} to map[string]any adopts Go's modern type alias introduced in Go 1.18. This improves code readability while maintaining identical functionality.

cmd/mounts_update.go (1)

40-40: Type updated to use modern Go idiom

The change from map[string]interface{} to map[string]any adopts Go's modern type alias introduced in Go 1.18. This improves code readability while maintaining identical functionality.

cmd/mounts_add.go (1)

40-40: Type updated to use modern Go idiom

The change from map[string]interface{} to map[string]any adopts Go's modern type alias introduced in Go 1.18. This improves code readability while maintaining identical functionality.

cmd/store_addons.go (2)

53-53: Type assertion updated to use modern Go idiom

The change from .([]interface{}) to .([]any) adopts Go's modern type alias introduced in Go 1.18. This improves code readability while maintaining identical functionality.


55-56: Variable type and type assertion updated to use modern Go idiom

The changes from map[string]interface{} to map[string]any adopt Go's modern type alias introduced in Go 1.18. This improves code readability while maintaining identical functionality.

cmd/resolution_check_options.go (1)

27-27: Modernization improvement: Using any type alias

This change replaces interface{} with the any type alias introduced in Go 1.18, resulting in more concise and readable code while maintaining the same functionality.

cmd/os_update.go (1)

31-31: Appropriate use of any type alias

The change from interface{} to any is a good modernization that follows current Go best practices. Both the variable declaration and map initialization are consistently updated to use the same type.

Also applies to: 35-35

cmd/store_addons_update.go (1)

48-48: Good modernization with any type

Converting from make(map[string]interface{}) to make(map[string]any) aligns with modern Go standards introduced in Go 1.18+. This improves code readability without changing functionality.

cmd/dns_update.go (1)

30-30: Proper implementation of any type alias

Both the variable declaration and map initialization are consistently updated to use the any type alias, following modern Go conventions. This is a good improvement that makes the code more concise.

Also applies to: 34-34

cmd/cli_update.go (2)

30-30: Type modernization looks good.

The change from map[string]interface{} to map[string]any aligns with Go's modern type conventions introduced in Go 1.18.


34-34: Type declaration update is consistent.

The map initialization has been correctly updated to match the variable declaration change, maintaining consistency.

cmd/resolution_suggestion.go (2)

35-35: Type assertion modernization is correct.

The change from .([]interface{}) to .([]any) maintains the same functionality while adopting Go's newer type alias.


37-38: Type updates are properly applied.

Both the variable declaration and subsequent type assertion have been consistently updated to use any instead of interface{}.

cmd/resolution_check.go (2)

34-34: Slice type assertion modernization looks good.

The change from data.Data["checks"].([]interface{}) to data.Data["checks"].([]any) is correct and follows modern Go conventions.


36-37: Map type declaration and assertion are properly updated.

Both the variable declaration and type assertion have been consistently updated to use any instead of interface{}.

cmd/multicast_update.go (2)

30-30: Type modernization is correctly applied.

The variable declaration has been properly updated from map[string]interface{} to map[string]any.


34-34: Map initialization is consistently updated.

The map initialization correctly uses the modern map[string]any type, matching the variable declaration.

cmd/observer_update.go (2)

30-30: Type modernization looks good

The change from map[string]interface{} to map[string]any is a good modernization. The any type was introduced in Go 1.18 as an alias for interface{}, making the code more concise while maintaining the same functionality.


34-34: Consistent type usage

Good job maintaining consistency by updating the map initialization to also use the any type. This ensures type consistency throughout the code.

cmd/os_boot_slot.go (2)

45-45: Type assertion updated correctly

The type assertion has been properly updated from map[string]interface{} to map[string]any, which aligns with Go's modern type system.


60-60: Map declaration modernized

The map declaration has been correctly updated to use any type, which is more concise than the previous interface{} type.

cmd/host_options.go (2)

28-28: Type declaration updated properly

The variable type declaration has been properly updated to use the more modern any type instead of interface{}.


32-32: Consistent map initialization

Good job consistently updating the map initialization to use the any type, maintaining type consistency throughout the code.

cmd/store_repositories_delete.go (2)

72-72: Slice type assertion modernized

The slice type assertion has been correctly updated from []interface{} to []any, which aligns with the modernization efforts in the codebase.


74-75: Map declaration and type assertion updated

Both the map variable declaration and subsequent type assertion have been properly updated to use the any type, maintaining consistency with the rest of the codebase's modernization.

cmd/network.go (1)

42-46: LGTM! Modern Go type assertions with any.

The change from interface{} to any aligns with modern Go coding practices introduced in Go 1.18 where any is an alias for interface{}. This makes the code more concise and maintainable.

spinner/spinner.go (3)

24-24: LGTM! Added required import for string operations.

Adding the strings package is necessary for using strings.Repeat function later in the code.


106-106: LGTM! Simplified loop with range-based iteration.

Changed from index-based loop to range-based loop for cleaner code while maintaining the same functionality.


168-168: LGTM! Improved string generation efficiency.

Using strings.Repeat is more efficient and readable than manually building a string with spaces in a loop.

cmd/backups.go (2)

66-69: LGTM! Adopted modern Go type assertions.

Updated from interface{} to any for type assertions, improving code readability while maintaining identical functionality.


108-111: LGTM! Consistent use of modern Go type assertions.

Consistently updated from interface{} to any in the backups location completions function, aligning with modern Go practices.

cmd/resolution_issue.go (1)

34-37: LGTM! Updated to modern Go type assertions.

The change from interface{} to any is consistent with modern Go practices and matches the pattern used throughout the codebase in this PR.

cmd/os.go (3)

39-39: LGTM: Good use of any type.

The function signature has been updated to use Go's any type (introduced in Go 1.18) instead of interface{}, which makes the code more concise while maintaining the same functionality.


47-47: LGTM: Consistent usage of any type.

Type assertion updated to use any instead of interface{}, keeping consistent with the function signature change.


64-64: LGTM: Consistent type assertion update.

This type assertion update completes the modernization of the type declarations in this file.

cmd/addons.go (2)

57-57: LGTM: Good use of any type.

Updated type assertion to use the more concise any type instead of interface{}.


59-60: LGTM: Consistent type updates.

Variable declaration and type assertion updated to use any consistently with the rest of the changes.

cmd/mounts.go (3)

54-54: LGTM: Updated function parameter type.

The function parameter type has been updated to use any instead of interface{}, which is a more modern and concise approach in Go.


93-93: LGTM: Consistent type assertion.

Updated type assertion to use any consistently with other changes in the codebase.


95-96: LGTM: Consistent variable type declarations.

Variable declaration and type assertion updated to use any instead of interface{}.

client/client.go (3)

34-34: LGTM: Updated function parameter type.

The function parameter type has been updated to use any instead of interface{}, which aligns with modern Go coding practices.


66-66: LGTM: Consistent parameter type update.

Export function signature updated to use any type consistently with internal implementation.


70-70: LGTM: Complete type update across related functions.

This completes the type updates for all related JSON request functions, ensuring consistency throughout the codebase.

cmd/network_update.go (5)

37-37: Good modernization: replaced interface{} with any

The change from map[string]interface{} to map[string]any appropriately uses Go's any type alias, making the code more concise while maintaining the same functionality.


123-124: Positive function signature update

The function signature and return type have been modernized from map[string]interface{} to map[string]any, following current Go best practices.


126-126: Good type declaration modernization

Converting var val interface{} to var val any improves code readability while maintaining identical functionality.


145-145: Appropriate parameter type update

The parameter type for options has been updated to use the more modern map[string]any syntax.


159-159: Consistent type modernization

Function parameter has been updated to use map[string]any, maintaining consistency with the other changes throughout the codebase.

cmd/banner.go (7)

28-28: Good function signature update

The return type has been modernized from *(map[string]interface{}) to *(map[string]any), improving code readability.


50-50: Proper parameter type modernization

Updating the parameter type from []interface{} to []any maintains functionality while using the more concise type alias.


80-80: Idiomatic Go loop improvement

Changed from for i := 0; i < 60; i++ to for i := range 60, which is a more idiomatic way to iterate a specific number of times in Go when the counter value is only used for the first iteration check.


88-88: Consistent type assertion update

Type assertion updated from netifaces.([]interface{}) to netifaces.([]any), maintaining consistency with the other type changes.


113-114: Good type assertion modernization

Updated type assertions for loop iteration and nested map access to use the any type, improving readability while maintaining functionality.


121-123: Appropriate nested type assertion updates

All type assertions for the IPv4 configuration have been consistently updated to use the any type, making the code more concise.


126-128: Consistent IPv6 type assertion updates

Type assertions for IPv6 configuration match the pattern used for IPv4, maintaining consistency throughout the codebase.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Nice! Thanks, @scop 👍

../Frenck

@frenck frenck merged commit 451a57b into home-assistant:master Feb 28, 2025
@scop scop deleted the refactor/modernize branch February 28, 2025 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants