Moved across the check for upper case ell
This commit is contained in:
parent
e77f0c5c6e
commit
563f76592d
|
|
@ -475,7 +475,6 @@ public class Checker
|
|||
new String[] {te.getMessage()}));
|
||||
}
|
||||
|
||||
System.out.println("mMessages.size() = " + mMessages.size());
|
||||
if (mMessages.size() == 0) {
|
||||
mCache.checkedOk(aFileName, timestamp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -658,12 +658,6 @@ public class Configuration
|
|||
return getBooleanProperty(Defn.IGNORE_BRACES_PROP);
|
||||
}
|
||||
|
||||
/** @return whether to ignore long 'L' **/
|
||||
boolean isIgnoreLongEll()
|
||||
{
|
||||
return getBooleanProperty(Defn.IGNORE_LONG_ELL_PROP);
|
||||
}
|
||||
|
||||
/** @return whether to ignore 'public' keyword in interface definitions **/
|
||||
boolean isIgnorePublicInInterface()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -102,8 +102,6 @@ public interface Defn
|
|||
String IGNORE_CAST_WHITESPACE_PROP = "checkstyle.ignore.whitespace.cast";
|
||||
/** property name for ignoring braces **/
|
||||
String IGNORE_BRACES_PROP = "checkstyle.ignore.braces";
|
||||
/** property name for ignoring long 'L' **/
|
||||
String IGNORE_LONG_ELL_PROP = "checkstyle.ignore.longell";
|
||||
/** property name for ignoring 'public' in interface definitions **/
|
||||
String IGNORE_PUBLIC_IN_INTERFACE_PROP =
|
||||
"checkstyle.ignore.public.in.interface";
|
||||
|
|
@ -151,7 +149,6 @@ public interface Defn
|
|||
IGNORE_CAST_WHITESPACE_PROP,
|
||||
IGNORE_IMPORTS_PROP,
|
||||
IGNORE_IMPORT_LENGTH_PROP,
|
||||
IGNORE_LONG_ELL_PROP,
|
||||
IGNORE_PUBLIC_IN_INTERFACE_PROP,
|
||||
IGNORE_WHITESPACE_PROP,
|
||||
JAVADOC_CHECK_UNUSED_THROWS_PROP,
|
||||
|
|
|
|||
|
|
@ -1067,11 +1067,6 @@ class Verifier
|
|||
*/
|
||||
void verifyLongEll(int aLineNo, int aColNo)
|
||||
{
|
||||
if (!mConfig.isIgnoreLongEll()
|
||||
&& (mLines[aLineNo - 1].charAt(aColNo) == 'l'))
|
||||
{
|
||||
mMessages.add(aLineNo, aColNo, "upperEll");
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
|
|
|||
|
|
@ -272,6 +272,18 @@ public abstract class Check
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to log a LocalizedMessage.
|
||||
*
|
||||
* @param aLineNo line number to associate with the message
|
||||
* @param aColNo column number to associate with the message
|
||||
* @param aKey key to locale message format
|
||||
*/
|
||||
public void log(int aLineNo, int aColNo, String aKey)
|
||||
{
|
||||
log(aLineNo, aColNo, aKey, EMPTY_OBJECT_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to log a LocalizedMessage.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
|||
* @author Oliver Burn
|
||||
* @version 1.0
|
||||
*/
|
||||
public class AvoidStarImport extends ImportCheck
|
||||
public class AvoidStarImport
|
||||
extends ImportCheck
|
||||
{
|
||||
public int[] getDefaultTokens()
|
||||
{
|
||||
|
|
@ -43,7 +44,6 @@ public class AvoidStarImport extends ImportCheck
|
|||
{
|
||||
final String name = getImportText(aAST);
|
||||
if ((name != null) && name.endsWith(".*")) {
|
||||
System.out.println("AvoidStarImport.visitToken");
|
||||
log(aAST.getLineNo(), "import.avoidStar");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.JavaTokenTypes;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.Check;
|
||||
|
||||
/**
|
||||
* Checks that long constants are defined with an uppper ell. That is 'L' and
|
||||
* not 'l'.
|
||||
*
|
||||
* <p> Rationale: The letter l looks a lot like 1.
|
||||
*
|
||||
* @author Oliver Burn
|
||||
* @version 1.0
|
||||
*/
|
||||
public class UpperEllCheck
|
||||
extends Check
|
||||
{
|
||||
public int[] getDefaultTokens()
|
||||
{
|
||||
return new int[] {JavaTokenTypes.NUM_LONG};
|
||||
}
|
||||
|
||||
public void visitToken(DetailAST aAST)
|
||||
{
|
||||
if (aAST.getText().endsWith("l")) {
|
||||
log(aAST.getLineNo(),
|
||||
aAST.getColumnNo() + aAST.getText().length() - 1,
|
||||
"upperEll");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -881,7 +881,6 @@ public class CheckerTest
|
|||
mProps.setProperty(Defn.CATCH_BLOCK_PROP, BlockOption.STMT.toString());
|
||||
mProps.setProperty(Defn.FINALLY_BLOCK_PROP, BlockOption.STMT.toString());
|
||||
mProps.setProperty(Defn.IGNORE_IMPORTS_PROP, "true");
|
||||
mProps.setProperty(Defn.IGNORE_LONG_ELL_PROP, "false");
|
||||
mProps.setProperty(
|
||||
Defn.ILLEGAL_INSTANTIATIONS_PROP,
|
||||
"java.lang.Boolean,"
|
||||
|
|
@ -908,7 +907,6 @@ public class CheckerTest
|
|||
filepath + ":76:17: Must have at least one statement.",
|
||||
filepath + ":78:13: Must have at least one statement.",
|
||||
filepath + ":81:17: Must have at least one statement.",
|
||||
filepath + ":93:43: Should use uppercase 'L'.",
|
||||
};
|
||||
verify(c, filepath, expected);
|
||||
}
|
||||
|
|
@ -922,7 +920,6 @@ public class CheckerTest
|
|||
mProps.setProperty(Defn.CATCH_BLOCK_PROP, BlockOption.TEXT.toString());
|
||||
mProps.setProperty(Defn.FINALLY_BLOCK_PROP, BlockOption.TEXT.toString());
|
||||
mProps.setProperty(Defn.IGNORE_IMPORTS_PROP, "true");
|
||||
mProps.setProperty(Defn.IGNORE_LONG_ELL_PROP, "true");
|
||||
mProps.setProperty(Defn.ILLEGAL_INSTANTIATIONS_PROP, "");
|
||||
final Checker c = createChecker();
|
||||
final String filepath = getPath("InputSemantic.java");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.checks.UpperEllCheck;
|
||||
|
||||
public class UpperEllCheckTest
|
||||
extends BaseCheckTestCase
|
||||
{
|
||||
public UpperEllCheckTest(String aName)
|
||||
{
|
||||
super(aName);
|
||||
}
|
||||
|
||||
public void testWithChecker()
|
||||
throws Exception
|
||||
{
|
||||
final CheckConfiguration checkConfig = new CheckConfiguration();
|
||||
checkConfig.setClassname(UpperEllCheck.class.getName());
|
||||
final Checker c = createChecker(checkConfig);
|
||||
final String fname = getPath("InputSemantic.java");
|
||||
final String[] expected = {
|
||||
"93:43: Should use uppercase 'L'.",
|
||||
};
|
||||
verify(c, fname, expected);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue