-
Notifications
You must be signed in to change notification settings - Fork 34
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
Adjust applyPermissions logic #10919 #10928
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10928 +/- ##
============================================
+ Coverage 84.66% 84.67% +0.01%
- Complexity 19965 19968 +3
============================================
Files 2622 2622
Lines 69374 69356 -18
Branches 5600 5600
============================================
- Hits 58734 58726 -8
+ Misses 7933 7929 -4
+ Partials 2707 2701 -6 ☔ View full report in Codecov by Sentry. |
...re-content/src/main/java/com/enonic/xp/core/impl/content/ApplyContentPermissionsCommand.java
Outdated
Show resolved
Hide resolved
...s/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/ApplyNodePermissionsCommand.java
Outdated
Show resolved
Hide resolved
|
||
if ( recursive ) | ||
{ | ||
if ( updatedSourceNode != null && updatedSourceNode.node() != null ) |
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 issue identified by the PMD linter is that the nested if
statements can be combined into a single conditional expression. This improves the readability of the code by reducing the number of nested blocks and making the logic clearer.
Here’s the original line:
if ( updatedSourceNode != null && updatedSourceNode.node() != null ) | |
if ( updatedSourceNode != null && updatedSourceNode.node() != null ) |
The suggestion is to combine the conditions into a single line without changing the logic.
Here’s the code suggestion:
if ( updatedSourceNode != null && updatedSourceNode.node() != null ) | |
if ( updatedSourceNode != null && updatedSourceNode.node() != null ) |
This line is already optimal, but if you want to avoid the nested if
statement altogether, you could simplify it by using a single if
statement with a method reference or a lambda if appropriate. However, since the request is for a single line change, the original line is already concise and correct.
If you want to directly address the suggestion made by PMD, you could refactor the code to avoid nesting entirely. Here’s a more concise way to express the same logic:
if ( updatedSourceNode != null && updatedSourceNode.node() != null ) | |
if ( updatedSourceNode != null && updatedSourceNode.node() != null ) doApplyOnChildren(permissions, updatedSourceNode.node().path()); |
This single line change removes the nested structure by directly invoking doApplyOnChildren
if both conditions are met.
This comment was generated by an experimental AI tool.
No description provided.