JavaNCSS

JavaNCSS not able to parse some generic code

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 32.53
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    2

Description

We have a class methods that's like this:
/**

  • Takes an Iterable of Iterables of T and flattens it down to a Collection
  • of T.
    */
    public static <T, Source extends Iterable<? extends Iterable<T>>, Store extends Collection<T>> Store flatten( Source source, Store store ) {
    for ( Iterable<T> subSource : source )
    Unknown macro: { for ( T t }

    return store;
    }

We are running hudson+sonar plugin, when we reach the sonar build we get this error:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute the command org.codehaus.mojo:javancss-maven-plugin::report

Embedded error: An error has occurred in JavaNCSS Report report generation.
Encountered "< T , Source extends Iterable < ? extends Iterable < T >> , Store extends" at line 34, column 19.
Was expecting one of:
"boolean" ...
"byte" ...
"char" ...
"double" ...
"final" ...
"float" ...
"int" ...
"long" ...
"private" ...
"protected" ...
"public" ...
"short" ...
"static" ...
"transient" ...
"volatile" ...
"@" ...
"abstract" ...
"strictfp" ...
"class" ...
"interface" ...
"synchronized" ...
"native" ...
"enum" ...

Thanks

  1. JAVANCSS-14_patch.diff
    29/May/09 4:38 AM
    2 kB
    Sébastien Reynaud
  2. Method.java
    26/May/09 8:56 AM
    0.4 kB
    Antonio Terreno

Activity

Hide
Herve Boutemy added a comment -

can you give us a link to the source causing this error?

Show
Herve Boutemy added a comment - can you give us a link to the source causing this error?
Hide
Antonio Terreno added a comment -

Sorry, I can't give you a link, it's not an open source project. You should be able to reproduce it using the full method body:

/**

  • Takes an Iterable of Iterables (e.g. a list of lists), of T and flattens
  • it down to a Collection of T.
    */
    public static <T, Source extends Iterable<? extends Iterable<T>>, Store extends Collection<T>> Store flatten(Source source, Store store) {
    for (Iterable<T> subSource : source)
    Unknown macro: { for (T t }

    return store;

You will have some compilation errors, but if you create some fake interfaces for Store, Source and Iterable it should then work.

Thanks.

Show
Antonio Terreno added a comment - Sorry, I can't give you a link, it's not an open source project. You should be able to reproduce it using the full method body: /**
  • Takes an Iterable of Iterables (e.g. a list of lists), of T and flattens
  • it down to a Collection of T. */ public static <T, Source extends Iterable<? extends Iterable<T>>, Store extends Collection<T>> Store flatten(Source source, Store store) { for (Iterable<T> subSource : source)
    Unknown macro: { for (T t }
    return store;
You will have some compilation errors, but if you create some fake interfaces for Store, Source and Iterable it should then work. Thanks.
Hide
Antonio Terreno added a comment -

Sorry I've just realized that JIRA tries to parse the java code and to create a macro.

With the code attached you should be able to reproduce the problem .

Thanks.

Show
Antonio Terreno added a comment - Sorry I've just realized that JIRA tries to parse the java code and to create a macro. With the code attached you should be able to reproduce the problem . Thanks.
Hide
Sébastien Reynaud added a comment -

attached the patch.

Show
Sébastien Reynaud added a comment - attached the patch.
Hide
Herve Boutemy added a comment -

fixed in r170
thank you Sébastien

Show
Herve Boutemy added a comment - fixed in r170 thank you Sébastien

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: