TRUNK-5748: Refactor code smells in openmrs-core#5937
Open
harshapilli369 wants to merge 9 commits intoopenmrs:masterfrom
Open
TRUNK-5748: Refactor code smells in openmrs-core#5937harshapilli369 wants to merge 9 commits intoopenmrs:masterfrom
harshapilli369 wants to merge 9 commits intoopenmrs:masterfrom
Conversation
- Field name was duplicating the containing class name (SonarCloud S1700) - Updated all internal references to use the new field name
…gyReaction - getId() was duplicating the implementation of getAllergyId() (SonarCloud S4144) - Updated getId() to delegate to specific getter instead of duplicating logic - Applied Pull-up method refactoring technique
…ts class - Interfaces should not solely consist of constants (SonarCloud S1214) - Created OperatorConstants utility class to hold all operator constants - Applied Move field and Extract class refactoring techniques
…itive complexity - Extracted findShortestNameForLocale() method (SonarCloud S3776) - Extracted findShortestNameForConcept() method - Extracted resolveShortestName() method to decompose conditional - Introduced explaining variables isSameLocale and isShorterThanCurrent - Applied Extract Method, Decompose Conditional and Introduce Explaining Variable techniques
- String literal 'conceptId' was duplicated 15 times (SonarCloud S1192) - Introduced private static final String CONCEPT_ID constant - Replaced all 15 occurrences with the constant reference - Applied Introduce Explaining Variable refactoring technique
…mbership.java - instanceof already returns false for null values (SonarCloud S4201) - Removed unnecessary null check to simplify conditional expression - Applied Decompose Conditional refactoring technique
…ggingUtil - Extracted FileLocationResolver interface (org.openmrs.logging) - Created resolver implementations for each appender type in resolver/ package: RollingFileAppenderResolver, FileAppenderResolver, MemoryMappedFileAppenderResolver, RollingRandomAccessFileAppenderResolver, RandomAccessFileAppenderResolver, AbstractFileAppenderResolver - Replaced if-else instanceof chain in getOpenmrsLogLocation() with resolver pattern - Applied Replace Conditional with Polymorphism refactoring technique
jwnasambu
reviewed
Mar 17, 2026
…d compatibility - Restored all 21 constants in Operator interface marked as @deprecated - Each constant now delegates to OperatorConstants for the actual value - Prevents breaking changes for external modules using Operator.AND, Operator.CONTAINS etc. - Applied as suggested by reviewer @jwnasambu Co-authored-by: jwnasambu <33891016+jwnasambu@users.noreply.github.com>
|
|
Looks good overall. Just wondering if this might cause any issues in edge cases? |
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.



Description of what I changed
Refactored multiple code smells identified via SonarCloud in openmrs-core:
Issue I worked on
see https://issues.openmrs.org/browse/TRUNK-5748
Checklist: I completed these to help reviewers :)
code style of this project.