-
Notifications
You must be signed in to change notification settings - Fork 37
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
Boutahar Naoual #29
base: develop
Are you sure you want to change the base?
Boutahar Naoual #29
Conversation
@Override | ||
public void apply(CompilationUnitWrapper compilationUnit) { | ||
final List<TypeDeclaration<?>> types = compilationUnit.getTypes(); | ||
types.stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use visitor pattern to avoid going through the structure
types.stream() | ||
.forEach(type -> { | ||
type.getFields().stream() | ||
.filter(field -> field.isStatic() && field.isFinal() && !field.getVariables().get(0).getNameAsString().matches("^[A-Z_]+$")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get(0) has to be generalized,
a declaration may have more than one field :
private String foo, bar;
for (TypeDeclaration<?> type : types) { | ||
List<MethodDeclaration> methods = type.getMethods(); | ||
for (MethodDeclaration method : methods) { | ||
int lineCount = method.getEnd().get().line - method.getBegin().get().line; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optinal::get is to be called conditionally
final List<TypeDeclaration<?>> types = compilationUnit.getTypes(); | ||
|
||
types.stream() | ||
.filter(type -> !Character.isUpperCase(type.getNameAsString().charAt(0)) || type.getNameAsString().contains("_")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!Character.isUpperCase ==> Character.isLowerCase
No description provided.