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
Issue #12099: Add ArchUnit test to detect cycles in packages #12190
Conversation
How it looks like if we add new cycle ? Or be able to resolve cycle? You can create more commits in this PR to add remove/add some code to pass compilation and let arch unit to action |
743ee96
to
c7ee98b
Compare
@Vyom-Yadav , please resove conflict. please create extra test commits to show how it will looks like to deal with it, we can remove such extra commits ones we confirm that all works. |
c7ee98b
to
4b61c26
Compare
done
This is what it looks like when I moved all utils to API in 4b61c26, I think we might not be able to report all violations with the current limits set. I wonder if this affects our ability to detect new violations. |
98c19a9
to
099c889
Compare
what was code change ? that caused this error |
See above comment, I just moved utils to api package to resolve a bunch of violations at one time. The behavior of this freezing rule is strange, see 02e822e where I simply added one violation and have a negative diff of over 1,000 lines in freeze file. I would expect the addition of a few lines at most, not removal of over 1,000. |
last removal in your diff
It is not a cycle, so it might be problem with original generation of file. |
This looks like all the tool did was remove the newline at the end of the file, unless I am missing something. Edit: wrong line, I see now |
02e822e
to
ab8dfb8
Compare
Example of removing one violation: ab8dfb8 Diff is removal of over 1,000 lines; also test is still failing after freeze store update, see https://dev.azure.com/romanivanovjr/romanivanovjr/_build/results?buildId=11284&view=logs&j=eb841e9f-6e1e-5c29-3ad5-74ec2c658069 |
3da9267
to
5d49608
Compare
We are enabling re-freeze to minimize diff in the store in case a violation is added or removed. This would be more convenient for the developer.
|
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.
Item:
public class ArchUnitCyclesCheckTest { | ||
|
||
@Test | ||
public void testSlicesShouldBeFreeOfCycle() { |
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.
Please do this: imagine you are a new contributor, and execution of this test has generated a new suppression.
Then, in the issue, place links and information about the concept of this test and links to freeze documentation that would help you to understand why suppression was generated. After that, place a Javadoc here that explains how this test works, and a link to your comment in the issue.
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.
Yes, it good idea to read details in actual test class. Hints on how to interpretate is also good.
What is the process if we ok to allow extra cycle?
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.
@romani @nrmancuso Please take a look at the javadoc.
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.
does it mean that test will always pass and just update freeze file, so will enforce no cycles by simple PR review and noticing a diff - I am ok.
If user forget to place freeze file to commit, CI will fail as it will detect a git-diff.
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.
Yes, for any new violation, the store will be automatically updated, if the user commits the changes in the store, they will be seen and reviewed in the PR.
If user forget to place freeze file to commit, CI will fail as it will detect a git-diff.
Yes
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.
please mention in javadoc that change in freeze file need to be placed in commit.
Any change in freeze file should be committed and shared in PR to let mentors approve new cycle and guide contributor on how to avoid it.
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.
Whenever a new violation is introduced, the test will pass successfully but the frozen violations will be updated. In that case, developers should check if the new violation is expected or not. In both cases create a separate commit in the PR for discussing changes in the violation store.
Added this para to the javadoc.
8939115
to
c54f913
Compare
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.
items
src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitCyclesCheckTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitCyclesCheckTest.java
Outdated
Show resolved
Hide resolved
c54f913
to
0c7e410
Compare
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.
Ok to merge
@Vyom-Yadav , please resolve conflict |
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.
Items
* | ||
* <p>Whenever a new cycle is introduced or removed, the test will pass successfully but the | ||
* frozen violations will be updated. It is highly recommended to avoid new cycles and, it | ||
* is preferred to remove them. In both cases create a separate commit in the PR for discussing |
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.
In both cases put update in commit for discussion
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:
In both cases update the commit for discussing changes in the violation store.
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.
'Update commit' for sounds strange .
We need some sort on "include in commit"
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.
The suppressions generated by this tool are like the metadata generator; most contributors will never know/care about such changes and should commit all changes in one commit, and it is doubtful they will even see this comment until a reviewer points it out. It is responsibility of reviewer to catch extension of freeze file and question why we extended cycles.
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.
Yes, lets agree on some reasonable wording, and let's merge this PR
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.
In both cases commit the changes for further discussion.
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.
Good
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.
Done.
0103dd9
to
ec16877
Compare
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.
Ok to merge
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 good to merge once CI passes
checker-framework will fail due to #12210 |
We can not merge .. red CI will affect all |
src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitCyclesCheckTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitCyclesCheckTest.java
Show resolved
Hide resolved
src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitCyclesCheckTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitCyclesCheckTest.java
Outdated
Show resolved
Hide resolved
ec16877
to
8da749a
Compare
8da749a
to
7f8e539
Compare
7f8e539
to
5075bd1
Compare
#12099
Link to documentation about freezing arch rules: https://www.archunit.org/userguide/html/000_Index.html#_configuration
ViolationStore was created using property
freeze.store.default.allowStoreCreation=true
, default isfalse
as we do not want it to be created in CI pipeline.example of failure in test from diff: 4b61c26