Questions tagged [codenarc]

CodeNarc is a static analysis tool for Groovy source code, enabling monitoring and enforcement of many coding standards and best practices.

CodeNarc is a static analysis tool for Groovy source code, enabling monitoring and enforcement of many coding standards and best practices. CodeNarc applies a set of Rules (predefined and/or custom) that are applied to each Groovy file, and generates an HTML or XML report of the results, including a list of rules violated for each source file, and a count of the number of violations per package and for the whole project.

CodeNarc is similar to popular static analysis tools such as PMD or Checkstyle. Unlike those tools which analyze Java code, CodeNarc analyzes Groovy code.

Useful Links

63 questions
1
vote
0 answers

Only display codenarc priorities 1 and 2 in Jenkins violations report

Is there a way I can exclude priority 3 violations from the Jenkins graph? The other codenarc report types like 'html' or 'sortable' have a maxPriority option which does exactly what I want, but that option doesn't exist for the type=xml…
Vahid Pazirandeh
  • 1,552
  • 3
  • 13
  • 29
1
vote
2 answers

Static code analysis for Grails/groovy project

If I use sonarqube as static code analysis tool for grails project after installing groovy plugin in sonar, then does it also internally use codenarc or do i have to use codenarc analysis of project separately using codenarc plugin in…
Gauranga Rathod
  • 348
  • 5
  • 16
1
vote
1 answer

How to Add CodeNarc Rules to Sonar Groovy Plugin

CodeNarc has 346 rules, but the Sonar Groovy plugin (which utilizes CodeNarc) only uses 59 of those rules. I need to add more rules in Sonar to the Groovy analysis. How can I do this? Thanks
GreenSaguaro
  • 2,968
  • 2
  • 22
  • 41
1
vote
1 answer

CodeNarc - determine if a class is a Grails integration test

I'd like to write a custom CodeNarc rule that validates some aspects of Grails integration test classes. e.g. Spock integration tests should extend IntegrationSpec; not Specification. But to do this, I need to filter on integration tests while…
Dan Tanner
  • 2,229
  • 2
  • 26
  • 39
1
vote
1 answer

Configuring Sonar / Grails

I am using Sonar in my Grails project. My configuration is in a sonar-project.properties file: sonar.projectKey=com.mastercard.labs.cplatform sonar.projectName=Commerce…
More Than Five
  • 9,959
  • 21
  • 77
  • 127
1
vote
0 answers

Is there a way to improve CodeNarc performance?

Recently after upgrading to CodeNarc version 0.23 and Gradle to version 2.4 we've noticed that there is huge impact on a build time. Since the versions upgrade CodeNarc task started to fail quite often with java.lang.OutOfMemoryError: PermGen space…
topr
  • 4,482
  • 3
  • 28
  • 35
1
vote
1 answer

Codenarc priority meanings

I'm a novice CodeNarc user. After a fair amount of googling, I still haven't found any clear indication of what the 3 CodeNarc finding priority levels mean. Right now I take priority 1 to probably mean critical, must fix. But how are other…
chenj7
  • 95
  • 1
  • 10
1
vote
2 answers

How to avoid returning null from a catch block?

I've got a rather simple Grails controller action which binds the parameters to a domain instance and passes that to a service which handles the persistence. def finishBooking() { Booking booking = new Booking(params) try { booking =…
Kimi
  • 6,239
  • 5
  • 32
  • 49
0
votes
1 answer

Configure additional filename extensions for Gradle CodeNarc plugin

I am currently trying to get the CodeNarc plugin for Gradle 8.0.2 to work in my project. Due to some reasons, the Groovy files have different extensions. At the moment, the plugin only seems to run for the *.groovy files. Let's say I have a…
epR8GaYuh
  • 311
  • 9
  • 21
0
votes
1 answer

AnnotationCollectorMode cannot be cast to AnnotationCollectorMode in CodeNarc task after Groovy version upgrade

Upgrade Groovy version of a project from 2.5.13 to 3.0.9 . Everything seems to be working but the CodeNarc plugin shows an error when trying to compile classes that includes tag @Immutable . Error: Compilation failed for…
0
votes
1 answer

How to setup Gosu CodeNarc

I have codenarc set up in my local windows machine with the following configuration. JDK 1.6 and Ant 1.7.1 integrated with claim center 7 version and also codenarc report has been successfully generated. Now the question is there any way to add the…
Anji
  • 63
  • 2
  • 8
0
votes
1 answer

How to manage Java and Python apps on docker?

I have a Python app based on Django that I run over a docker container. The app browses the file system and does analysis on some XML files and extracts embedded source code and exports that into separate files. The app should run a Java jar file…
magsul
  • 1
0
votes
1 answer

CodeNarc and Groovy: NoSuchMethodError: org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeStaticMethod

I am trying to run codenarc and have below script for this but I have been getting java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeStaticMethod. I dont believe there are different version of jars in the script…
Rose Mary
  • 3
  • 3
0
votes
1 answer

Which version of codenarc will support to Grails 1.3.7?

I am trying to implement for my grails project using 1.3.7 version. I am using ant build instead of Gradle build tool. I am not able to find Which version of codenarc will support to Grails 1.3.7?
Sun
  • 3,444
  • 7
  • 53
  • 83
0
votes
1 answer

CodeNarc failing on DuplicateStringLiteral rule for strings included in ignoreStrings

I'm using the CodeNarc plug for Gradle with CodeNarc 1.1. I am using the DuplicateStringLiteral rule and passing in ignoreStrings: ['1', '2'] in the config file but the rule is not respecting the values I'm passing in. It's a groovy config file,…
nateha1984
  • 99
  • 3
  • 14