tsantalis/JDeodorant

Duplicated code and project not compiling after refactoring Long Method.

Closed this issue · 4 comments

rsain commented

Project: Perseo-core (https://github.com/telefonicaid/perseo-core)
Commit: 19189b66cbb0ba97edad41147f749e3bb2d7d2fb
Package: src.main.java.org.json
Classname: JSONObject
Method: private void populateMap(Object bean)
Operating system: Linux Debian
Eclipse version: 2019-03 (4.11.0)
JDeodorant plug-in version: 5.0.70

When I perform Long Method refactoring from the JDeodorant Eclipse plug-in on the populateMap method, a block of code is duplicated in the extracted method. Because of this, a local variable is defined twice and the project contains compilation errors.

  • Here the original code:

image

  • Here the refactored code (the wrongly duplicated code is highlighted in blue):

image

@rsain Out of all possible blocks to extract, which one did you select?
2019-10-11 09_51_00-

It seems only B2 block (0/20) creates the problem you reported. For all other blocks the code is refactored correctly.

Screenshot showing the refactored code after the fix
2019-10-14 07_16_11-

rsain commented

I still can replicate the issue when running JDeodorant over the entire project. However, when running JDeodorant over a single class (JSONObject) the refactoring is applied correctly.