RefactoringMiner icon indicating copy to clipboard operation
RefactoringMiner copied to clipboard

[JavaRecreation of JS Extract Method] Cannot detect relatively simple Extract Operation refactoring

Open mkshiblu opened this issue 3 years ago • 2 comments

Problem

Refactoring Miner was not able to detect that stringifyFn() was extracted from extractArgs().

Steps to Reproduce

  1. Go to https://github.com/mkshiblu/practice/commit/e6c793bfa5c087e41d1d32af87757411ca96b08b
  2. Run the chrome extension

Observed Behavior

  • No refactorings are reported by RefactoringMiner.

Java Diff

image

Note

  • The Above Java Example Test Code is a close recreation to this original javaScript code (injector.js).

  • Source code is compilable because of the addition of mock classes (e.g. Function, StringVar)

mkshiblu avatar Jun 27 '22 20:06 mkshiblu

This is a duplicate with #253 related to sub-expression matching

tsantalis avatar Jun 28 '22 00:06 tsantalis

@mkshiblu I think the reason is that you have two variables (fnText and args) declared in the same statement.

StringVar fnText = Function.prototype.toString.call(fn).replace(STRIP_COMMENTS, ""),
				args = fnText.match(ARROW_ARG).match(FN_ARGS);

tsantalis avatar Jun 30 '22 01:06 tsantalis