Skip to content

Refactor: Fix Infrastructure and Design Code Smells for Improved Maintainability#2928

Open
Gautham-2907 wants to merge 4 commits intoEngineHub:version/7.4.xfrom
Gautham-2907:version-3
Open

Refactor: Fix Infrastructure and Design Code Smells for Improved Maintainability#2928
Gautham-2907 wants to merge 4 commits intoEngineHub:version/7.4.xfrom
Gautham-2907:version-3

Conversation

@Gautham-2907
Copy link

Summary

This PR addresses Infrastructure and Design code smells identified in the WorldEdit codebase through targeted refactoring.

Changes Made

  • Extract Method: Decomposed long methods into smaller, focused helpers
  • Remove Duplication: Consolidated repeated logic into shared utility methods
  • Replace Magic Numbers: Substituted hardcoded values with named constants
  • Rename for Clarity: Improved variable and method names to better reflect intent

Files Changed

  • [List your changed files here, e.g. EditSession.java, etc.]

Testing

  • No functional behavior has been altered
  • All existing tests pass
  • Changes are purely structural/cosmetic

Notes

Happy to revise based on maintainer feedback.

…plaining variable, replace conditional with polymorphism

- Add ChunkFromTagLoader interface and ChunkFromTagLoaders with format-specific loaders (code smell: long conditional chain)
- Extract extractDataVersion() and applyDataFixerIfNeeded() to reduce method size
- Introduce explaining variables isMcAFormat, isBehindCurrentVersion, shouldApplyFix
- Replace version if-else chain with ChunkFromTagLoaders.loadChunk()
…ponents

- Code smell: duplicated path computation in getFilename and getChunkData
- Add getChunkPathComponents(BlockVector2) and ChunkPathComponents record
- Both getFilename and getChunkData now use getChunkPathComponents
- Code smell: LocalSession had mixed responsibilities (session + CUI state)
- Add SessionCUIState holding failedCuiAttempts, hasCUISupport, cuiVersion, serverCuiStructureBlockPosition
- LocalSession delegates CUI state getters/setters to cuiState; onIdle() calls cuiState.reset()
- Code smell: unclear names. Rename pickaxeMode to superPickaxeTool
- Extract isSelectionDefinedForWorld(World) and use in getSelection() to decompose complex conditional
@Gautham-2907 Gautham-2907 requested a review from a team as a code owner March 17, 2026 06:13
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