Skip to content

Commit

Permalink
Remove excludeClass in favour of excludeClasses
Browse files Browse the repository at this point in the history
  • Loading branch information
mnhock committed Sep 22, 2024
1 parent ad352a4 commit 6affc16
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
7 changes: 3 additions & 4 deletions docs/USERGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ Taikai.builder()

### 3.4 Excluding Classes Globally

You can globally exclude specific classes from all rule checks by using the `excludeClass` or `excludeClasses` methods in the builder. This ensures that the specified classes are not checked by any rule.
You can globally exclude specific classes from all rule checks by using the `excludeClasses` methods in the builder. This ensures that the specified classes are not checked by any rule.

```java
Taikai.builder()
.namespace("com.company.project")
.excludeClass("com.company.project.SomeClassToExclude")
.excludeClasses("com.company.project.foo.ClassToExclude", "com.company.project.bar.ClassToExclude")
.build()
.check();
Expand All @@ -77,7 +76,7 @@ The `toBuilder` method allows you to create a new Builder instance from an exist
```java
Taikai taikai = Taikai.builder()
.namespace("com.company.project")
.excludeClass("com.company.project.SomeClassToExclude")
.excludeClasses("com.company.project.SomeClassToExclude")
.failOnEmpty(true)
.java(java -> java
.fieldsShouldNotBePublic())
Expand All @@ -86,7 +85,7 @@ Taikai taikai = Taikai.builder()
// Modify the existing configuration
Taikai modifiedTaikai = taikai.toBuilder()
.namespace("com.company.newproject")
.excludeClass("com.company.project.AnotherClassToExclude")
.excludeClasses("com.company.project.AnotherClassToExclude")
.failOnEmpty(false)
.java(java -> java
.classesShouldImplementHashCodeAndEquals()
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/enofex/taikai/Taikai.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ public Builder classes(JavaClasses classes) {
return this;
}

public Builder excludeClass(String className) {
this.excludedClasses.add(className);
return this;
}

public Builder excludeClasses(Collection<String> classNames) {
this.excludedClasses.addAll(classNames);
return this;
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/com/enofex/taikai/TaikaiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void shouldBuildTaikaiWithCustomValues() {

Taikai taikai = Taikai.builder()
.classes(new ClassFileImporter().importClasses(TaikaiTest.class))
.excludeClass("com.enofex.taikai.SomeClassToExclude")
.excludeClasses("com.enofex.taikai.foo.ClassToExclude", "com.enofex.taikai.bar.ClassToExclude")
.failOnEmpty(true)
.addRules(rules)
Expand All @@ -64,7 +63,7 @@ void shouldBuildTaikaiWithCustomValues() {
assertNotNull(taikai.classes());
assertEquals(1, taikai.rules().size());
assertTrue(taikai.rules().contains(mockRule));
assertEquals(3, taikai.excludedClasses().size());
assertEquals(2, taikai.excludedClasses().size());
}

@Test
Expand Down Expand Up @@ -140,15 +139,15 @@ void shouldCheckRules() {
void shouldRebuildTaikaiWithNewValues() {
Taikai taikai = Taikai.builder()
.namespace(VALID_NAMESPACE)
.excludeClass("com.enofex.taikai.ClassToExclude")
.excludeClasses("com.enofex.taikai.ClassToExclude")
.failOnEmpty(true)
.java(java -> java
.fieldsShouldNotBePublic())
.build();

Taikai modifiedTaikai = taikai.toBuilder()
.namespace("com.enofex.newnamespace")
.excludeClass("com.enofex.taikai.AnotherClassToExclude")
.excludeClasses("com.enofex.taikai.AnotherClassToExclude")
.failOnEmpty(false)
.java(java -> java
.classesShouldImplementHashCodeAndEquals()
Expand Down

0 comments on commit 6affc16

Please sign in to comment.