-
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
Projet Linter JAVA (BOUCHENTOUF Oussama - ALOUCHE Mustapha) #23
base: develop
Are you sure you want to change the base?
Conversation
Using jars is not correct in a maven project knowing that these jars could be added as dependencies in the pom.xml file |
import org.apache.commons.csv.CSVFormat; | ||
import org.apache.commons.csv.CSVPrinter; | ||
|
||
public class CSVFilePrinter implements Printer { |
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.
👍🏽
for (Statement statement : method.getBody().get().getStatements()) { | ||
if (statement instanceof IfStmt) { | ||
IfStmt ifStmt = (IfStmt) statement; | ||
if (ifStmt.getCondition().findAll(BinaryExpr.class).size() >= 2) { |
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.
not only on if
statements, it may be something like boolean condition = a && b || c && d;
@Override | ||
public void apply(CompilationUnitWrapper compilationUnit) { | ||
for (MethodDeclaration method : compilationUnit.getMethods()) { | ||
int methodLines = 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.
optional::get is to be called conditionally
public void apply(CompilationUnitWrapper compilationUnit) { | ||
for (TypeDeclaration<?> type : compilationUnit.getTypes()) { | ||
int methodCount = 0; | ||
for (BodyDeclaration<?> member : type.getMembers()) { |
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 casts and instanceof checkc
@Override | ||
public void apply(CompilationUnitWrapper compilationUnit) { | ||
for (TypeDeclaration<?> type : compilationUnit.getTypes()) { | ||
if (!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.