-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement no class feature #316
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #316 /- ##
============================================
Coverage 93.02% 93.23% 0.20%
- Complexity 476 487 11
============================================
Files 60 62 2
Lines 1262 1301 39
============================================
Hits 1174 1213 39
Misses 88 88
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to add a description of this new behavior into the README file
@@ -69,9 79,9 @@ public function classesToBeExcluded(string ...$classesToBeExcluded): self | |||
return $this; | |||
} | |||
|
|||
public function setRunOnlyThis(): self | |||
public function negateShoulds(): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you do this change?
use Arkitect\Rules\ViolationMessage; | ||
use Arkitect\Rules\Violations; | ||
|
||
class NegateDecorator implements Expression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about naming it just Not
? I could also simplify other expressions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree!
@@ -9,4 9,9 @@ public static function allClasses(): AllClasses | |||
{ | |||
return new AllClasses(); | |||
} | |||
|
|||
public static function noClass(): NoClass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about naming it NoClasses, for consistency with AllClasses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it would not be correct English. It's the same in Italian "tutte le classi"/"nessuna classe".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am far from being an expert but I think also NoClasses is correct. Looking at java's ArchUnit they decided to used it, eg.
ArchRule rule = ArchRuleDefinition.noClasses()
.that().resideInAPackage("..service..")
.should().accessClassesThat().resideInAPackage("..controller..");
rule.check(importedClasses);
@@ -39,6 45,10 @@ public function addThat(Expression $that): self | |||
|
|||
public function addShould(Expression $should): self | |||
{ | |||
if ($this->negateShoulds) { | |||
$should = new NegateDecorator($should); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am too low on ☕ but I can't wrap my head around this, would you mind explaining it to me?
If the should method in NoClass already does this
$this->ruleBuilder->addShould(new NegateDecorator($expression));
why do we need to add another new NegateDecorator
here?
Closes #315 allowing to write rules like:
or