Skip to content

Commit

Permalink
update messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Luro02 committed Nov 15, 2024
1 parent 57d8728 commit a5d93aa
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void reportProblem(CtBinaryOperator<?> ctBinaryOperator, boolean literal
addLocalProblem(
ctBinaryOperator,
new LocalizedMessage(
"redundant-boolean-equal",
"common-reimplementation",
Map.of(
"suggestion", suggestion
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import de.firemage.autograder.core.check.ExecutableCheck;
import de.firemage.autograder.core.integrated.IntegratedCheck;
import de.firemage.autograder.core.integrated.StaticAnalysis;
import de.firemage.autograder.core.integrated.TypeUtil;
import de.firemage.autograder.core.integrated.evaluator.OperatorHelper;
import spoon.processing.AbstractProcessor;
import spoon.reflect.code.BinaryOperatorKind;
Expand Down Expand Up @@ -39,8 +40,7 @@ public class UseOperatorAssignment extends IntegratedCheck {
private boolean isCommutativeType(CtTypedElement<?> ctTypedElement) {
return ctTypedElement.getType() == null
|| NON_COMMUTATIVE_TYPES.stream()
.map(ty -> ctTypedElement.getFactory().Type().createReference(ty))
.noneMatch(ty -> ty.equals(ctTypedElement.getType()));
.noneMatch(ty -> TypeUtil.isTypeEqualTo(ctTypedElement.getType(), ty));
}

private boolean isCommutative(BinaryOperatorKind binaryOperatorKind) {
Expand Down Expand Up @@ -106,8 +106,8 @@ public void process(CtAssignment<?, ?> assignment) {
addLocalProblem(
assignment,
new LocalizedMessage(
"use-operator-assignment-exp",
Map.of("simplified", simplifiedExpr)
"common-reimplementation",
Map.of("suggestion", simplifiedExpr)
),
ProblemType.USE_OPERATOR_ASSIGNMENT
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected void check(StaticAnalysis staticAnalysis) {
staticAnalysis.processWith(new AbstractProcessor<CtAssert<?>>() {
@Override
public void process(CtAssert<?> element) {
addLocalProblem(element, new LocalizedMessage("assert-used-exp"), ProblemType.ASSERT);
addLocalProblem(element, new LocalizedMessage("assert-used"), ProblemType.ASSERT);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ public void process(CtBinaryOperator<?> operator) {

if (isStringComparison(lhs, rhs)) {
addLocalProblem(operator, new LocalizedMessage(
"string-cmp-exp",
Map.of("lhs", lhs, "rhs", rhs)
"suggest-replacement",
Map.of(
"original", operator.toString(),
"replacement", "%s.equals(%s)".formatted(lhs, rhs)
)
),
ProblemType.STRING_COMPARE_BY_REFERENCE
);
Expand Down

This file was deleted.

Loading

0 comments on commit a5d93aa

Please sign in to comment.