TruX-DTF / debug-method-name

Learning to Spot and Refactor Inconsistent Method Names
16 stars 17 forks source link

How to judge if the name and body become stable after a change #34

Open lzl-cmd opened 2 years ago

lzl-cmd commented 2 years ago

Hi Kui,

I am one of your fans. Thanks for your great work! Recently I am performing a project based on your work. I have a question that needs your help.

In your paper, you introduced that a renamed method name would be collected if (1) the method body is not changed, and (2) the method name and body become stable after the change.

After reading the code, I find that the first condition is ensured by the following line https://github.com/TruX-DTF/debug-method-name/blob/fb1f87ffd923ef987aad8521ab9be8b747ca50c5/RenamedMethodsCollector/src/main/java/edu/lu/uni/serval/renamed/methods/CodeChangeParser.java#L88

but I did not find the corresponding code towards the second condition. I would appreciate it if you could give me some clues. Thanks in advance!

Kui-Liu commented 2 years ago

Hello @lzl-cmd , Thanks for your interests in our work. For the first condition, it can be done by your mentioned code, which will collect the modified method names from all commits, where we will collect the method signature for each collected method. A method might be changed multiple times. So, with the method signatures, we can identify whether a collectted modified method was modified multiple times or not. If a collected method method modified times, we will consider the one modified in the latest time, others will be discarded.

lzl-cmd commented 2 years ago

Thanks for your replying! With the help of your hint, I found these https://github.com/TruX-DTF/debug-method-name/blob/fb1f87ffd923ef987aad8521ab9be8b747ca50c5/RenamedMethodsCollector/src/main/java/edu/lu/uni/serval/renamed/methods/CodeChangeParser.java#L48 https://github.com/TruX-DTF/debug-method-name/blob/fb1f87ffd923ef987aad8521ab9be8b747ca50c5/RenamedMethodsCollector/src/main/java/edu/lu/uni/serval/renamed/methods/CodeChangeParser.java#L49 https://github.com/TruX-DTF/debug-method-name/blob/fb1f87ffd923ef987aad8521ab9be8b747ca50c5/RenamedMethodsCollector/src/main/java/edu/lu/uni/serval/renamed/methods/CodeChangeParser.java#L54 But I'm still not sure whether these three judgements can finish the job. Could you show me more details? Thanks in advance!

Kui-Liu commented 2 years ago

I didn't touch the code for a long time, I do not remember so many details any more. I am sorry for that. I am sure that, if you execute the RenameMethodsCollector, all judgements will be finished to collect the correct data.

lzl-cmd commented 2 years ago

NewMethodNames.txt OldMethodNames.txt

I run the RenamedMethodsCollector with the first repository(abdera), and get the above results, I find that the first two method renames are quite similar: image image

so I print the commit's path out and find the concrete commits in the 1.Data/Output/Commit_Diffs/abdera/revFiles/fa61c6_108201_server#src#main#java#org#apache#abdera#server#AbderaServerException.java 2.Data/Output/Commit_Diffs/abdera/prevFile/prev_fa61c6_108201_server#src#main#java#org#apache#abdera#server#AbderaServerException.java 3.Data/Output/Commit_Diffs/abdera/revFiles/108201_1c6007_server#src#main#java#org#apache#abdera#server#AbderaServerException.java 4.Data/Output/Commit_Diffs/abdera/prevFile/prev_108201_1c6007_server#src#main#java#org#apache#abdera#server#AbderaServerException.java

fa61c6_108201_server#src#main#java#org#apache#abdera#server#AbderaServerException.txt prev_108201_1c6007_server#src#main#java#org#apache#abdera#server#AbderaServerException.txt prev_fa61c6_108201_server#src#main#java#org#apache#abdera#server#AbderaServerException.txt 108201_1c6007_server#src#main#java#org#apache#abdera#server#AbderaServerException.txt

From the commits' history, I guess that the original commit is 1c6007, after which the method:

public boolean hasEntity() { return false; } which was changed in the commit 108201 into: public boolean hasOutput() { return false; } . And this method was changed from hasOutput to hasEntity again in the commit fa61c6: public boolean hasEntity() { return false; }

But from the commit changes I found, the filter seems to fail in getting the renamed methods that are stable after changing. I would highly appreciate it if you could help me check this case. Thanks in advance!