gleclaire / codenarc-maven-plugin

Maven Mojo Plug-In to generate reports based on the CodeNarc Analyzer
https://gleclaire.github.io/codenarc-maven-plugin/
Apache License 2.0
7 stars 17 forks source link

Analysis fails if project name contains spaces #12

Open mkordas opened 8 years ago

mkordas commented 8 years ago

In pom.xml it is possible to have name with spaces:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    ...
    <name>Project Name</name>

but then the analysis fails

[DEBUG] antTitle => -title="Project Name"
     ...
     [java] ERROR: Invalid argument format: [on]. Expression: matcher. Values: matcher = java.util.regex.Matcher[pattern=\-(.*)\=(.*) region=0,2 lastmatch=]
     [java] java.lang.AssertionError: Invalid argument format: [on]. Expression: matcher. Values: matcher = java.util.regex.Matcher[pattern=\-(.*)\=(.*) region=0,2 lastmatch=]
     [java]     at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:388)
     [java]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:662)
     [java]     at org.codenarc.CodeNarc$_parseArgs_closure3.doCall(CodeNarc.groovy:156)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java]     at java.lang.reflect.Method.invoke(Method.java:497)
     [java]     at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
     [java]     at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
     [java]     at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
     [java]     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
     [java]     at groovy.lang.Closure.call(Closure.java:276)
     [java]     at groovy.lang.Closure.call(Closure.java:289)
     [java]     at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1198)
     [java]     at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1174)
     [java]     at org.codehaus.groovy.runtime.dgm$109.invoke(Unknown Source)
     [java]     at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:270)
     [java]     at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
     [java]     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
     [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
     [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
     [java]     at org.codenarc.CodeNarc.parseArgs(CodeNarc.groovy:153)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java]     at java.lang.reflect.Method.invoke(Method.java:497)
     [java]     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
     [java]     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
     [java]     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
     [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
     [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
     [java]     at org.codenarc.CodeNarc.execute(CodeNarc.groovy:122)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java]     at java.lang.reflect.Method.invoke(Method.java:497)
     [java]     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
     [java]     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:63)
     [java]     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
     [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
     [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
     [java]     at org.codenarc.CodeNarc.main(CodeNarc.groovy:111)
     [java] CodeNarc - static analysis for Groovy',
     [java] Usage: java org.codenarc.CodeNarc [OPTIONS]
     [java]   where OPTIONS are zero or more command-line options of the form "-NAME[=VALUE]":
     [java]     -basedir=<DIR>
     [java]         The base (root) directory for the source code to be analyzed.
     [java]         Defaults to the current directory (".").
     [java]     -includes=<PATTERNS>
     [java]         The comma-separated list of Ant-style file patterns specifying files that must
     [java]         be included. Defaults to "**/*.groovy".
     [java]     -excludes=<PATTERNS>
     [java]         The comma-separated list of Ant-style file patterns specifying files that must
     [java]         be excluded. No files are excluded when omitted.
     [java]     -rulesetfiles=<FILENAMES>
     [java]         The path to the Groovy or XML RuleSet definition files, relative to the classpath.
     [java]         This can be a single file path, or multiple paths separated by commas.
     [java]         Defaults to "rulesets/basic.xml"
     [java]     -title=<REPORT TITLE>
     [java]         The title descriptive for this analysis; used in the output report(s). Optional.
     [java]     -report=<REPORT-TYPE[:FILENAME]>
     [java]         The definition of the report to produce. The option value is of the form
     [java]         TYPE[:FILENAME], where TYPE is "html", "text", "xml", or "console" and FILENAME is the filename (with
     [java]         optional path) of the output report filename. If the report filename is
     [java]         omitted, the default filename is used for the specified report type
     [java]         ("CodeNarcReport.html" for "html" and "CodeNarcXmlReport.xml" for "xml"). If no
     [java]         report option is specified, default to a single "html" report with the
     [java]         default filename.
     [java]     -help
     [java]         Display the command-line help. If present, this must be the only command-line parameter.
     [java]   Example command-line invocations:
     [java]     java org.codenarc.CodeNarc
     [java]     java org.codenarc.CodeNarc -rulesetfiles="rulesets/basic.xml" title="My Project"
     [java]     java org.codenarc.CodeNarc -report=xml:MyXmlReport.xml -report=html
     [java]     java org.codenarc.CodeNarc -help'
     [java] Java Result: 1

It's because the project name is not passed to CodeNarc in quotes. Let's fix that.

jglick commented 5 years ago

Despite #1 being closed, I still see this in 0.22-1 on Windows (not Linux).