Author: rdonkin
Date: Fri Dec 6 17:58:17 2013
New Revision: 1548626
URL: http://svn.apache.org/r1548626
Log:
Apply PMD Rules.
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java?rev=1548626&r1=1548625&r2=1548626&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java
Fri Dec 6 17:58:17 2013
@@ -29,41 +29,54 @@ import org.apache.rat.analysis.IHeaderMa
import org.apache.rat.api.Document;
import org.apache.rat.document.MockLocation;
import org.apache.rat.test.utils.Resources;
-import org.junit.Assert;
/**
* The Class DirectoryScanner.
*/
-class DirectoryScanner {
+final class DirectoryScanner {
+
+ private static final int ZERO = 0;
+
+ /**
+ *
+ */
+ private DirectoryScanner() {
+ super();
+ }
- @SuppressWarnings("boxing")
/**
* Get list of files in a directory, and scan for license matches
- * @param directory the directory containing the files
- * @param matcher the license matcher
- * @param expected the expected result of the each scan
+ *
+ * @param directory
+ * the directory containing the files
+ * @param matcher
+ * the license matcher
+ * @param expected
+ * the expected result of the each scan
* @throws IOException
*/
- public static void testFilesInDir(String directory, IHeaderMatcher
matcher,
- boolean expected) throws IOException {
+ public static void testFilesInDir(final String directory,
+ final IHeaderMatcher matcher, final boolean expected)
+ throws IOException {
final File[] resourceFiles =
Resources.getResourceFiles(directory);
- if (resourceFiles.length == 0) {
- Assert.fail("No files found under " + directory);
+ if (resourceFiles.length == ZERO) {
+ throw new IOException("No files found under " +
directory);
}
- for (File f : resourceFiles) {
- final Document subject = new MockLocation(f.toString());
- BufferedReader br = null;
+ for (File file : resourceFiles) {
+ final Document subject = new
MockLocation(file.toString());
+ BufferedReader bufferedReader = null;
try {
boolean result = false;
- br = Resources.getBufferedReader(f);
- String line;
- while (!result && (line = br.readLine()) !=
null) {
+ bufferedReader =
Resources.getBufferedReader(file);
+ String line = bufferedReader.readLine();
+ while (!result && line != null) {
result = matcher.match(subject, line);
+ line = bufferedReader.readLine();
}
- assertEquals(f.toString(), expected, result);
+ assertEquals(file.toString(), expected, result);
} finally {
matcher.reset();
- IOUtils.closeQuietly(br);
+ IOUtils.closeQuietly(bufferedReader);
}
}
}