diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java index 60e56172e..772402ce5 100755 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java @@ -158,7 +158,9 @@ public class DeclarationOrderCheck extends Check state = mScopeStates.peek(); if (aAST.findFirstToken(TokenTypes.LITERAL_STATIC) != null) { if (state.mScopeState > STATE_STATIC_VARIABLE_DEF) { - if (!mIgnoreModifiers) { + if (!mIgnoreModifiers + || state.mScopeState > STATE_INSTANCE_VARIABLE_DEF) + { log(aAST, "declaration.order.static"); } } @@ -168,9 +170,7 @@ public class DeclarationOrderCheck extends Check } else { if (state.mScopeState > STATE_INSTANCE_VARIABLE_DEF) { - if (!mIgnoreModifiers) { - log(aAST, "declaration.order.instance"); - } + log(aAST, "declaration.order.instance"); } else if (state.mScopeState == STATE_STATIC_VARIABLE_DEF) { state.mDeclarationAccess = Scope.PUBLIC; diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java index 2a1b18fbb..b65506bc6 100755 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java @@ -72,8 +72,13 @@ public class DeclarationOrderCheckTest checkConfig.addAttribute("ignoreModifiers", "true"); final String[] expected = { + "45:9: Static variable definition in wrong order.", "54:5: Constructor definition in wrong order.", + "80:5: Instance variable definition in wrong order.", + "100:9: Static variable definition in wrong order.", + "143:9: Static variable definition in wrong order.", "152:5: Constructor definition in wrong order.", + "178:5: Instance variable definition in wrong order.", }; verify(checkConfig, getPath("coding/InputDeclarationOrder.java"), expected); } diff --git a/src/xdocs/releasenotes.xml b/src/xdocs/releasenotes.xml index 47c18f2cc..6c3dbf7e3 100755 --- a/src/xdocs/releasenotes.xml +++ b/src/xdocs/releasenotes.xml @@ -19,6 +19,11 @@

Bug fixes: