Refactor/extract magic numbers and separator#197
Closed
blascosmog wants to merge 2 commits intoEndava:masterfrom
Closed
Refactor/extract magic numbers and separator#197blascosmog wants to merge 2 commits intoEndava:masterfrom
blascosmog wants to merge 2 commits intoEndava:masterfrom
Conversation
- Extract ConnectionPool values 10 and 15 into MAX_IDLE_CONNECTIONS and KEEP_ALIVE_MINUTES in ServiceCaller - Extract magic number 22 into SEPARATOR_PADDING in ConsoleUtils - Centralize CONSOLE_SEPARATOR in ConsoleUtils, use in TestCaseListener and CatsCommand to eliminate duplication
Contributor
|
I'm going to reject this one also. Please avoid PRs that reformat code without bringing anything else. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Extract Magic Numbers and Centralize SEPARATOR Constant
Description
This PR refactors the codebase to eliminate magic numbers and centralize duplicated constants, improving code readability and maintainability across the project.
Changes Made
1. ServiceCaller.java — Extraction of Magic Numbers in ConnectionPool
10and15innew ConnectionPool(10, 15, TimeUnit.MINUTES)MAX_IDLE_CONNECTIONS = 10— Maximum number of idle connections in the poolKEEP_ALIVE_MINUTES = 15— Time in minutes connections are kept alive2. ConsoleUtils.java — Centralization of Separator and Magic Number 22
22(offset for console width calculation)SEPARATOR_PADDING = 22— Padding for separator calculationCONSOLE_SEPARATOR— Static string with the precalculated console separator3. TestCaseListener.java — Elimination of Code Duplication
"-".repeat(ConsoleUtils.getConsoleColumns(22))withConsoleUtils.CONSOLE_SEPARATOR4. CatsCommand.java — Elimination of Code Duplication
"-".repeat(ConsoleUtils.getConsoleColumns(22))withConsoleUtils.CONSOLE_SEPARATORIssues Resolved
✅ Code Smell #1: Magic numbers in ServiceCaller (10, 15)
✅ Code Smell #3: Magic number 22 duplicated in TestCaseListener and CatsCommand
✅ DRY Violation: Duplicated separator code in two classes
Impact
Testing
Notes for Reviewers
static finalfor maximum efficiencyCONSOLE_SEPARATORis precalculated once at class loading time