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

Fix sonar issues in test code #266

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.sonar.plugins.communitydelphi.api.check.DelphiCheck;

class ForbiddenIdentifierCheckTest {
private static String FORBIDDEN_IDENTIFIER = "BadName";
private static final String FORBIDDEN_IDENTIFIER = "BadName";

private static DelphiCheck createCheck() {
ForbiddenIdentifierCheck check = new ForbiddenIdentifierCheck();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final class DelphiNodeUtils {

public static final DescribedPredicate<JavaClass> IMPLEMENT_ACCEPT =
new DescribedPredicate<>("have a method that implements accept(DelphiParserVisitor, T)") {
private final Class<?>[] ACCEPT_PARAMETERS = {DelphiParserVisitor.class, Object.class};
private final Class<?>[] acceptParameters = {DelphiParserVisitor.class, Object.class};

@Override
public boolean test(JavaClass javaClass) {
Expand All @@ -65,14 +65,14 @@ public boolean test(JavaClass javaClass) {
private boolean isAcceptMethodImplementation(JavaMethod javaMethod) {
Method method = javaMethod.reflect();
return method.getName().equals("accept")
&& Arrays.equals(method.getParameterTypes(), ACCEPT_PARAMETERS)
&& Arrays.equals(method.getParameterTypes(), acceptParameters)
&& !Modifier.isAbstract(method.getModifiers());
}
};

public static final ArchCondition<JavaClass> HAVE_TOKEN_CONSTRUCTOR =
new ArchCondition<>("have a public constructor(Token)") {
private final Class<?>[] TOKEN_PARAMETER = {Token.class};
private final Class<?>[] tokenParameter = {Token.class};

@Override
public void check(JavaClass javaClass, ConditionEvents events) {
Expand All @@ -81,7 +81,7 @@ public void check(JavaClass javaClass, ConditionEvents events) {
.map(JavaConstructor::reflect)
.anyMatch(
constructor ->
Arrays.equals(constructor.getParameterTypes(), TOKEN_PARAMETER));
Arrays.equals(constructor.getParameterTypes(), tokenParameter));

String message =
javaClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ void testIntegerTypes() {
assertResolved(type(INTEGER), type(WORD), type(BYTE));
assertResolved(type(SHORTINT), type(NATIVEINT), type(NATIVEUINT));

Type HWND = FACTORY.strongAlias("HWND", type(NATIVEUINT));
Type hwnd = FACTORY.strongAlias("HWND", type(NATIVEUINT));
assertResolved(
List.of(HWND, type(NATIVEUINT), type(SHORTINT), type(SHORTINT)),
List.of(HWND, type(NATIVEUINT), type(NATIVEINT), type(NATIVEINT)),
List.of(HWND, type(NATIVEUINT), type(NATIVEUINT), type(NATIVEINT)));
List.of(hwnd, type(NATIVEUINT), type(SHORTINT), type(SHORTINT)),
List.of(hwnd, type(NATIVEUINT), type(NATIVEINT), type(NATIVEINT)),
List.of(hwnd, type(NATIVEUINT), type(NATIVEUINT), type(NATIVEINT)));

assertResolved(type(BYTE), type(INTEGER), type(DOUBLE));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ private static Type getType(String name) {
return ((TypeFactoryImpl) TYPE_FACTORY).anonymousUInt31();
case "Extended":
return TYPE_FACTORY.getIntrinsic(IntrinsicType.EXTENDED);
default:
// do nothing
}

if (name.endsWith("_Subrange")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class IntegrationTestSuite {
new File("../sonar-delphi-plugin/target"), "sonar-delphi-plugin-*.jar");

@RegisterExtension
static OrchestratorExtension ORCHESTRATOR =
static final OrchestratorExtension ORCHESTRATOR =
OrchestratorExtension.builderEnv()
.useDefaultAdminCredentialsForBuilds(true)
.setSonarVersion(System.getProperty("sonar.runtimeVersion", "LATEST_RELEASE"))
Expand Down
Loading