Feuermagier / autograder

Automatic grading of student's Java code
MIT License
13 stars 7 forks source link

Replace `isLetter || isDigit` with `isLetterOrDigit` #540

Open Luro02 opened 1 month ago

Luro02 commented 1 month ago

What it does

Detects CtBinaryExpression<Boolean> that can be replaced by a call to Character.isLetterOrDigit().

The implementation is easy, visit all CtBinaryExpression and check that they match the below format.

Lint Name

CHAR_LETTER_OR_DIGIT

Category

api

Example

Character.isLetter(c) || Character.isDigit(c)

Could be written as:

Character.isLetterOrDigit(c)

!(Character.isLetter(c) || Character.isDigit(c))
// or
!Character.isLetter(c) && !Character.isDigit(c)

Could be written as:

!Character.isLetterOrDigit(c)