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
Improve S3398: Fix code smells #6827
Conversation
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 don't find this more readable.
Can you find something that uses more positive logic and less indirection?
} | ||
|
||
return firstPath[lastCommonPathIndex]; | ||
bool NotEveryNodeIsTheSameOnLevel(int level) => |
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 don't find this clearer because it's two negations:
- NotEveryNodeIsTheSameOnLevel
!=
inside Any
Also, levels
refers to indeces, whereas NotEveryNodeIsTheSameOnLevel
is iterating over typeHierarchyFromTopToBottom
But NotEveryNodeIsTheSameOnLevel
is called on levels
There's a lot of indirection in here. levels.Do(Action)
actually iterates on a different data structure, using the indeces inside levels
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.
Reverted it. Now the only change is splitting the comment to multiple lines.
? minPathLength - 1 | ||
: firstDifferingLevel - 1; |
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.
having -1
makes it a bit difficult to follow the logic...
there's another implicit negation here: Differ
rather then Common
in the name of the method: LowestCommonAncestorOrSelf
So the method is named Common
, but the logic inside is looking for Different
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Fixes #6706
RSPEC PR