Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Design and implementation code smells #966

Closed
wants to merge 7 commits into from

Conversation

shyamal2411
Copy link

Extracted Methods:
Extracted the method getBeanName to improve readability and isolate the logic for obtaining bean names based on annotations. The method now uses more descriptive names and has a single responsibility.
Extracted the method getBeanNameForAnnotation to encapsulate the logic of retrieving bean names from annotations, promoting code reuse.

Renamed Methods and Variables:
Renamed the method getBeanName to getBeanNameForAnnotations to better reflect its purpose.
Renamed the variable str to choicesString in the getErrorMessage method for clarity.
Decomposed Conditional Statements:

Decomposed the conditional statements in the getBeanNameForAnnotations method to simplify the logic and make it more straightforward.
Simplified the conditional statement in the getErrorMessage method by introducing a boolean variable hasSuggestions.

Introduced Explaining Variables:
Introduced the variable choicesString in the getBeanNameForAnnotations and getErrorMessage methods to explain the purpose of the string representation of choices.
Removed Unused Code:

Removed unused imports and variables, ensuring a cleaner codebase.
Optimized Enumerations:
Leveraged Java 8 features to handle enumerations more concisely, improving code efficiency.

@@ -300,6 +300,7 @@ public String getErrorMessage(EndpointValidationResult result, Map.Entry<String,
}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

remove me

return (element instanceof PsiLiteralExpression || element instanceof PropertyValueImpl) && parentOfType == null;
}


Copy link
Contributor

Choose a reason for hiding this comment

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

One empty line is good enough


return getAttributeReferences(attribute, value, context);
}
//IMPLEMENTATION SMELL OF IF STATEMENT
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what you mean by this, please clarify or remove it

} else {
writer = GradleFileWriter.GROOVY;
}
writer = targetBuildFileName.endsWith(".kts") ? GradleFileWriter.KOTLIN : GradleFileWriter.GROOVY;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto, please revert since it doesn't help much

@@ -87,31 +87,13 @@ public String getBeanName(PsiClass clazz) {
* @param project - Project reference to narrow the search inside.
* @return the {@link PsiClass} matching the bean name and annotation.
*/

Copy link
Contributor

Choose a reason for hiding this comment

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

useless empty line, please revert

returnName = StringUtils.stripDoubleQuotes(componentAnnotation.getText());
} else {
returnName = Introspector.decapitalize(clazz.getName());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto, it doesn't bring much so please revert

@davsclaus
Copy link
Collaborator

closing stale PR

@davsclaus davsclaus closed this Mar 21, 2024
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.

3 participants