Skip to content

Commit

Permalink
update user guide what to check
Browse files Browse the repository at this point in the history
I think in most cases users should rely on `onlyHaveDependentClassesThat()` instead of `onlyBeAccessed().byClassesThat()`. The former covers all types of dependencies, also field types, annotations, type parameters, etc., while the latter only covers real accesses like field access or method call. Since this difference has often been confusing to users, we should lead them to the more restrictive one by default.

Signed-off-by: Peter Gafert <[email protected]>
  • Loading branch information
codecholeric committed Dec 16, 2020
1 parent 45c8e87 commit edf4b29
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/_pages/use-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classes().that().resideInAPackage("..foo..")

```
classes().that().haveNameMatching(".*Bar")
.should().onlyBeAccessed().byClassesThat().haveSimpleName("Bar")
.should().onlyHaveDependentClassesThat().haveSimpleName("Bar")
```
Expand All @@ -54,7 +54,7 @@ classes().that().implement(Connection.class)

```
classes().that().areAssignableTo(EntityManager.class)
.should().onlyBeAccessed().byAnyPackage("..persistence..")
.should().onlyHaveDependentClassesThat().resideInAnyPackage("..persistence..")
```
Expand All @@ -64,7 +64,7 @@ classes().that().areAssignableTo(EntityManager.class)

```
classes().that().areAssignableTo(EntityManager.class)
.should().onlyBeAccessed().byClassesThat().areAnnotatedWith(Transactional.class)
.should().onlyHaveDependentClassesThat().areAnnotatedWith(Transactional.class)
```
Expand Down
8 changes: 4 additions & 4 deletions docs/userguide/004_What_to_Check.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ note left on link #green: allowed
[source,java]
----
classes().that().haveNameMatching(".*Bar")
.should().onlyBeAccessed().byClassesThat().haveSimpleName("Bar")
.should().onlyHaveDependentClassesThat().haveSimpleName("Bar")
----

=== Class and Package Containment Checks
Expand Down Expand Up @@ -178,7 +178,7 @@ note right on link #crimson: Accessor resides in wrong package
[source,java]
----
classes().that().areAssignableTo(EntityManager.class)
.should().onlyBeAccessed().byAnyPackage("..persistence..")
.should().onlyHaveDependentClassesThat().resideInAnyPackage("..persistence..")
----

=== Annotation Checks
Expand Down Expand Up @@ -211,7 +211,7 @@ note right on link #crimson: Accessor is not annotated with @Transactional
[source,java]
----
classes().that().areAssignableTo(EntityManager.class)
.should().onlyBeAccessed().byClassesThat().areAnnotatedWith(Transactional.class)
.should().onlyHaveDependentClassesThat().areAnnotatedWith(Transactional.class)
----

=== Layer Checks
Expand Down Expand Up @@ -305,4 +305,4 @@ note right on link #crimson: Combination of accesses forms cycle
[source,java]
----
slices().matching("com.myapp.(*)..").should().beFreeOfCycles()
----
----
6 changes: 3 additions & 3 deletions docs/userguide/html/000_Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ <h3 id="_class_dependency_checks"><a class="anchor" href="#_class_dependency_che
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code data-lang="java" class="language-java hljs">classes().that().haveNameMatching(".*Bar")
.should().onlyBeAccessed().byClassesThat().haveSimpleName("Bar")</code></pre>
.should().onlyHaveDependentClassesThat().haveSimpleName("Bar")</code></pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -916,7 +916,7 @@ <h3 id="_inheritance_checks"><a class="anchor" href="#_inheritance_checks"></a>4
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code data-lang="java" class="language-java hljs">classes().that().areAssignableTo(EntityManager.class)
.should().onlyBeAccessed().byAnyPackage("..persistence..")</code></pre>
.should().onlyHaveDependentClassesThat().resideInAnyPackage("..persistence..")</code></pre>
</div>
</div>
</div>
Expand All @@ -930,7 +930,7 @@ <h3 id="_annotation_checks"><a class="anchor" href="#_annotation_checks"></a>4.5
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code data-lang="java" class="language-java hljs">classes().that().areAssignableTo(EntityManager.class)
.should().onlyBeAccessed().byClassesThat().areAnnotatedWith(Transactional.class)</code></pre>
.should().onlyHaveDependentClassesThat().areAnnotatedWith(Transactional.class)</code></pre>
</div>
</div>
</div>
Expand Down

0 comments on commit edf4b29

Please sign in to comment.