Skip to content
/ taikai Public

Taikai is an extension of the popular ArchUnit library, offering a comprehensive suite of predefined rules tailored for various technologies.

License

Notifications You must be signed in to change notification settings

enofex/taikai

Repository files navigation

Taikai

Taikai extends the capabilities of the popular ArchUnit library by offering a comprehensive suite of predefined rules tailored for various technologies. It simplifies the enforcement of architectural constraints and best practices in your codebase, ensuring consistency and quality across your projects.

Maven Usage

Add Taikai as a dependency in your pom.xml:

<dependency>
  <groupId>com.enofex</groupId>
  <artifactId>taikai</artifactId>
  <version>${taikai.version}</version>
  <scope>test</scope>
</dependency>

Replace ${taikai.version} with the appropriate version defined in your project. Ensure that the required dependencies like ArchUnit are already declared.

Gradle Usage

Add Taikai as a dependency in your build.gradle file:

testImplementation "com.enofex:taikai:${taikaiVersion}"

Replace ${taikaiVersion} with the appropriate version defined in your project. Ensure that the required dependencies like ArchUnit are already declared.

JUnit 5 Example Test

Here's an example demonstrating the usage of some Taikai rules with JUnit 5. Customize rules as needed using TaikaiRule.of().

@Test
void shouldFulfillConstraints() {
  Taikai.builder()
      .namespace("com.enofex.taikai")
      .java(java -> java
          .noUsageOfDeprecatedAPIs()
          .methodsShouldNotDeclareGenericExceptions()
          .utilityClassesShouldBeFinalAndHavePrivateConstructor()
          .imports(imports -> imports
              .shouldHaveNoCycles()
              .shouldNotImport("..shaded..")
              .shouldNotImport("org.junit.."))
          .naming(naming -> naming
              .classesShouldNotMatch(".*Impl")
              .methodsShouldNotMatch("^(?!foo$|bar$).*")
              .fieldsShouldNotMatch(".*(List|Set|Map)$")
              .fieldsShouldMatch("com.enofex.taikai.Matcher", "matcher")
              .constantsShouldFollowConventions()
              .interfacesShouldNotHavePrefixI()))
      .logging(logging -> logging
          .loggersShouldFollowConventions(Logger.class, "logger", List.of(PRIVATE, FINAL)))      
      .test(test -> test
          .junit5(junit5 -> junit5
              .classesShouldNotBeAnnotatedWithDisabled()
              .methodsShouldNotBeAnnotatedWithDisabled()))
      .spring(spring -> spring
          .noAutowiredFields()
          .boot(boot -> boot
              .springBootApplicationShouldBeIn("com.enofex.taikai"))
          .configurations(configuration -> configuration
              .namesShouldEndWithConfiguration())
          .controllers(controllers -> controllers
              .shouldBeAnnotatedWithRestController()
              .namesShouldEndWithController()
              .shouldNotDependOnOtherControllers()
              .shouldBePackagePrivate())
          .services(services -> services
              .shouldBeAnnotatedWithService()
              .shouldNotDependOnControllers()
              .namesShouldEndWithService())
          .repositories(repositories -> repositories
              .shouldBeAnnotatedWithRepository()
              .shouldNotDependOnServices()
              .namesShouldEndWithRepository()))      
      .addRule(TaikaiRule.of(...)) // Add custom ArchUnit rule here
      .build()
      .check();
}

User Guide

Explore the complete documentation for comprehensive information on all available rules.

Contributing

Interested in contributing? Check out our Contribution Guidelines for details on how to get involved. Note, that we expect everyone to follow the Code of Conduct.

What you will need

  • Git
  • Java 17 or higher

Get the Source Code

Clone the repository

git clone [email protected]:enofex/taikai.git
cd taikai

Build the code

To compile, test, and build

./mvnw clean package -B

About

Taikai is an extension of the popular ArchUnit library, offering a comprehensive suite of predefined rules tailored for various technologies.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages