cleanup of checkstyle errors
This commit is contained in:
parent
19708f9811
commit
7f35e143a2
|
|
@ -94,7 +94,8 @@ public class DetailAST
|
|||
* Set the parent token.
|
||||
* @param aParent the parent token
|
||||
*/
|
||||
// TODO: Check visibility, could be private if set in setFirstChild() and friends
|
||||
// TODO: Check visibility, could be private
|
||||
// if set in setFirstChild() and friends
|
||||
public void setParent(DetailAST aParent)
|
||||
{
|
||||
mParent = aParent;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ import org.apache.commons.beanutils.ConversionException;
|
|||
*/
|
||||
public class HeaderCheck extends Check
|
||||
{
|
||||
private static int[] EMPTY_INT_ARRAY = new int[0];
|
||||
/** empty array to avoid instantiations */
|
||||
private static final int[] EMPTY_INT_ARRAY = new int[0];
|
||||
|
||||
/** the lines of the header file */
|
||||
private String[] mHeaderLines = null;
|
||||
|
|
@ -102,6 +103,7 @@ public class HeaderCheck extends Check
|
|||
|
||||
/**
|
||||
* Set the header file to check against.
|
||||
* @param aFileName the file that contains the header to check against.
|
||||
* @throws org.apache.commons.beanutils.ConversionException if
|
||||
* the file cannot be loaded
|
||||
*/
|
||||
|
|
@ -149,6 +151,10 @@ public class HeaderCheck extends Check
|
|||
Arrays.sort(mIgnoreLines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the header lines to check against.
|
||||
* @return the header lines to check against.
|
||||
*/
|
||||
protected String[] getHeaderLines()
|
||||
{
|
||||
return mHeaderLines;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,17 @@ import com.puppycrawl.tools.checkstyle.api.Check;
|
|||
import com.puppycrawl.tools.checkstyle.JavaTokenTypes;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
|
||||
/**
|
||||
* Checks that modifiers are written in the order suggested by
|
||||
* the Java Language Specification (JLS). The relevant sections
|
||||
* are 8.1.1, 8.3.1 and 8.4.3.
|
||||
* <p>
|
||||
* Rationale: Code is easier to read if everybody follows
|
||||
* a standard.
|
||||
* </p>
|
||||
*
|
||||
* @author Lars Kühne
|
||||
*/
|
||||
public class ModifierCheck
|
||||
extends Check
|
||||
{
|
||||
|
|
@ -72,6 +83,7 @@ public class ModifierCheck
|
|||
* Checks if the modifiers were added in the order suggested
|
||||
* in the Java language specification.
|
||||
*
|
||||
* @param aModifiers list of modifier AST tokens
|
||||
* @return null if the order is correct, otherwise returns the offending
|
||||
* * modifier AST.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,7 +27,12 @@ public class RegexpHeaderCheck extends HeaderCheck
|
|||
/** the compiled regular expressions */
|
||||
private RE[] mHeaderRegexps = null;
|
||||
|
||||
/** */
|
||||
/**
|
||||
* Sets the file that contains the header to check against.
|
||||
* @param aFileName the file that contains the header to check against.
|
||||
* @throws org.apache.commons.beanutils.ConversionException if
|
||||
* the file cannot be loaded or one line is not a regexp.
|
||||
*/
|
||||
public void setHeaderFile(String aFileName)
|
||||
{
|
||||
super.setHeaderFile(aFileName);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
|||
* Checks for overly complicated boolean return statements.
|
||||
*
|
||||
* Idea shamelessly stolen from the equivalent PMD rule (pmd.sourceforge.net).
|
||||
*
|
||||
* @author Lars Kühne
|
||||
*/
|
||||
public class SimplifyBooleanReturnCheck extends Check
|
||||
{
|
||||
|
|
@ -62,6 +64,26 @@ public class SimplifyBooleanReturnCheck extends Check
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if an AST is a return statment with a boolean literal
|
||||
* or a compound statement that contains only such a return statement.
|
||||
*
|
||||
* Returns <code>true</code> iff aAST represents
|
||||
* <br>
|
||||
* <pre>
|
||||
* return true/false;
|
||||
* <pre>
|
||||
* or
|
||||
* <br>
|
||||
* <pre>
|
||||
* {
|
||||
* return true/false;
|
||||
* }
|
||||
* <pre>
|
||||
*
|
||||
* @param aAST the sytax tree to check
|
||||
* @return if aAST is a return statment with a boolean literal.
|
||||
*/
|
||||
private boolean returnsOnlyBooleanLiteral(AST aAST)
|
||||
{
|
||||
if (isBooleanLiteralReturnStatement(aAST)) {
|
||||
|
|
@ -72,6 +94,18 @@ public class SimplifyBooleanReturnCheck extends Check
|
|||
return isBooleanLiteralReturnStatement(firstStmnt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if an AST is a return statment with a boolean literal.
|
||||
*
|
||||
* Returns <code>true</code> iff aAST represents
|
||||
* <br>
|
||||
* <pre>
|
||||
* return true/false;
|
||||
* <pre>
|
||||
*
|
||||
* @param aAST the sytax tree to check
|
||||
* @return if aAST is a return statment with a boolean literal.
|
||||
*/
|
||||
private boolean isBooleanLiteralReturnStatement(AST aAST)
|
||||
{
|
||||
if (aAST.getType() != JavaTokenTypes.LITERAL_return) {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ import antlr.collections.AST;
|
|||
* the public member regular expression.
|
||||
* </p>
|
||||
* Rationale: Enforce encapsulation.
|
||||
*
|
||||
* @author Lars Kühne
|
||||
*/
|
||||
public class VisibilityModifierCheck
|
||||
extends Check
|
||||
|
|
@ -50,7 +52,8 @@ public class VisibilityModifierCheck
|
|||
/** whether package visible members are allowed */
|
||||
private boolean mPackageAllowed = false;
|
||||
|
||||
// TODO: Now that EJB 1.1 is becoming obsolete (is it?) we should change the default to "^$"
|
||||
// TODO: we should change the default to "^$"
|
||||
// as EJB 1.1 is becoming obsolete (is it?)
|
||||
/** pattern for public members that should be ignored */
|
||||
private String mPublicMemberPattern = "^f[A-Z][a-zA-Z0-9]*$";
|
||||
|
||||
|
|
@ -144,7 +147,8 @@ public class VisibilityModifierCheck
|
|||
|| mods.contains("static") && mods.contains("final")
|
||||
|| "package".equals(variableScope) && isPackageAllowed()
|
||||
|| "protected".equals(variableScope) && isProtectedAllowed()
|
||||
|| "public".equals(variableScope) && getPublicMemberRegexp().match(varName)))
|
||||
|| "public".equals(variableScope)
|
||||
&& getPublicMemberRegexp().match(varName)))
|
||||
{
|
||||
log(varNameAST.getLineNo(), varNameAST.getColumnNo(),
|
||||
"variable.notPrivate", varName);
|
||||
|
|
@ -191,8 +195,8 @@ public class VisibilityModifierCheck
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the set of modifier Strings for a VARIABLE_DEF AST
|
||||
* @param variableDefAST
|
||||
* Returns the set of modifier Strings for a VARIABLE_DEF AST.
|
||||
* @param variableDefAST AST for a vraiable definition
|
||||
* @return the set of modifier Strings for variableDefAST
|
||||
*/
|
||||
private Set getModifiers(DetailAST variableDefAST)
|
||||
|
|
|
|||
|
|
@ -128,8 +128,8 @@ public class JTreeTable extends JTable
|
|||
*/
|
||||
public int getEditingRow()
|
||||
{
|
||||
return (getColumnClass(editingColumn) == TreeTableModel.class) ? -1 :
|
||||
editingRow;
|
||||
final Class editingClass = getColumnClass(editingColumn);
|
||||
return (editingClass == TreeTableModel.class) ? -1 : editingRow;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -144,7 +144,7 @@ public class JTreeTable extends JTable
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the tree that is being shared between the model.
|
||||
* @return the tree that is being shared between the model.
|
||||
*/
|
||||
public JTree getTree()
|
||||
{
|
||||
|
|
@ -154,12 +154,13 @@ public class JTreeTable extends JTable
|
|||
/**
|
||||
* A TreeCellRenderer that displays a JTree.
|
||||
*/
|
||||
public class TreeTableCellRenderer extends JTree implements
|
||||
class TreeTableCellRenderer extends JTree implements
|
||||
TableCellRenderer
|
||||
{
|
||||
/** Last table/tree row asked to renderer. */
|
||||
protected int visibleRow;
|
||||
|
||||
/** creates a new instance */
|
||||
public TreeTableCellRenderer(TreeModel model)
|
||||
{
|
||||
super(model);
|
||||
|
|
@ -223,6 +224,7 @@ public class JTreeTable extends JTable
|
|||
|
||||
/**
|
||||
* TreeCellRenderer method. Overridden to update the visible row.
|
||||
* @see TableCellRenderer
|
||||
*/
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
Object value,
|
||||
|
|
@ -230,10 +232,11 @@ public class JTreeTable extends JTable
|
|||
boolean hasFocus,
|
||||
int row, int column)
|
||||
{
|
||||
if (isSelected)
|
||||
if (isSelected) {
|
||||
setBackground(table.getSelectionBackground());
|
||||
else
|
||||
} else {
|
||||
setBackground(table.getBackground());
|
||||
}
|
||||
|
||||
visibleRow = row;
|
||||
return this;
|
||||
|
|
@ -273,6 +276,8 @@ public class JTreeTable extends JTable
|
|||
* that wouldn't be the case.
|
||||
* <p>By returning false we are also enforcing the policy that
|
||||
* the tree will never be editable (at least by a key sequence).
|
||||
*
|
||||
* @see TableCellEditor
|
||||
*/
|
||||
public boolean isCellEditable(EventObject e)
|
||||
{
|
||||
|
|
@ -318,6 +323,8 @@ public class JTreeTable extends JTable
|
|||
* Returns the list selection model. ListToTreeSelectionModelWrapper
|
||||
* listens for changes to this model and updates the selected paths
|
||||
* accordingly.
|
||||
*
|
||||
* @return the list selection model
|
||||
*/
|
||||
ListSelectionModel getListSelectionModel()
|
||||
{
|
||||
|
|
@ -349,7 +356,7 @@ public class JTreeTable extends JTable
|
|||
/**
|
||||
* Creates and returns an instance of ListSelectionHandler.
|
||||
*/
|
||||
protected ListSelectionListener createListSelectionListener()
|
||||
private ListSelectionListener createListSelectionListener()
|
||||
{
|
||||
return new ListSelectionHandler();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -310,7 +310,6 @@ public class CheckerTest
|
|||
public void testIgnoreAccess()
|
||||
throws Exception
|
||||
{
|
||||
mProps.setProperty(Defn.PUBLIC_MEMBER_PATTERN_PROP, "^r[A-Z]");
|
||||
mProps.setProperty(Defn.ALLOW_PROTECTED_PROP, "true");
|
||||
mProps.setProperty(Defn.ALLOW_PACKAGE_PROP, "true");
|
||||
final Checker c = createChecker();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,22 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2002 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.checks.MethodLengthCheck;
|
||||
|
|
|
|||
Loading…
Reference in New Issue