Objective-C copy paste detection using Jenkins

I recently configured a Jenkins job to execute CPD (copy paste detector) using PMD against an iOS project. For those of you who are not familiar with CPD, it is a tool which can analyze a code base to identify large chunks of code that have been duplicated.  CPD is capable of ignoring differences in whitespace and literal values so that you can find similar code and not just identical code.  Because of this, CPD is an invaluable ally in the constant battle against bad coding practices.

CPD supports Java, JSP, C, C++, Fortran and PHP out of the box and can be extended by writing language definitions in Java.  In order to get the best results for iOS projects, I have compiled a simple Objective-C language definition based on an Objective-C JavaCC grammar which was written by a fellow named Mike Hall.

If you would like to setup CPD execution within your Jenkins iOS builds, you will need to first download CPD from this link:  http://sourceforge.net/projects/pmd/files/pmd/4.2.5/

You will also need to download my generated Objective-C CPD language definition from github: https://github.com/jkennedy1980/Objective-C-CPD-Language.  NOTE: It is best to download the entire project as a zip file because I have seen issues when downloading the individual release jars from github.

Once you have all the jars extracted from their zip files, you’ll want to copy the PMD and ObjCLanguage-0.0.7-SNAPSHOT jars to a location on your Jenkins box.  Next, go into your Jenkins build’s configuration and add a new ‘execute shell’ build step.  You’ll need to tailor the actual command to your project, but here is an example of what the command should look like:

java
-Xmx512m
-classpath pmd-4.2.5.jar:ObjCLanguage-0.0.7-SNAPSHOT.jar
net.sourceforge.pmd.cpd.CPD
--minimum-tokens 100
--files [Path to XCode project classes]
--language ObjectiveC
--encoding UTF-8
--format net.sourceforge.pmd.cpd.XMLRenderer > cpd-output.xml

Command Breakdown

  • java – CPD is executed using the java application.  Make sure you Jenkins box has a JRE installed.
  • -Xmx512m – This parameter tells the JRE to allocate 512 Mb of memory for the JVM.  If your project is large and you are getting out of memory or heap errors, you may want to bump this number up.
  • –classpath pmd-4.2.5.jar:ObjCLanguage-0.0.7-SNAPSHOT.jar – This puts the PMD jar and the Objective C language definition onto the JVMs classpath.  The paths to the 2 jars may need to be absolute paths.
  • net.sourceforge.pmd.cpd.CPD — This is the main class (CPD itself) that is executed from inside the PMD jar by the java executable.
  • –minimum-tokens 100 – Configures the minimum size for blocks considered to be duplicate
  • –files [path] – This parameter tells CPD which files should be scanned for copy paste violations.  You can provide more than one –files parameter if needed.
  • –language ObjectiveC – This tells CPD to load my custom Objective-C language definition.
  • –encoding UTF-8 – This allows you to specify which encoding you would like to use.  [optional]
  • –format net.sourceforge.pmd.cpd.XMLRenderer – This tells CPD that you would like to output the results as XML.  You will need to use XML if you want to publish the results within Jenkins using the plugins mentioned below.
  • > cpd-output.xml – This takes all the XML output by CPD and writes it into a file named cpd-output.xml.  You can name the output file whatever you want.

Jenkins Plugins

Once you have tailored the command above, you can install the Violations or the DRY plugin from the Jenkins update center.  I used the Violations plugin which allows you to configure limits that define when the build should be unstable or cloudy within each job’s configuration.  You’ll need to be sure that you setup the Violations or DRY plugin’s configuration values so that they can find the output CPD XML file.

Once you have configured everything properly, you should see a Violations section within your job that lets you browse the duplicated code blocks that were found within your code base.

I hope you find this post helpful and that CPD helps you remove all your duplication…or your co-workers’ duplication :)

Troubleshooting

If you are receiving parsing errors in your output, you can now( as of version 0.0.5) add ‘-DObjC-CPD-LoggingEnabled=YES’ after java in the CPD command to enable some additional logging.  The new logging will print out each file’s name as they are processed and show files names when parsing exceptions are generated.   If you are redirecting the output to an XML file as I have shown in this post, you will have to open the XML file to see the logging output.  Here is an example with logging enabled:

