Skip to content
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

Merged
merged 5 commits into from
Feb 25, 2025
Merged

Adjust applyPermissions logic #10919 #10928

merged 5 commits into from
Feb 25, 2025

Conversation

vbradnitski
Copy link
Contributor

No description provided.

@vbradnitski vbradnitski linked an issue Feb 20, 2025 that may be closed by this pull request
Copy link

codecov bot commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 95.83333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.67%. Comparing base (a2b5ceb) to head (538cde4).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
...xp/repo/impl/node/ApplyNodePermissionsCommand.java 95.23% 0 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

@vbradnitski vbradnitski marked this pull request as ready for review February 20, 2025 14:19

if ( recursive )
{
if ( updatedSourceNode != null && updatedSourceNode.node() != null )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Codacy found a medium ErrorProne issue: These nested if statements could be combined

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:

Suggested change
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:

Suggested change
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:

Suggested change
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.

@rymsha rymsha merged commit a8a9115 into master Feb 25, 2025
5 of 6 checks passed
@rymsha rymsha deleted the issue-10919 branch February 25, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjust applyPermissions logic
3 participants