Skip to content
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

Detect Rename function #3

Closed
mkshiblu opened this issue May 19, 2020 · 1 comment
Closed

Detect Rename function #3

mkshiblu opened this issue May 19, 2020 · 1 comment
Assignees

Comments

@mkshiblu
Copy link
Owner

mkshiblu commented May 19, 2020

Background

  • In JavaScript, a function's signature could be considered as its name only.
  • If there are multiple functions in the same scope with the same name, regardless of the number of parameters, only the lastly declared function will be hoisted up i.e. considered by the environment.

For example, in the following code snippet function, the output would be

World
World

Since the lastly declared function A is hoisted up and called twice.

A(10, 20);
A(5);

function A(p1, p2) {
    alert('Hello')
} 

function A(p3) {
    alert('World')
}
  • Thre is no method overloading like Java however, any function can be passed any number of arguments.

Technique

  • Find added, modified and deleted files using git or a directory

  • Compare function names in the same file and see if only the name has changed (Round 1)

  • Detect change in other files ( Next Round)

  • Compare body (next round)

  • Compare refactoring in the body? (Next Round)

  • In general, it's found that detecting lower level refactoring first than higher-level refactoring would allow more refactorings since empirical studies have found that lower-level refactorings are more prevalent than higher level ones.

@mkshiblu mkshiblu self-assigned this May 19, 2020
@mkshiblu mkshiblu added this to the MILESTONE_MAY_31 milestone May 19, 2020
@tsantalis
Copy link
Collaborator

It is important to collect some empirical data to see how commonly developers declare functions with the same name and different number of arguments in the same file.
Maybe it is considered a bad practice, and developers avoid it.
Normally, the signature of a function should be the function name + the number of arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants