mAttributeMap = Maps.newHashMap();
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheck.java
index 75885de45..1da256612 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheck.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheck.java
@@ -16,11 +16,11 @@
// 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.sizes;
-import com.puppycrawl.tools.checkstyle.api.Check;
-import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
+import java.io.File;
+import java.util.List;
/**
*
@@ -52,7 +52,7 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST;
*
* @author Lars Kühne
*/
-public class FileLengthCheck extends Check
+public class FileLengthCheck extends AbstractFileSetCheck
{
/** default maximum number of lines */
private static final int DEFAULT_MAX_LINES = 2000;
@@ -61,17 +61,10 @@ public class FileLengthCheck extends Check
private int mMaxFileLength = DEFAULT_MAX_LINES;
@Override
- public int[] getDefaultTokens()
+ protected void processFiltered(File aFile, List aLines)
{
- return new int[0];
- }
-
- @Override
- public void beginTree(DetailAST aRootAST)
- {
- final String[] lines = getLines();
- if (lines.length > mMaxFileLength) {
- log(1, "maxLen.file", lines.length, mMaxFileLength);
+ if (aLines.size() > mMaxFileLength) {
+ log(1, "maxLen.file", aLines.size(), mMaxFileLength);
}
}
diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java
index 69e2d1303..7ab69a3bd 100644
--- a/src/tests/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java
+++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java
@@ -1,37 +1,50 @@
package com.puppycrawl.tools.checkstyle.checks.sizes;
import static org.junit.Assert.fail;
+
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
+import com.puppycrawl.tools.checkstyle.api.Configuration;
import org.junit.Test;
public class FileLengthCheckTest
extends BaseCheckTestSupport
{
- private void runIt(String aMax, String[] aExpected) throws Exception
+ @Override
+ protected DefaultConfiguration createCheckerConfig(
+ Configuration aCheckConfig)
{
- final DefaultConfiguration checkConfig =
- createCheckConfig(FileLengthCheck.class);
- checkConfig.addAttribute("max", aMax);
- verify(checkConfig, getPath("InputSimple.java"), aExpected);
+ DefaultConfiguration dc = new DefaultConfiguration("root");
+ dc.addChild(aCheckConfig);
+ return dc;
}
@Test
public void testAlarm() throws Exception
{
+ DefaultConfiguration checkConfig =
+ createCheckConfig(FileLengthCheck.class);
+ checkConfig.addAttribute("max", "20");
final String[] expected = {
"1: File length is 225 lines (max allowed is 20)."
};
- runIt("20", expected);
+ verify(createChecker(checkConfig),
+ getPath("InputSimple.java"),
+ getPath("InputSimple.java"), expected);
}
@Test
public void testOK() throws Exception
{
+ DefaultConfiguration checkConfig =
+ createCheckConfig(FileLengthCheck.class);
+ checkConfig.addAttribute("max", "2000");
final String[] expected = {
};
- runIt("2000", expected);
+ verify(createChecker(checkConfig),
+ getPath("InputSimple.java"),
+ getPath("InputSimple.java"), expected);
}
@Test
diff --git a/src/xdocs/config_sizes.xml b/src/xdocs/config_sizes.xml
index cd680409f..e08f24124 100755
--- a/src/xdocs/config_sizes.xml
+++ b/src/xdocs/config_sizes.xml
@@ -130,7 +130,7 @@
- TreeWalker
+ Checker
diff --git a/src/xdocs/releasenotes.xml b/src/xdocs/releasenotes.xml
index e4f2333f1..ffd63f282 100755
--- a/src/xdocs/releasenotes.xml
+++ b/src/xdocs/releasenotes.xml
@@ -62,6 +62,10 @@
character. It replaces TabCharacterCheck which was
restricted to Java files.
+
+ Changed FileLength
+ check to be a FileSetCheck.
+
Fixed Bugs: