You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Guillaume Boué (JIRA)" <ji...@apache.org> on 2017/02/12 19:34:42 UTC

[jira] [Commented] (MCHECKSTYLE-315) MismatchedTokenException occurred during the analysis of file and build FAILS.

    [ https://issues.apache.org/jira/browse/MCHECKSTYLE-315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15862926#comment-15862926 ] 

Guillaume Boué commented on MCHECKSTYLE-315:
--------------------------------------------

The Java code wouldn't compile and is invalid: when declaring an array in a method parameter, the short form of {{&#123; "foo", "bar" &#125;}} cannot be used. Only the long form of {{new String[]&#123; "foo", "bar" &#125;}} would be valid Java. This is why Checkstyle rejects such code.

> MismatchedTokenException occurred during the analysis of file and build FAILS.
> ------------------------------------------------------------------------------
>
>                 Key: MCHECKSTYLE-315
>                 URL: https://issues.apache.org/jira/browse/MCHECKSTYLE-315
>             Project: Maven Checkstyle Plugin
>          Issue Type: Bug
>          Components: checkstyle:check
>    Affects Versions: 2.17
>         Environment: OSX 10.11.1, java version "1.8.0_25", Apache Maven 3.1.1, Checkstyle configuration plugin for M2Eclipse1.0.0.201503101518
>            Reporter: Cormac O'Mahony
>
> 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 {
>         ...
>     }
>     



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)