diff --git a/ChangeLog b/ChangeLog index 54a99cba0..c4eeacdcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2001-07-02 Oliver Burn + + * 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 * src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java: diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/Configuration.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/Configuration.java index 447763649..2bcf5d435 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/Configuration.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/Configuration.java @@ -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 diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/Defn.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/Defn.java index aa101fe08..d5290e12d 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/Defn.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/Defn.java @@ -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"; } diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/VerifierImpl.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/VerifierImpl.java index 849449dc2..e06d21d53 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/VerifierImpl.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/VerifierImpl.java @@ -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."); } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java index 36ad6e4db..fab35ecf0 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java @@ -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 {