Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
2.17
-
None
-
None
-
OSX 10.11.1, java version "1.8.0_25", Apache Maven 3.1.1, Checkstyle configuration plugin for M2Eclipse1.0.0.201503101518
Description
Checkstyle cannot parse an automatically initialize array in method call.
I experience the issue with both maven-checkstyle and eclipse-checksyle.
The following code causes checktyle:check to fail. The issues is cause by the second parameter.
final SanitisingBeanRecordFieldExtractor extractor = new SanitisingBeanRecordFieldExtractor(CreditCardRecord.class, { "transactionDescriptionLineText" }, AbstractTransactionRecord.DATE_FORMAT, HASH_KEY);
The checksyle:check fails with the following error.
.../SanitisingBeanRecordFieldExtractorTest.java:109:15: expecting "class", found 'SanitisingBeanRecordFieldExtractor' .../SanitisingBeanRecordFieldExtractorTest.java:110:78: expecting IDENT, found ',' [ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (default) on project sense-batch: Failed during checkstyle configuration: MismatchedTokenException occurred during the analysis of file .../SanitisingBeanRecordFieldExtractorTest.java. expecting EOF, found 'extractor' -> [Help 1]
To work around the code needs to be changed to the following:
final SanitisingBeanRecordFieldExtractor extractor = new SanitisingBeanRecordFieldExtractor(CreditCardRecord.class, new String[] { "transactionDescriptionLineText" }, AbstractTransactionRecord.DATE_FORMAT, HASH_KEY);
For reference the constructor I am calling is defined as follows:
public SanitisingBeanRecordFieldExtractor(final Class<?> type, final String[] fields, final String dateFormatPattern, final String hashKey) throws IntrospectionException { ... }