tsantalis / RefactoringMiner

MIT License
344 stars 132 forks source link

Lack of support for the refactoring using conditional expression transformation #681

Open simpt5 opened 3 months ago

simpt5 commented 3 months ago

Tested tools and version:

Refactoring Aware Commit Review Chrome Extension (Version: 2.0.4). RefactoringMiner (Version 3.0.4) maven dependency.

Description:

During the usage of RefactoringMiner, I found a refactoring case using conditional expression transformation that can’t be detected. Could it possibly be supported in the future maybe?

Commit URL: https://github.com/dromara/hutool/pull/1109/commits/1d4ac7d0dca04ff8b6d64b4c47cc5ff01d60201d

File URL: https://github.com/dromara/hutool/pull/1109/commits/1d4ac7d0dca04ff8b6d64b4c47cc5ff01d60201d#diff-e9a28972da0c69b8a3c84ac4d14c9c911bb58f552aef78049f00909468cbf1be

The following refactoring for conditional expression in the above commit can’t be detected.

image

tsantalis commented 3 months ago

@simpt5 The corresponding if statements are actually matched. I am not sure if this is a refactoring type. It can be considered as Simplifying Boolean Expressions

image

simpt5 commented 3 months ago

Yes, it is actually can be treated as a boolean expression transformation, which transform boolean expression using some rules without changing the program behaviors. It is indeed not a typical refactoring type as others. Since those transformations are based on rules and performed on the boolean expression, I am wondering if those could be detected (if it is worth to detect) using some strategies?

tsantalis commented 3 months ago

@simpt5 It is definitely possible to implement this in RefactoringMiner and get it reported with a new refactoring type Simplify Boolean Expression. I can add it as a new feature request.