added support for IgnoreBraces property

This commit is contained in:
Oliver Burn 2001-07-02 06:23:24 +00:00
parent ba46163e7c
commit be6d271ac3
5 changed files with 52 additions and 0 deletions

View File

@ -1,3 +1,17 @@
2001-07-02 Oliver Burn <oliver-work@puppycrawl.com>
* src/checkstyle/com/puppycrawl/tools/checkstyle/VerifierImpl.java:
Added support for the IgnoreBraces property.
* src/checkstyle/com/puppycrawl/tools/checkstyle/Defn.java: Added
IGNORE_BRACES_PROP.
* src/checkstyle/com/puppycrawl/tools/checkstyle/Configuration.java:
Added IgnoreBraces property.
* src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java: Added test
for IgnoreBraces property.
2001-06-30 Oliver Burn <checkstyle@puppycrawl.com>
* src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java:

View File

@ -95,6 +95,8 @@ class Configuration
private boolean mIgnoreImports = false;
/** whether to ignore whitespace **/
private boolean mIgnoreWhitespace = false;
/** whether to ignore braces **/
private boolean mIgnoreBraces = false;
/** the header lines to check for **/
private String[] mHeaderLines = {};
@ -143,6 +145,9 @@ class Configuration
getBooleanProperty(aProps,
IGNORE_WHITESPACE_PROP,
mIgnoreWhitespace));
setIgnoreBraces(getBooleanProperty(aProps,
IGNORE_BRACES_PROP,
mIgnoreBraces));
setHeaderIgnoreLineNo(
getIntProperty(aProps, aLog, HEADER_IGNORE_LINE_PROP,
mHeaderIgnoreLineNo));
@ -282,6 +287,12 @@ class Configuration
return mIgnoreWhitespace;
}
/** @return whether to ignore checks for braces **/
boolean isIgnoreBraces()
{
return mIgnoreBraces;
}
/** @return the header lines to check for **/
String[] getHeaderLines()
{
@ -409,6 +420,14 @@ class Configuration
mIgnoreWhitespace = aTo;
}
/**
* @param aTo whether to ignore checks for braces
*/
void setIgnoreBraces(boolean aTo)
{
mIgnoreBraces = aTo;
}
/**
* @param aFileName the header lines to check for
* @throws FileNotFoundException if an error occurs

View File

@ -52,4 +52,6 @@ interface Defn
String IGNORE_IMPORTS_PROP = "checkstyle.ignore.imports";
/** property name for ignoring whitespace **/
String IGNORE_WHITESPACE_PROP = "checkstyle.ignore.whitespace";
/** property name for ignoring braces **/
String IGNORE_BRACES_PROP = "checkstyle.ignore.braces";
}

View File

@ -313,6 +313,10 @@ class VerifierImpl
String aConstruct,
int aLineNo)
{
if (mConfig.isIgnoreBraces()) {
return;
}
if (!"{".equals(aText) && !(aAllowIf && "if".equals(aText))) {
log(aLineNo, "'" + aConstruct + "' construct must use '{}'s.");
}

View File

@ -105,6 +105,19 @@ public class CheckerTest
verify(c, "InputBraces.java", expected);
}
public void testBracesOff()
throws Exception
{
mConfig.setIgnoreBraces(true);
final Checker c = new Checker(mConfig, mStream);
final String[] expected = {
"InputBraces.java:41: ';' is not preceeded with whitespace.",
"InputBraces.java:58: ';' is not preceeded with whitespace.",
"InputBraces.java:81: ';' is not preceeded with whitespace.",
};
verify(c, "InputBraces.java", expected);
}
public void testTags()
throws Exception
{