Skip to content

Commit

Permalink
Ensures that there is at least one character before default matching
Browse files Browse the repository at this point in the history
  • Loading branch information
mnhock authored and mnhock committed Jun 20, 2024
1 parent 3e2d595 commit ebcde7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/com/enofex/taikai/internal/Modifiers.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,14 @@ public static boolean isFieldProtected(JavaField field) {
public static boolean isFieldFinal(JavaField field) {
return field.getModifiers().contains(JavaModifier.FINAL);
}

/**
* Checks if a field is synthetic.
*
* @param field the Java field to check
* @return true if the field is synthetic, false otherwise
*/
public static boolean isFieldSynthetic(JavaField field) {
return field.getModifiers().contains(JavaModifier.SYNTHETIC);
}
}
5 changes: 4 additions & 1 deletion src/main/java/com/enofex/taikai/test/JUnit5Configurer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import static com.enofex.taikai.test.JUnit5DescribedPredicates.ANNOTATION_PARAMETRIZED_TEST;
import static com.enofex.taikai.test.JUnit5DescribedPredicates.ANNOTATION_TEST;
import static com.enofex.taikai.test.JUnit5DescribedPredicates.annotatedWithTestOrParameterizedTest;
import static com.tngtech.archunit.base.DescribedPredicate.not;
import static com.tngtech.archunit.lang.conditions.ArchConditions.beInterfaces;

import static com.tngtech.archunit.lang.conditions.ArchPredicates.are;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods;
Expand Down Expand Up @@ -45,7 +48,7 @@ public JUnit5Configurer classesShouldBePackagePrivate(String regex) {

public JUnit5Configurer classesShouldBePackagePrivate(String regex, Configuration configuration) {
return addRule(TaikaiRule.of(classes()
.that().haveNameMatching(regex)
.that().areNotInterfaces().and().haveNameMatching(regex)
.should().bePackagePrivate()
.as("Classes with names matching %s should be package-private".formatted(regex)),
configuration));
Expand Down

0 comments on commit ebcde7e

Please sign in to comment.