diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7bccb2fbbe..6e4c03f874 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -98,6 +98,7 @@ Other languages are equivalent. * all * [#695](https://github.com/pmd/pmd/issues/695): \[core] Extend comment-based suppression to all JavaCC languages * [#988](https://github.com/pmd/pmd/issues/988): \[core] FileNotFoundException for missing classes directory with analysis cache enabled + * [#1036](https://github.com/pmd/pmd/issues/1036): \[core] Non-XML output breaks XML-based CLI integrations * documentation * [#994](https://github.com/pmd/pmd/issues/994): \[doc] Delete duplicate page contributing.md on the website * java diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java index adb01dc245..9555c86d21 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java @@ -15,7 +15,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -import java.util.logging.Handler; +import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; @@ -45,7 +45,6 @@ import net.sourceforge.pmd.util.database.DBURI; import net.sourceforge.pmd.util.database.SourceObject; import net.sourceforge.pmd.util.datasource.DataSource; import net.sourceforge.pmd.util.datasource.ReaderDataSource; -import net.sourceforge.pmd.util.log.ConsoleLogHandler; import net.sourceforge.pmd.util.log.ScopedLogHandlersManager; /** @@ -450,8 +449,7 @@ public class PMD { final PMDConfiguration configuration = params.toConfiguration(); final Level logLevel = params.isDebug() ? Level.FINER : Level.INFO; - final Handler logHandler = new ConsoleLogHandler(); - final ScopedLogHandlersManager logHandlerManager = new ScopedLogHandlersManager(logLevel, logHandler); + final ScopedLogHandlersManager logHandlerManager = new ScopedLogHandlersManager(logLevel, new ConsoleHandler()); final Level oldLogLevel = LOG.getLevel(); // Need to do this, since the static logger has already been initialized // at this point diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java index dbca59a615..ad5d8cee58 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java @@ -351,7 +351,7 @@ public class CPDConfiguration extends AbstractConfiguration { } } - FilenameFilter filter = new FilenameFilter() { + return new FilenameFilter() { @Override public boolean accept(File dir, String name) { File f = new File(dir, name); @@ -362,7 +362,6 @@ public class CPDConfiguration extends AbstractConfiguration { return languageFilter.accept(dir, name); } }; - return filter; } /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java index 3f568c430f..c51770960f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java @@ -720,7 +720,7 @@ public class GUI implements CPDListener { final long start = System.currentTimeMillis(); - Timer t = new Timer(1000, new ActionListener() { + return new Timer(1000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { long now = System.currentTimeMillis(); @@ -731,7 +731,6 @@ public class GUI implements CPDListener { timeField.setText(formatTime(minutes, seconds)); } }); - return t; } private static String formatTime(long minutes, long seconds) { @@ -762,7 +761,7 @@ public class GUI implements CPDListener { private TableModel tableModelFrom(final List items) { - TableModel model = new SortingTableModel() { + return new SortingTableModel() { private int sortColumn; private boolean sortDescending; @@ -837,8 +836,6 @@ public class GUI implements CPDListener { } } }; - - return model; } private void sortOnColumn(int columnIndex) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/Designer.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/Designer.java index a70f3fbc67..c82c81353d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/Designer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/Designer.java @@ -312,7 +312,7 @@ public class Designer implements ClipboardOwner { @Override public Enumeration children() { - Enumeration e = new Enumeration() { + return new Enumeration() { int i = 0; @Override @@ -325,7 +325,6 @@ public class Designer implements ClipboardOwner { return kids[i++]; } }; - return e; } @Override @@ -395,7 +394,7 @@ public class Designer implements ClipboardOwner { getChildAt(0); // force it to build kids } - Enumeration e = new Enumeration() { + return new Enumeration() { int i = 0; @Override @@ -408,7 +407,6 @@ public class Designer implements ClipboardOwner { return kids[i++]; } }; - return e; } @Override diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ConsoleLogHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ConsoleLogHandler.java index 42c0389f90..8e61d3d27b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ConsoleLogHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ConsoleLogHandler.java @@ -14,7 +14,9 @@ import java.util.logging.LogRecord; * Log to the console using a basic formatter. * * @author Wouter Zelle + * @deprecated This class will be complety removed in 7.0.0 */ +@Deprecated public class ConsoleLogHandler extends Handler { private static final Formatter FORMATTER = new PmdLogFormatter(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ScopedLogHandlersManager.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ScopedLogHandlersManager.java index c6e26b6dda..53cb824944 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ScopedLogHandlersManager.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ScopedLogHandlersManager.java @@ -36,7 +36,9 @@ public class ScopedLogHandlersManager { } for (Handler handler : newHandlers) { logger.addHandler(handler); + handler.setLevel(level); } + logger.setUseParentHandlers(false); } public void close() { @@ -47,5 +49,6 @@ public class ScopedLogHandlersManager { logger.addHandler(handler); } logger.setLevel(oldLogLevel); + logger.setUseParentHandlers(true); } }