-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #12099: Add ArchUnit test to detect cycles in packages
- Loading branch information
1 parent
b61f11a
commit c7ee98b
Showing
8 changed files
with
2,848 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2,776 changes: 2,776 additions & 0 deletions
2,776
config/archunit-store/7999d2d1-606c-4e14-a852-2cb0fa661f48
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# | ||
#Sat Sep 10 22:27:26 IST 2022 | ||
slices\ matching\ 'com.puppycrawl.tools.checkstyle.(**)'\ should\ be\ free\ of\ cycles=7999d2d1-606c-4e14-a852-2cb0fa661f48 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitCyclesCheckTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/////////////////////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code and other text files for adherence to a set of rules. | ||
// Copyright (C) 2001-2022 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
/////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.puppycrawl.tools.checkstyle.internal; | ||
|
||
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.tngtech.archunit.core.domain.JavaClasses; | ||
import com.tngtech.archunit.core.importer.ClassFileImporter; | ||
import com.tngtech.archunit.core.importer.ImportOption; | ||
import com.tngtech.archunit.lang.ArchRule; | ||
import com.tngtech.archunit.library.freeze.FreezingArchRule; | ||
|
||
public class ArchUnitCyclesCheckTest { | ||
|
||
@Test | ||
public void testSlicesShouldBeFreeOfCycle() { | ||
final JavaClasses importedClasses = new ClassFileImporter() | ||
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS) | ||
.importPackages("com.puppycrawl.tools.checkstyle"); | ||
|
||
final ArchRule slicesShouldBeFreeOfCycle = FreezingArchRule.freeze( | ||
slices() | ||
.matching("com.puppycrawl.tools.checkstyle.(**)") | ||
.should().beFreeOfCycles()); | ||
|
||
slicesShouldBeFreeOfCycle.check(importedClasses); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This will limit the maximum number of dependencies to report per cycle edge. | ||
# Note that ArchUnit will regardless always analyze all dependencies to detect cycles, | ||
# so this purely affects how many dependencies will be printed in the report. | ||
# Also note that this number will quickly affect the required heap since it scales with number. | ||
# of edges and number of cycles | ||
# default is 20 | ||
cycles.maxNumberOfDependenciesPerEdge=550 | ||
|
||
# This will limit the maximum number of cycles to detect and thus required CPU and heap. | ||
# default is 100 | ||
cycles.maxNumberToDetect=200 | ||
|
||
freeze.store.default.path=config/archunit-store |