cobertura / cobertura

Cobertura
GNU General Public License v2.0
1.03k stars 277 forks source link

JavaNCSS error: maven plugin v2.7 #266

Closed mmoayyed closed 1 year ago

mmoayyed commented 9 years ago
public static String inflate(final byte[] bytes) {
        try (final ByteArrayInputStream inb = new ByteArrayInputStream(bytes);
             final ByteArrayOutputStream out = new ByteArrayOutputStream();
             final InflaterOutputStream ios = new InflaterOutputStream(out);) {
            IOUtils.copy(inb, ios);
            return new String(out.toByteArray(), UTF8_ENCODING);
        } catch (final Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }

causes:

[WARN] JavaNCSS got an error while parsing the java file /Users/Misagh/Workspace/GitWorkspace/cas-server/cas-server-core/src/main/java/org/jasig/cas/util/CompressionUtils.java
ParseException in STDIN
Last useful checkpoint: "org.jasig.cas.util.CompressionUtils.inflate(byte[])"
Encountered " "final" "final "" at line 64, column 14.
Was expecting one of:
    "assert" ...
    "boolean" ...
    "byte" ...
    "char" ...
    "double" ...
    "enum" ...
    "false" ...
    "float" ...
    "int" ...
    "long" ...
    "new" ...
    "null" ...
    "short" ...
    "super" ...
    "this" ...
    "true" ...
    "void" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <CHARACTER_LITERAL> ...
    <STRING_LITERAL> ...
    <IDENTIFIER> ...
    "(" ...
    ")" ...
    "!" ...
    "~" ...
    "++" ...
    "--" ...
    "+" ...
    "-" ...

Report time: 510ms

[ERROR] net.sourceforge.cobertura.javancss.parser.ParseException: Encountered " "final" "final "" at line 64, column 14.
adelinor commented 9 years ago

I am having a similar error with the following line of code:

    private static final String BOM = "\uFEFF";

The error is:

[WARN] JavaNCSS got an error while parsing the java file /Users/myuser/Documents/workspace/myproject/mymodule/src/main/java/myproject/mymodule/encoding/MessageEncodingProcessor.java
TokenMgrError in STDIN
Lexical error at line 30, column 40.  Encountered: "\ufeff" (65279), after : ""

Report time: 255ms

[ERROR] net.sourceforge.cobertura.javancss.parser.TokenMgrError: Lexical error at line 30, column 40.  Encountered: "\ufeff" (65279), after : ""
    at net.sourceforge.cobertura.javancss.parser.JavaParserTokenManager.getNextToken(JavaParserTokenManager.java:2057)
    at net.sourceforge.cobertura.javancss.parser.JavaParser.jj_scan_token(JavaParser.java:10375)
    at net.sourceforge.cobertura.javancss.parser.JavaParser.jj_3R_100(JavaParser.java:7053)
    at net.sourceforge.cobertura.javancss.parser.JavaParser.jj_3_12(JavaParser.java:7086)
    at net.sourceforge.cobertura.javancss.parser.JavaParser.jj_2_12(JavaParser.java:6013)
xylo commented 7 years ago

I get the error on this line: return Integer::new;

Looks like cobertura doesn't like the "::" syntax.