tsantalis / JDeodorant

JDeodorant
https://marketplace.eclipse.org/content/jdeodorant
MIT License
139 stars 59 forks source link

Duplicated code and project not compiling after refactoring Long Method. #70

Closed rsain closed 5 years ago

rsain commented 5 years ago

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.

image

image

tsantalis commented 5 years ago

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

tsantalis commented 5 years ago

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

tsantalis commented 5 years ago

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

rsain commented 5 years ago

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.