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

Duplicate code not detected where two variables differ #615

Open
Luro02 opened this issue Oct 8, 2024 · 0 comments
Open

Duplicate code not detected where two variables differ #615

Luro02 opened this issue Oct 8, 2024 · 0 comments
Labels
bug Something isn't working duplicate-code false-negative A lint should trigger on code that is wrong.

Comments

@Luro02
Copy link
Collaborator

Luro02 commented Oct 8, 2024

Summary

if ((doesRCExist(currentField.getRow() + 1, currentField.getColumn()))
    && (!previousFields.get(0).equals(gameBoard[currentField.getRow() + 1][currentField.getColumn()]))) {
    fieldsToSearch.add(gameBoard[currentField.getRow() + 1][currentField.getColumn()]);
    previousFields.add(currentField);
    movementLeft.add(movementLeft.get(0) - 1);
}

if ((doesRCExist(currentField.getRow(), currentField.getColumn() + 1))
    && (!previousFields.get(0).equals(gameBoard[currentField.getRow()][currentField.getColumn() + 1]))) {
    fieldsToSearch.add(gameBoard[currentField.getRow()][currentField.getColumn() + 1]);
    previousFields.add(currentField);
    movementLeft.add(movementLeft.get(0) - 1);
}

if ((doesRCExist(currentField.getRow() - 1, currentField.getColumn()))
    && (!previousFields.get(0).equals(gameBoard[currentField.getRow() - 1][currentField.getColumn()]))) {
    fieldsToSearch.add(gameBoard[currentField.getRow() - 1][currentField.getColumn()]);
    previousFields.add(currentField);
    movementLeft.add(movementLeft.get(0) - 1);
}

if ((doesRCExist(currentField.getRow(), currentField.getColumn() - 1))
    && (!previousFields.get(0).equals(gameBoard[currentField.getRow()][currentField.getColumn() - 1]))) {
    fieldsToSearch.add(gameBoard[currentField.getRow()][currentField.getColumn() - 1]);
    previousFields.add(currentField);
    movementLeft.add(movementLeft.get(0) - 1);
}

Lint Name

DUPLICATE_CODE

Reproducer

<code>
@Luro02 Luro02 added bug Something isn't working false-negative A lint should trigger on code that is wrong. duplicate-code labels Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate-code false-negative A lint should trigger on code that is wrong.
Projects
None yet
Development

No branches or pull requests

1 participant