walkmod / walkmod-pmd-plugin

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

Code surrounded by if(true) is lost #3

Closed cal101 closed 7 years ago

cal101 commented 7 years ago
-            if (true) {
-                System.out.println("hello");
-            }
rpau commented 7 years ago

Thanks 👍

rpau commented 7 years ago

I have written a test in this plugin and works. So, It is something regarding the phase where walkmod defines the minimum set of changes to write. I keep working on it

cal101 commented 7 years ago

I simplified the case. The original has much more code inside. If you get stuck I can redo the test and try to produce a real single test case. I just wanted to avoid the seemingly unnessasary work ;-)

rpau commented 7 years ago

Issue fixed at 9d56f0654ea3bebed5ecebae2343e13a239db678

cal101 commented 7 years ago

Line handling is a bid weird.

if (true) {
   1
   2
}

3

becomes

   1

2
3
cal101 commented 7 years ago

Not completely fixed:

     @Override
     public EpsData create(InputStream in, ParsingState cur) throws IOException, IllegalFileException {
-        if(true) {
             throw new UncheckedSystemException("not implemented");
-        }
         return null;
     }

If the "if" is to be removed so is the "return null" then. False positives of pmd may be a problem here.