walkmod / walkmod-pmd-plugin

Walkmod plugin to fix the code according the PMD rules
2 stars 2 forks source link

used variable deleted #11

Open cal101 opened 7 years ago

cal101 commented 7 years ago
         // create window
-        JFrame mainFrame = getMainFrame();
         mainFrame.setTitle(resourceMap.getString("frameTitle"));
         mainFrame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
         mainFrame.setJMenuBar(buildMenubar());
rpau commented 7 years ago

Cal, probably is something more hard to find. I keep working on it

cal101 commented 7 years ago

I don't want to spend too much time extracting real test cases for everything. Let's do a first run of the bugs that are easy to reproduce (and to fix) and do a second run for the difficult ones where I can try to extract real test cases.
I don't plan to use the PMD plugin at all but just noticed a thing or two when playing with it.

rpau commented 7 years ago

Ok,

I have fixed some important issues and I think that most of those that you reported are pretty much related. Let's see what happens.

cal101 commented 7 years ago

Test case https://github.com/cal101/walkmod-misc/commit/328a3d173d6c7770cac220e474dc852bf3cc60ad

rpau commented 7 years ago

I have created a test for it and it does not break. When I print the source code is exactly the same https://github.com/walkmod/walkmod-pmd-plugin/commit/8781ce698709648f891147e039b542d887d6adca

cal101 commented 7 years ago

Did you try my test case?

git clone http://github.com/cal101/walkmod-misc.git
cd walkmod-misc/
git branch pmd-plugin-tests origin/pmd-plugin-tests
git checkout pmd-plugin-tests
rm -rf ~/.m2/repository
rm -rf ~/.ivy2
mvn compile
walkmod apply -e

git diff
diff --git a/src/main/java/de/walkmod/pmd/RemoveOfUsedVar1.java b/src/main/java/de/walkmod/pmd/RemoveOfUsedVar1.java
index 41956c6..878bfd4 100644
--- a/src/main/java/de/walkmod/pmd/RemoveOfUsedVar1.java
+++ b/src/main/java/de/walkmod/pmd/RemoveOfUsedVar1.java
@@ -7,8 +7,6 @@ import javax.swing.JTextField;
 public class RemoveOfUsedVar1 {

     private JTextField jYear;
-    private JTextField jMonth;
-    private JTextField jDay;

     public void setToday() {
           Calendar today = Calendar.getInstance();