We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Detects common statements at the start or end of conditional branches like if/else and suggests moving them before the if branch or after it.
this.first
else if
DUPLICATE_CODE
general
No response
if (this.first == null) { ListCell newListCell = new ListCell(new int[this.arraySize], this.last, null); this.first = newListCell; this.last = newListCell; this.numberOfCells++; // returns always true here, because adding to a new array isn´t problematic // (array size > 0) return newListCell.addElement(element); } else { ListCell newListCell = new ListCell(new int[this.arraySize], this.last, null); this.last.next = newListCell; this.last = newListCell; this.numberOfCells++; return newListCell.addElement(element); // returns always true here, because adding to a new array isn´t problematic // (array size > 0) }
Could be written as:
ListCell newListCell = new ListCell(new int[this.arraySize], this.last, null); if (this.first == null) { this.first = newListCell; } else { this.last.next = newListCell; } this.last = newListCell; this.numberOfCells++; return newListCell.addElement(element);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What it does
Detects common statements at the start or end of conditional branches like if/else and suggests moving them before the if branch or after it.
To what can this be applied?
Some things to be careful of:
this.first
)else if
s might be difficult to work with / hard to give sensible feedback to the student -> I would suggest ignoring itLint Name
DUPLICATE_CODE
Category
general
Advantage
No response
Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: