From 65dfd54ad6b015eff78160b9fb3202a1c22fcebd Mon Sep 17 00:00:00 2001 From: Xavier Le Vourch Date: Sun, 26 Oct 2008 19:41:32 +0000 Subject: [PATCH] code cleanup: AvoidConstantsInterface rule is now part of the dogfood ruleset git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6681 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/rulesets/internal/dogfood.xml | 1 - .../sourceforge/pmd/lang/dfa/NodeType.java | 48 +++++++++---------- .../pmd/util/NumericConstants.java | 12 +++-- .../pmd/util/viewer/gui/ActionCommands.java | 7 ++- .../pmd/util/viewer/gui/MainFrame.java | 11 ++--- 5 files changed, 39 insertions(+), 40 deletions(-) diff --git a/pmd/rulesets/internal/dogfood.xml b/pmd/rulesets/internal/dogfood.xml index 64c698b438..1646d28c0c 100644 --- a/pmd/rulesets/internal/dogfood.xml +++ b/pmd/rulesets/internal/dogfood.xml @@ -80,7 +80,6 @@ - diff --git a/pmd/src/net/sourceforge/pmd/lang/dfa/NodeType.java b/pmd/src/net/sourceforge/pmd/lang/dfa/NodeType.java index 2156fb977c..0f0bfd25f0 100644 --- a/pmd/src/net/sourceforge/pmd/lang/dfa/NodeType.java +++ b/pmd/src/net/sourceforge/pmd/lang/dfa/NodeType.java @@ -7,37 +7,37 @@ package net.sourceforge.pmd.lang.dfa; * @author raik */ // TODO This should be an enum? -public interface NodeType { +public class NodeType { - int IF_EXPR = 1; - int IF_LAST_STATEMENT = 2; - int IF_LAST_STATEMENT_WITHOUT_ELSE = 3; - int ELSE_LAST_STATEMENT = 4; + public static final int IF_EXPR = 1; + public static final int IF_LAST_STATEMENT = 2; + public static final int IF_LAST_STATEMENT_WITHOUT_ELSE = 3; + public static final int ELSE_LAST_STATEMENT = 4; - int WHILE_EXPR = 10; - int WHILE_LAST_STATEMENT = 11; + public static final int WHILE_EXPR = 10; + public static final int WHILE_LAST_STATEMENT = 11; - int SWITCH_START = 20; - int CASE_LAST_STATEMENT = 21; - int SWITCH_LAST_DEFAULT_STATEMENT = 22; - int SWITCH_END = 23; + public static final int SWITCH_START = 20; + public static final int CASE_LAST_STATEMENT = 21; + public static final int SWITCH_LAST_DEFAULT_STATEMENT = 22; + public static final int SWITCH_END = 23; - int FOR_INIT = 30; - int FOR_EXPR = 31; - int FOR_UPDATE = 32; - int FOR_BEFORE_FIRST_STATEMENT = 33; - int FOR_END = 34; + public static final int FOR_INIT = 30; + public static final int FOR_EXPR = 31; + public static final int FOR_UPDATE = 32; + public static final int FOR_BEFORE_FIRST_STATEMENT = 33; + public static final int FOR_END = 34; - int DO_BEFORE_FIRST_STATEMENT = 40; - int DO_EXPR = 41; + public static final int DO_BEFORE_FIRST_STATEMENT = 40; + public static final int DO_EXPR = 41; - int RETURN_STATEMENT = 50; - int BREAK_STATEMENT = 51; - int CONTINUE_STATEMENT = 52; + public static final int RETURN_STATEMENT = 50; + public static final int BREAK_STATEMENT = 51; + public static final int CONTINUE_STATEMENT = 52; - int LABEL_STATEMENT = 60; - int LABEL_LAST_STATEMENT = 61; + public static final int LABEL_STATEMENT = 60; + public static final int LABEL_LAST_STATEMENT = 61; // TODO - throw statements? - int THROW_STATEMENT = 70; + public static final int THROW_STATEMENT = 70; } diff --git a/pmd/src/net/sourceforge/pmd/util/NumericConstants.java b/pmd/src/net/sourceforge/pmd/util/NumericConstants.java index 972d79ac2e..ab4d15e62c 100644 --- a/pmd/src/net/sourceforge/pmd/util/NumericConstants.java +++ b/pmd/src/net/sourceforge/pmd/util/NumericConstants.java @@ -1,9 +1,11 @@ package net.sourceforge.pmd.util; -public interface NumericConstants { +public class NumericConstants { + + public static final Integer ZERO = 0; + + public static final Integer ONE = 1; + + public static final Float FLOAT_ZERO = new Float(0.0f); - Integer ZERO = 0; - Integer ONE = 1; - - Float FLOAT_ZERO = new Float(0.0f); } diff --git a/pmd/src/net/sourceforge/pmd/util/viewer/gui/ActionCommands.java b/pmd/src/net/sourceforge/pmd/util/viewer/gui/ActionCommands.java index 095d7d1842..80cfb865b7 100644 --- a/pmd/src/net/sourceforge/pmd/util/viewer/gui/ActionCommands.java +++ b/pmd/src/net/sourceforge/pmd/util/viewer/gui/ActionCommands.java @@ -4,10 +4,9 @@ package net.sourceforge.pmd.util.viewer.gui; * contains action command constants * * @author Boris Gruschko ( boris at gruschko.org ) - * @version $Id$ */ -public interface ActionCommands { - String COMPILE_ACTION = "Compile"; - String EVALUATE_ACTION = "Evaluate"; +public final class ActionCommands { + public static final String COMPILE_ACTION = "Compile"; + public static final String EVALUATE_ACTION = "Evaluate"; } diff --git a/pmd/src/net/sourceforge/pmd/util/viewer/gui/MainFrame.java b/pmd/src/net/sourceforge/pmd/util/viewer/gui/MainFrame.java index 05daac000d..7d766fe3a4 100644 --- a/pmd/src/net/sourceforge/pmd/util/viewer/gui/MainFrame.java +++ b/pmd/src/net/sourceforge/pmd/util/viewer/gui/MainFrame.java @@ -29,12 +29,11 @@ import net.sourceforge.pmd.util.viewer.util.NLS; * viewer's main frame * * @author Boris Gruschko ( boris at gruschko.org ) - * @version $Id$ */ public class MainFrame extends JFrame - implements ActionListener, ActionCommands, ViewerModelListener { + implements ActionListener, ViewerModelListener { private ViewerModel model; private SourceCodePanel sourcePanel; private XPathPanel xPathPanel; @@ -68,10 +67,10 @@ public class MainFrame interactionsPane.add(editingPane, BorderLayout.CENTER); getContentPane().add(interactionsPane, BorderLayout.CENTER); JButton compileBtn = new JButton(NLS.nls("MAIN.FRAME.COMPILE_BUTTON.TITLE")); - compileBtn.setActionCommand(COMPILE_ACTION); + compileBtn.setActionCommand(ActionCommands.COMPILE_ACTION); compileBtn.addActionListener(this); evalBtn = new JButton(NLS.nls("MAIN.FRAME.EVALUATE_BUTTON.TITLE")); - evalBtn.setActionCommand(EVALUATE_ACTION); + evalBtn.setActionCommand(ActionCommands.EVALUATE_ACTION); evalBtn.addActionListener(this); evalBtn.setEnabled(false); statusLbl = new JLabel(); @@ -134,7 +133,7 @@ public class MainFrame String command = e.getActionCommand(); long t0; long t1; - if (command.equals(COMPILE_ACTION)) { + if (ActionCommands.COMPILE_ACTION.equals(command)) { try { t0 = System.currentTimeMillis(); model.commitSource(sourcePanel.getSourceCode(), getLanguageVersion()); @@ -144,7 +143,7 @@ public class MainFrame setStatus(NLS.nls("MAIN.FRAME.COMPILATION.PROBLEM") + " " + exc.toString()); new ParseExceptionHandler(this, exc); } - } else if (command.equals(EVALUATE_ACTION)) { + } else if (ActionCommands.EVALUATE_ACTION.equals(command)) { try { t0 = System.currentTimeMillis(); model.evaluateXPathExpression(xPathPanel.getXPathExpression(), this);