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

Projet Linter JAVA (BOUCHENTOUF Oussama - ALOUCHE Mustapha) #23

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

OussamaBouchentouf
Copy link

No description provided.

@BelmoMusta
Copy link
Owner

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 {
Copy link
Owner

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) {
Copy link
Owner

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;
Copy link
Owner

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()) {
Copy link
Owner

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("_")) {
Copy link
Owner

Choose a reason for hiding this comment

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

!Character.isUpperCase ==> Character.isLowerCase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants