-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#33 "source code style rule definition"
- code was already cycle-free on package level - fixed 'layering' (no dependencies between a package and any of its (sub-)sub-packages) -- all test gap analysis related classes are now in analysis package (or a sub-package) -- created a new top-level package for DebugCoverageResolution
- Loading branch information
1 parent
93a58cc
commit 880ab72
Showing
16 changed files
with
139 additions
and
26 deletions.
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
4 changes: 2 additions & 2 deletions
4
...-plugin/src/main/java/com/scheible/testgapanalysis/maven/DebugCoverageResolutionMojo.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
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
2 changes: 1 addition & 1 deletion
2
...heible/testgapanalysis/TestGapReport.java → ...lysis/analysis/testgap/TestGapReport.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
2 changes: 1 addition & 1 deletion
2
...tgapanalysis/DebugCoverageResolution.java → ...alysis/debug/DebugCoverageResolution.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
2 changes: 1 addition & 1 deletion
2
...alysis/DebugCoverageResolutionReport.java → .../debug/DebugCoverageResolutionReport.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
71 changes: 71 additions & 0 deletions
71
test-gap-analysis/src/test/java/com/scheible/testgapanalysis/CodeDependenciesTest.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,71 @@ | ||
package com.scheible.testgapanalysis; | ||
|
||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; | ||
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices; | ||
|
||
import org.junit.runner.RunWith; | ||
|
||
import com.tngtech.archunit.core.domain.Dependency; | ||
import com.tngtech.archunit.core.domain.JavaClass; | ||
import com.tngtech.archunit.core.importer.ImportOption.DoNotIncludeTests; | ||
import com.tngtech.archunit.junit.AnalyzeClasses; | ||
import com.tngtech.archunit.junit.ArchTest; | ||
import com.tngtech.archunit.junit.ArchUnitRunner; | ||
import com.tngtech.archunit.lang.ArchCondition; | ||
import com.tngtech.archunit.lang.ArchRule; | ||
import com.tngtech.archunit.lang.ConditionEvents; | ||
import com.tngtech.archunit.lang.SimpleConditionEvent; | ||
import com.tngtech.archunit.library.dependencies.SliceAssignment; | ||
import com.tngtech.archunit.library.dependencies.SliceIdentifier; | ||
|
||
/** | ||
* | ||
* @author sj | ||
*/ | ||
@RunWith(ArchUnitRunner.class) | ||
@AnalyzeClasses(packagesOf = CodeDependenciesTest.class, importOptions = DoNotIncludeTests.class) | ||
public class CodeDependenciesTest { | ||
|
||
private static class SlicePerPackage implements SliceAssignment { | ||
|
||
@Override | ||
public SliceIdentifier getIdentifierOf(final JavaClass javaClass) { | ||
return SliceIdentifier.of(javaClass.getPackageName()); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Every package is treated as a slice."; | ||
} | ||
} | ||
|
||
@ArchTest | ||
static final ArchRule noPackageCyclesRule = slices().assignedFrom(new SlicePerPackage()).should().beFreeOfCycles(); | ||
|
||
private static class DependOnDescendantPackagesCondition extends ArchCondition<JavaClass> { | ||
|
||
DependOnDescendantPackagesCondition() { | ||
super("depend on descendant packages"); | ||
} | ||
|
||
@Override | ||
public void check(JavaClass clazz, ConditionEvents events) { | ||
for (Dependency dependency : clazz.getDirectDependenciesFromSelf()) { | ||
boolean dependencyOnDescendantPackage = isDependencyOnDescendantPackage(dependency.getOriginClass(), | ||
dependency.getTargetClass()); | ||
events.add(new SimpleConditionEvent(dependency, dependencyOnDescendantPackage, | ||
dependency.getDescription())); | ||
} | ||
} | ||
|
||
private boolean isDependencyOnDescendantPackage(JavaClass origin, JavaClass target) { | ||
String originPackageName = origin.getPackageName(); | ||
String targetSubPackagePrefix = target.getPackageName(); | ||
return targetSubPackagePrefix.contains(originPackageName + "."); | ||
} | ||
} | ||
|
||
@ArchTest | ||
static final ArchRule packageLayeringRule = noClasses().should(new DependOnDescendantPackagesCondition()) | ||
.because("lower packages shouldn't build on higher packages"); | ||
} |
10 changes: 1 addition & 9 deletions
10
test-gap-analysis/src/test/java/com/scheible/testgapanalysis/TestGapAnalysisSubModule.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 |
---|---|---|
@@ -1,20 +1,12 @@ | ||
package com.scheible.testgapanalysis; | ||
|
||
import com.scheible.pocketsaw.api.SubModule; | ||
import com.scheible.testgapanalysis.ExternalFunctionalities.Slf4j; | ||
import com.scheible.testgapanalysis.analysis.AnalysisSubModule; | ||
import com.scheible.testgapanalysis.common.CommonSubModule; | ||
import com.scheible.testgapanalysis.git.GitSubModule; | ||
import com.scheible.testgapanalysis.jacoco.JaCoCoSubModule; | ||
import com.scheible.testgapanalysis.jacoco.resolver.JaCoCoResolverSubModule; | ||
import com.scheible.testgapanalysis.parser.ParserSubModule; | ||
|
||
/** | ||
* | ||
* @author sj | ||
*/ | ||
@SubModule(includeSubPackages = false, uses = {AnalysisSubModule.class, JaCoCoSubModule.class, ParserSubModule.class, | ||
JaCoCoResolverSubModule.class, Slf4j.class, GitSubModule.class, CommonSubModule.class}) | ||
@SubModule(includeSubPackages = false) | ||
public class TestGapAnalysisSubModule { | ||
|
||
} |
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
20 changes: 20 additions & 0 deletions
20
...src/test/java/com/scheible/testgapanalysis/analysis/testgap/AnalysisTestGapSubModule.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,20 @@ | ||
package com.scheible.testgapanalysis.analysis.testgap; | ||
|
||
import com.scheible.pocketsaw.api.SubModule; | ||
import com.scheible.testgapanalysis.ExternalFunctionalities.Slf4j; | ||
import com.scheible.testgapanalysis.analysis.*; | ||
import com.scheible.testgapanalysis.common.CommonSubModule; | ||
import com.scheible.testgapanalysis.git.GitSubModule; | ||
import com.scheible.testgapanalysis.jacoco.JaCoCoSubModule; | ||
import com.scheible.testgapanalysis.jacoco.resolver.JaCoCoResolverSubModule; | ||
import com.scheible.testgapanalysis.parser.ParserSubModule; | ||
|
||
/** | ||
* | ||
* @author sj | ||
*/ | ||
@SubModule(uses = {JaCoCoSubModule.class, JaCoCoResolverSubModule.class, GitSubModule.class, ParserSubModule.class, | ||
Slf4j.class, CommonSubModule.class}) | ||
public class AnalysisTestGapSubModule { | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
.../testgapanalysis/TestGapAnalysisTest.java → ...analysis/testgap/TestGapAnalysisTest.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
2 changes: 1 addition & 1 deletion
2
...le/testgapanalysis/TestGapReportTest.java → ...s/analysis/testgap/TestGapReportTest.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
2 changes: 1 addition & 1 deletion
2
...analysis/DebugCoverageResolutionTest.java → ...is/debug/DebugCoverageResolutionTest.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
16 changes: 16 additions & 0 deletions
16
test-gap-analysis/src/test/java/com/scheible/testgapanalysis/debug/DebugSubModule.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,16 @@ | ||
package com.scheible.testgapanalysis.debug; | ||
|
||
import com.scheible.pocketsaw.api.SubModule; | ||
import com.scheible.testgapanalysis.common.CommonSubModule; | ||
import com.scheible.testgapanalysis.jacoco.JaCoCoSubModule; | ||
import com.scheible.testgapanalysis.jacoco.resolver.JaCoCoResolverSubModule; | ||
import com.scheible.testgapanalysis.parser.ParserSubModule; | ||
|
||
/** | ||
* | ||
* @author sj | ||
*/ | ||
@SubModule(uses = {JaCoCoSubModule.class, ParserSubModule.class, JaCoCoResolverSubModule.class, CommonSubModule.class}) | ||
public class DebugSubModule { | ||
|
||
} |