java
-DObjC-CPD-LoggingEnabled=YES
-Xmx512m
-classpath pmd-4.2.5.jar:ObjCLanguage-0.0.7-SNAPSHOT.jar
net.sourceforge.pmd.cpd.CPD
--minimum-tokens 100
--files [Path to XCode project classes]
--language ObjectiveC
--encoding UTF-8
--format net.sourceforge.pmd.cpd.XMLRenderer > cpd-output.xml

WARNING: by enabling logging the XML output will be invalid. Logging should only enabled to assist in troubleshooting.

About these ads

Published by

jkennedy1980

Software craftsman

57 thoughts on “Objective-C copy paste detection using Jenkins”

  1. Looks very interesting. There is a little bug in the tokenizer, though.

    If the input contains ObjC code like this:


    [NSString stringWithFormat:@"%.0f\xC2\xB0", someValue];

    Then CPD throws the following exception:

    com.deadmeta4.cpd.generated.TokenMgrError: Lexical error at line 438, column 84.  Encountered: "x" (120), after : "@\"%.0f\\"
    	at com.deadmeta4.cpd.generated.ObjCParserTokenManager.getNextToken(ObjCParserTokenManager.java:6153)
    	at com.deadmeta4.cpd.generated.ObjCParser.getNextToken(ObjCParser.java:7717)
    	at net.sourceforge.pmd.cpd.ObjectivecTokenizer.tokenize(ObjectivecTokenizer.java:31)
    	at net.sourceforge.pmd.cpd.CPD.add(CPD.java:106)
    	at net.sourceforge.pmd.cpd.CPD.add(CPD.java:72)
    	at net.sourceforge.pmd.cpd.CPD.addDirectory(CPD.java:82)
    	at net.sourceforge.pmd.cpd.CPD.addRecursively(CPD.java:67)
    	at net.sourceforge.pmd.cpd.CPD.main(CPD.java:180)
    

  2. Running the CPD as an Ant task instead of from the command line allows for more versatile source file inclusion / exclusion and may be also more appropriate for some build setups.

    CPD Ant task hardcodes the supported languages so adding support for ObjectiveC requires a minor addition to the CPDTask.java (line 188):

    private static final String[] LANGUAGES = new String[]{“java”,”jsp”,”cpp”, “c”,”php”, “ruby”, “fortran”, “ObjectiveC”};

    After this code tweak (and recompiling the pmd-4.2.5.jar by running “ant jar” in PMD source directory root) you can use the following Ant build.xml file to run the duplicate detection: http://pastebin.com/np7d5G2r

    Running the ant task from command line:


    CLASSPATH="ObjCLanguage-0.0.1-SNAPSHOT.jar:pmd-4.2.5.jar" ant cpd

  3. As for Jenkins plugins, I tried Violations plugin but it displayed only “duplicate tokens” report, which visualized single duplicated lines instead of duplicated blocks of lines.

    DRY plugin seems to do the right thing – displaying duplicated blocks of subsequent code lines over several source files.

  4. Awesome. I like this comment from the CPDTask source:


    /*
    FIXME Can't we do something cleaner and more dynamic ? Maybe externalise to a properties files that will be generated when building pmd ? This will not have to add manually new language here ?
    */

    If I have time I may see about fixing this in CPDTask.

    Good info on the DRY plugin…I’ll give it a try at work today. Thanks :)

  5. Very Interesting ! But i was unable to get the CPD report to work, i get an empty xml output.

    Here is the Jenkins logs :

    java -Xmx512m -classpath /Users/barbu/.hudson/plugins/CPD/pmd-4.2.5.jar:ObjCLanguage-0.0.1-SNAPSHOT.jar net.sourceforge.pmd.cpd.CPD –minimum-tokens 100 –files ‘/Users/barbu/Documents/Projets/Formations Mobiles/Training/Formation/Training’ –language ObjectiveC –encoding UTF-8 –format net.sourceforge.pmd.cpd.XMLRenderer
    Finished: SUCCESS

    The cpd-output.xml file is created but it only contains :

    Do you know what can be wrong ?

    P.S: Tried to put the minimum token at 1 but i got the same result

    Thanks,
    Vincent

    1. Hmm. Can you try adding a ‘-v’ to your command? This will generate additional output to the console. Make sure you see your files being reported in the output. You can also try taking off the ‘-format net.sourceforge.pmd.cpd.XMLRenderer’ and CPD should output the results to the console output. Otherwise…i guess your project is copy/paste free :)

  6. Hey there

    I get the command to complete but the xml file does not contain any violations:

    This is my command:

    java \
    -Xmx512m \
    -classpath ~/Desktop/pmd/pmd-4.2.5.jar:~/Desktop/pmd/ObjCLanguage-0.0.1-SNAPSHOT.jar \
    net.sourceforge.pmd.cpd.CPD \
    –minimum-tokens 10 \
    –files ~/MyApp/Classes \
    –language ObjectiveC \
    –encoding UTF-8 \
    –format net.sourceforge.pmd.cpd.XMLRenderer

    I think at a minimum-tokens of 10 should work to get some results…

    Do you have any idea how to fix / debug this?

  7. Great find (and work on the language descriptor files)! I’ve just come in to a new project and am looking at some refactoring and code cleaning … I was able to install pmd and the language file first time and within a few minutes I now have a nice (and large!) xml report highlighting stuff it would have taken me days to find. This really should be part of any large project workflow and thanks again for writing about it.

  8. I tried it with another project’s code base and got the following Exception.

    Any ideas how I can tackle this?

    com.deadmeta4.cpd.generated.TokenMgrError: Lexical error at line 148, column 67. Encountered: ” ” (32), after : “@”
    at com.deadmeta4.cpd.generated.ObjCParserTokenManager.getNextToken(ObjCParserTokenManager.java:6153)
    at com.deadmeta4.cpd.generated.ObjCParser.getNextToken(ObjCParser.java:7717)
    at net.sourceforge.pmd.cpd.ObjectivecTokenizer.tokenize(ObjectivecTokenizer.java:31)
    at net.sourceforge.pmd.cpd.CPD.add(CPD.java:106)
    at net.sourceforge.pmd.cpd.CPD.add(CPD.java:72)
    at net.sourceforge.pmd.cpd.CPD.addDirectory(CPD.java:82)
    at net.sourceforge.pmd.cpd.CPD.addRecursively(CPD.java:67)
    at net.sourceforge.pmd.cpd.CPD.main(CPD.java:180)

    Best regards

    1. I have seen this before when I was developing the language definition. Can you reply with the few lines of code around the position mentioned: “Lexical error at line 148, column 67. Encountered: ” ” (32), after : “@””?

      The way that the error reads it sounds like there is a space directly after an @ which is tripping up the syntax tokenizer. If that is the case you could try removing the space.

      1. But if I do something like this in my source file then it has obviously the string ‘@ ‘ which leads to the error.

        NSLog(@”Distance: %@ meters”, distance);

        Is there a way I can figure out which file leads to the problem?

      2. I have tons of code with NSLog statements just like your example and CPD works fine. I am trying to determine if there is something special about the statement at line148 column 67. If I can figure out why it is complaining I can modify the grammar file to fix the problem.

      3. If you add a -v to the command, CPD will output each filename as it crawls through the source. Then you should be able to see the exact line and character causing the problem. More than likely the objective-c grammar file needs updated. I just need to know how to reproduce this so I can test it myself.

  9. Hi,

    Got an issue, the cpd.xml file that has first line :
    And in the slave.log :
    org.xml.sax.SAXParseException: Invalid encoding name “MacRoman”.

    Maybe my env is misconfigured, but env returns : LANG=fr_FR.UTF-8

  10. New to Jenkins here, trying to follow this step:

    “You’ll need to be sure that you setup the Violations or DRY plugin’s configuration values so that they can find the output CPD XML file.”

    but I can’t find the Violations or DRY (or any) plugin configuration. I’ve checked the “Plugin Manager” and just about all the links under “Manage Jenkins”, to no avail. Searched the google, too. This page says to “activate the static code analyzers”:

    https://wiki.jenkins-ci.org/display/JENKINS/Violations

    but there’s no such option in the build.

    I am able to get the CPD XML file output, FWIW, so I think I’m just failing at Jenkins itself.

  11. You can delete my previous comment (if you want). I found it by searching the HTML source for the project configuration page, heh.

    FWIW, to configure Violations, you have to add a “Post-Build action” called “Report Violations”.

  12. hi,jkennedy1980 :

    I use the following command to scan iPhone project classes:
    java -Xmx512m -classpath /data/ssa/pmd/lib/pmd-4.2.5.jar:/data/ssa/pmd/lib/ObjCLanguage-0.0.1-SNAPSHOT.jar net.sourceforge.pmd.cpd.CPD –minimum-tokens 10 –files $WORKSPACE/Classes/ –language ObjectiveC –encoding GB2312 -v –format net.sourceforge.pmd.cpd.XMLRenderer > cpd-output.xml

    then i get some errors like these:
    com.deadmeta4.cpd.generated.TokenMgrError: Lexical error at line 1, column 1. Encountered: “\u9518″ (38168), after : “”
    at com.deadmeta4.cpd.generated.ObjCParserTokenManager.getNextToken(ObjCParserTokenManager.java:6153)
    at com.deadmeta4.cpd.generated.ObjCParser.getNextToken(ObjCParser.java:7717)
    at net.sourceforge.pmd.cpd.ObjectivecTokenizer.tokenize(ObjectivecTokenizer.java:28)
    at net.sourceforge.pmd.cpd.CPD.add(CPD.java:106)
    at net.sourceforge.pmd.cpd.CPD.add(CPD.java:72)
    at net.sourceforge.pmd.cpd.CPD.addDirectory(CPD.java:82)
    at net.sourceforge.pmd.cpd.CPD.addRecursively(CPD.java:67)
    at net.sourceforge.pmd.cpd.CPD.main(CPD.java:180)
    com.deadmeta4.cpd.generated.TokenMgrError: Lexical error at line 226, column 56. Encountered: “\n” (10), after : “@\”\ufffd\ufffd\ufffd\u7ec0\u54c4\ufffd\ufffd\ufffd; ”
    at com.deadmeta4.cpd.generated.ObjCParserTokenManager.getNextToken(ObjCParserTokenManager.java:6153)
    at com.deadmeta4.cpd.generated.ObjCParser.getNextToken(ObjCParser.java:7717)
    at net.sourceforge.pmd.cpd.ObjectivecTokenizer.tokenize(ObjectivecTokenizer.java:31)
    at net.sourceforge.pmd.cpd.CPD.add(CPD.java:106)
    at net.sourceforge.pmd.cpd.CPD.add(CPD.java:72)
    at net.sourceforge.pmd.cpd.CPD.addDirectory(CPD.java:82)
    at net.sourceforge.pmd.cpd.CPD.addRecursively(CPD.java:67)
    at net.sourceforge.pmd.cpd.CPD.main(CPD.java:180)

    can you tell me how to fix it ?

    thanks a lot.

    1. This looks like an issue in the Objective-C Language grammar. It looks like you have a file with some unicode characters in it (\u9518,\ufffd). If you send me a sample of the code containing these characters I may be able to modify the CPD grammar to accept these files.

      1. hi,jkennedy1980 :
        Can you tell me your e-mail address,so i can send you some sample of the code
        these characters (\u9518,\ufffd).

    1. I have had many people ask me about folder level exclusions but have not found a way to do it with PMD/CPD alone. I believe a custom tool would have to be written or CPD would have to be modified.

  13. Hi,

    This is my command:

    java -Xmx512m -classpath /Users/kishoren1/Desktop/UnitTest/pmd-bin-5.0.0/lib/pmd-5.0.0.jar:/Users/kishoren1/Desktop/UnitTest/CopyPasteDetection/ObjCLanguage-0.0.6-SNAPSHOT.jar net.sourceforge.pmd.cpd.CPD –minimum-tokens 100 –language ObjectiveC –encoding UTF-8 –format net.sourceforge.pmd.cpd.XMLRenderer –files /Users/kishoren1/Desktop/UnitTest/UnitTestSampleWithCodeCoverage –files $/Users/kishoren1/Desktop/UnitTest/UnitTestSampleWithCodeCoverage > /Users/kishoren1/Desktop/UnitTest/cpd-output.xml

    and i am getting an error message like this:
    Exception in thread “main” java.lang.NoClassDefFoundError: net/sourceforge/pmd/cpd/CPD
    Caused by: java.lang.ClassNotFoundException: net.sourceforge.pmd.cpd.CPD
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

    could you please help?

    Thanks.

    1. This has to be a classpath issue. Make sure the paths you are passing into the -classpath argument are valid. Check things like case sensitivity. I just noticed you are using PMD 5.0. Maybe they have changed something. Try using PMD 4.x and see if you have any luck.

      1. Can you tell me your e-mail address?
        so i can send you some sample of the code
        these characters (\u9518,\ufffd).

  14. Hi, i’m trying to follow your guide and Cyril’s one, and i’m getting the following error, any idea? :

    [DRY] Collecting duplicate code analysis files…
    [DRY] Finding all files that match the pattern build/cpd-output.xml
    [DRY] Parsing 1 files in /Users/X/Desktop/workspace/Y
    [DRY] Parsing of file /Users/X/Desktop/workspace/Y/build/cpd-output.xml failed due to an exception:

    java.io.IOException: No parser found for duplicated code results file /Users/X/Desktop/workspace/Y/build/cpd-output.xml
    at hudson.plugins.dry.parser.DuplicationParserRegistry.parse(DuplicationParserRegistry.java:93)
    at hudson.plugins.analysis.core.FilesParser.parseFile(FilesParser.java:261)
    at hudson.plugins.analysis.core.FilesParser.parseFiles(FilesParser.java:220)
    at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:169)
    at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:31)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2099)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:287)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)

    PS : the cpd-output.xml seems to be a correct (i just used my eyes ^^), but the first line is : “”, even if i’m using “–encoding UTF-8″ (i tried, utf8, utf-8, UTF8, UTF-8, –encoding, -encoding etc… :)). I also tried to replace the MacRoman by UTF-8 with a sed, and it does not change anything.

  15. It finally with Violations and this command (added an iconv in case of + sed for the encoding name) :

    java -Xmx512m -classpath ${WORKSPACE}/../PMD/pmd-4.2.5/lib/pmd-4.2.5.jar:${WORKSPACE}/../PMD/Objective-C/releases/ObjCLanguage-0.0.7-SNAPSHOT.jar net.sourceforge.pmd.cpd.CPD –minimum-tokens 100 –language ObjectiveC –encoding UTF-8 –format net.sourceforge.pmd.cpd.XMLRenderer –files ${WORKSPACE}/${JOB_NAME} | iconv -f macRoman -t utf-8 | sed ‘s/MacRoman/UTF-8/g’ > build/cpd-output.xml

  16. I just cannot get this to show me the violations . I gave the full path for the jar files in my class path but fail to get any violations . It just gives me an empty xml every time . Its a really cool tool and can help us notify some violations
    java -Xmx512m -classpath /Users/n/PMD/pmd-4.2.5/lib/pmd-4.2.5.jar:/Users/n/PMD/ObjCLanguage-0.0.7-SNAPSHOT.jar net.sourceforge.pmd.cpd.CPD –minimum-tokens 100 –language ObjectiveC –encoding UTF-8 –format net.sourceforge.pmd.cpd.XMLRenderer –files GSolution

    All i get is an empty xml

  17. Tried to manage PMD with Jenkins but still don’t work.
    Here is my command (tried in console too without much success)

    java -Xmx512m -classpath /Users/Shared/Jenkins/PMD/pmd-bin-5.0.2/lib/pmd-5.0.2.jar:/Users/Shared/Jenkins/PMD/ObjCLanguage-0.0.7-SNAPSHOT.jar net.sourceforge.pmd.cpd.CPD –minimum-tokens 100 –language ObjectiveC –encoding UTF-8 –format net.sourceforge.pmd.cpd.XMLRenderer –files TestJenkinsApp > build/cpd-output.xml

    No matter what parameters I tried, my build/cpd-output.xml file is always empty.

    Any ideas ?

    Thanks

  18. Nice tutorial, I was trying it since yesterday evening but without success, I didn’t have any result even an empty xml. The thing is I installed the last version of pmd the 5.0.2. When trying with the one in this tutorial the 4.2.5. But still now the xml report is generated but there are no results in it:

  19. hi Joshua,

    I am trying to use your code with Jenkin. The cpd-output files is being created.However it starts with these lines:
    CPD Processing: /Users/testUser/Documents/tmp/iPad-2013.02.0/testFiles.h

    And i see a warning in the Jenkins dashboard:
    Module : Parsing of file /Users/zkmrwqd/.jenkins/jobs/BOFAMobileiPad/workspace/pmd/cpd-output.xml failed due to an exception: java.io.IOException: No parser found for duplicated code results file /Users/zkmrwqd/.jenkins/jobs/BOFAMobileiPad/workspace/pmd/cpd-output.xml at hudson.plugins.dry.parser.DuplicationParserRegistry.parse(DuplicationParserRegistry.java:102) at hudson.plugins.analysis.core.FilesParser.parseFile(FilesParser.java:306) at hudson.plugins.analysis.core.FilesParser.parseFiles(FilesParser.java:264) at hudson.plugins.analysis.core.FilesParser.parserCollectionOfFiles(FilesParser.java:215) at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:184) at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:31) at hudson.FilePath.act(FilePath.java:852) at hudson.FilePath.act(FilePath.java:834) at hudson.plugins.dry.DryPublisher.perform(DryPublisher.java:175) at hudson.plugins.analysis.core.HealthAwarePublisher.perform(HealthAwarePublisher.java:146) at hudson.plugins.analysis.core.HealthAwareRecorder.perform(HealthAwareRecorder.java:331) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:718) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:693) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:640) at hudson.model.Run.execute(Run.java:1527) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:237)

    can you please help.

  20. I too get an empty xml and there are no results. I turned on the -v flag, but there are no verbose output there as well. I’ve double and triple checked the source directories too :(

    java -Xmx512m -classpath /etc/pmd-4.2.5/lib/pmd-4.2.5.jar:/etc/pmd-4.2.5/ObjCLanguage-0.0.7-SNAPSHOT.jar net.sourceforge.pmd.cpd.CPD –minimum-tokens 10 –language ObjectiveC –encoding UTF-8 -v –format net.sourceforge.pmd.cpd.XMLRenderer –files ‘/Users/Shared/Jenkins/Home/workspace/Commons’ –files ‘/Users/Shared/Jenkins/Home/workspace/CommonsTest’

  21. I too get an empty xml file. I tried turning on the -v flag, but no use, I don’t see any output in the console. Any ideas? :(

    java -Xmx512m -classpath /etc/pmd-4.2.5/lib/pmd-4.2.5.jar:/etc/pmd-4.2.5/ObjCLanguage-0.0.7-SNAPSHOT.jar net.sourceforge.pmd.cpd.CPD –minimum-tokens 10 –language ObjectiveC –encoding UTF-8 -v –format net.sourceforge.pmd.cpd.XMLRenderer –files ‘/Users/Shared/Jenkins/Home/workspace/Commons’ –files ‘/Users/Shared/Jenkins/Home/workspace/CommonsTest’

  22. It will work for PMD 4.2.6 and ObjCLanguage-0.0.7. However there will be some errors for objective c Literals like @[@1,@2]

  23. Quick comment. It generates an empty result file with the latest PMD bin (5.0.4 now) but I made it work just using the version 4.2.5

  24. I doesn’t work for me even with pmd-4.2.5 – the output isn’t empty with 4.2.5, but there are only xml tags:

    And the command doesn’t seem to take in account ObjCLanguage-0.0.7-SNAPSHOT.jar file – I can change it’s name or delete or change this path to any – no changes. Can anybody help? A also tried ObjCLanguage-0.0.8-SNAPSHOT.jar file – no difference.

  25. At first i got an empty xml as well. When i checked the command, the jar name in ObjCLanguage was different because if copied the command from the readme file. Mine was “ObjCLanguage-0.0.7-SNAPSHOT.jat
    Also i had to add commons-io.jar.
    *use pmd-4.2.5.jar

  26. Nice tool,
    At first i got an empty xml as the result. When i checked the command “ObjCLanguage-0.0.1-SNAPSHOT.jar” name was different because i copied the command from the readme file. I changed it to “ObjCLanguage-0.0.7-SNAPSHOT.jar
    Also i had to add commons-io.jar
    *use pmd-4.2.5.jar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s