Skip to content

Commit 529db8e

Browse files
committed
cleanup
1 parent eb60969 commit 529db8e

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/test/java/org/htmlunit/CodeStyleTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
*/
1515
package org.htmlunit;
1616

17-
import static java.nio.charset.StandardCharsets.UTF_8;
1817
import static org.junit.Assert.fail;
1918

2019
import java.io.File;
2120
import java.io.IOException;
2221
import java.lang.reflect.Constructor;
2322
import java.lang.reflect.Method;
2423
import java.lang.reflect.Modifier;
24+
import java.nio.charset.Charset;
25+
import java.nio.charset.StandardCharsets;
2526
import java.nio.file.Files;
2627
import java.nio.file.Paths;
2728
import java.time.LocalDate;
@@ -52,6 +53,7 @@
5253
*/
5354
public class CodeStyleTest {
5455

56+
private static final Charset SOURCE_ENCODING = StandardCharsets.UTF_8;
5557
private static final Pattern LEADING_WHITESPACE = Pattern.compile("^\\s+");
5658
private static final Pattern LOG_STATIC_STRING =
5759
Pattern.compile("^\\s*LOG\\.[a-z]+\\(\"[^\"]*\"(, [a-zA-Z_]+)?\\);");
@@ -139,7 +141,7 @@ private void process(final List<File> files, final List<String> classNames) thro
139141
for (final File file : files) {
140142
final String relativePath = file.getAbsolutePath().substring(new File(".").getAbsolutePath().length() - 1);
141143
if (file.getName().endsWith(".java")) {
142-
final List<String> lines = FileUtils.readLines(file, UTF_8);
144+
final List<String> lines = FileUtils.readLines(file, SOURCE_ENCODING);
143145
openingCurlyBracket(lines, relativePath);
144146
year(lines, relativePath);
145147
javaDocFirstLine(lines, relativePath);
@@ -290,7 +292,7 @@ private void processXML(final File dir, final boolean recursive) throws Exceptio
290292
}
291293
else {
292294
if (file.getName().endsWith(".xml")) {
293-
final List<String> lines = FileUtils.readLines(file, UTF_8);
295+
final List<String> lines = FileUtils.readLines(file, SOURCE_ENCODING);
294296
final String relativePath = file.getAbsolutePath().substring(
295297
new File(".").getAbsolutePath().length() - 1);
296298
mixedIndentation(lines, relativePath);
@@ -345,7 +347,7 @@ private void badIndentationLevels(final List<String> lines, final String relativ
345347
* Checks the year in {@code LICENSE.txt}.
346348
*/
347349
private void licenseYear() throws IOException {
348-
final List<String> lines = FileUtils.readLines(new File("checkstyle.xml"), UTF_8);
350+
final List<String> lines = FileUtils.readLines(new File("checkstyle.xml"), SOURCE_ENCODING);
349351
boolean check = false;
350352
final String copyright = "Copyright (c) 2002-" + LocalDate.now().getYear();
351353
for (final String line : lines) {
@@ -367,7 +369,7 @@ private void licenseYear() throws IOException {
367369
private void versionYear() throws IOException {
368370
final List<String> lines =
369371
FileUtils.readLines(new File("src/main/java/org/htmlunit/Version.java"),
370-
UTF_8);
372+
SOURCE_ENCODING);
371373
for (final String line : lines) {
372374
if (line.contains("return \"Copyright (c) 2002-" + Calendar.getInstance(Locale.ROOT).get(Calendar.YEAR))) {
373375
return;
@@ -380,7 +382,7 @@ private void versionYear() throws IOException {
380382
* Verifies no &lt;parent&gt; tag in {@code pom.xml}.
381383
*/
382384
private void parentInPom() throws IOException {
383-
final List<String> lines = FileUtils.readLines(new File("pom.xml"), UTF_8);
385+
final List<String> lines = FileUtils.readLines(new File("pom.xml"), SOURCE_ENCODING);
384386
for (int i = 0; i < lines.size(); i++) {
385387
if (lines.get(i).contains("<parent>")) {
386388
addFailure("pom.xml", i + 1, "'pom.xml' should not have <parent> tag");
@@ -927,7 +929,7 @@ private void testTests(final File dir) throws Exception {
927929
&& method.getAnnotation(Test.class) == null
928930
&& method.getReturnType() == Void.TYPE
929931
&& method.getParameterTypes().length == 0) {
930-
final List<String> lines = FileUtils.readLines(file, UTF_8);
932+
final List<String> lines = FileUtils.readLines(file, SOURCE_ENCODING);
931933
int line = -1;
932934
for (int i = 0; i < lines.size(); ++i) {
933935
if (lines.get(i).contains("public void " + method.getName() + "()")) {

0 commit comments

Comments
 (0)