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
0
votes
2 answers

How to check classes have @CompileStatic annotation?

I want to perform an automated static check analysis on my Groovy code to identify which clases doesn't have the @CompileStatic annotation. I'd like to know how that can be done either with IntelliJ or CodeNarc custom rule.
0
votes
1 answer

CodeNarc TrailingWhitespace doesn't work properly on windows

I use CodeNarc rule "TrailingWhitespace" to prevent whitespaces characters on the end of line. This work fine on linux systems, but on windows when I leave whitespace on the end then check doesn't find this. I use the same configuration for both…
xav9211
  • 191
  • 1
  • 3
  • 14
0
votes
0 answers

How to publish CodeNarc Reports in jenkins Pipeline?

Currently I am using this step (in my Pipeline) to publish the CodeNarc Report: publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'application/Project/build/reports/codenarc', reportFiles: 'main.html',…
adbo
  • 767
  • 1
  • 8
  • 23
0
votes
1 answer

CodeNarc supress JdbcREsultSetReference seems not working

I have class similar to this one: import org.springframework.jdbc.core.RowMapper import java.sql.ResultSet class DataMapper implements RowMapper { @Override @SupressWarnings('JdbcResultSetReference') Data mapRow(ResultSet…
Izbassar Tolegen
  • 1,990
  • 2
  • 20
  • 37
0
votes
0 answers

ignoreFailures in gradle for codnarcTest

Normally in gradle I have codenarc setup with most rules turned on. codenarc { ignoreFailures = true configFile = file 'config/codenarc/codenarc.groovy' } I was able to get violations down, in the main source set, to a very small number and…
John Mercier
  • 1,637
  • 3
  • 20
  • 44
0
votes
1 answer

Grails codenarc plugin for Grails 1.3.9

Searching the plugin site and other resources I could not find which plugin version must I install for my Grails version. Can someone help me out?
Jacob
  • 3,580
  • 22
  • 82
  • 146
0
votes
1 answer

Groovy Codenarc.xml org.xml.sax.SAXParseException xsi:schemaLocation not associated with element type ruleset not bound

I'm using Gradle 2.3 and project has Groovy code. For static code analysis, I'm using Codenarc (i.e. project folder has "config/codenarc/codenarc.xml" file). In the build.gradle / GRADLE_HOME/init.d/top-level.gradle file, I have: apply plugin:…
AKS
  • 16,482
  • 43
  • 166
  • 258
0
votes
0 answers

Grails publish-plugin to Grails Central successful but does not update latest version

I successfully published the Grails CodeNarc Plugin version 0.23 to Grails Central, but the plugin page still shows 0.22 as the latest version. Ideas? >grails publish-plugin | Plugin packaged grails-codenarc-0.23.zip | Plugin packaged…
Chris Mair
  • 56
  • 2
0
votes
1 answer

grails codenarc "Error Script not found: Codenarc"

I want to run codenarc on our jenkins it always fails and all I get in the output is $ /opt/grails/bin/grails -Dgrails.work.dir=/var/lib/jenkins/.grails-codenarc codenarc --non-interactive | Loading Grails 2.4.4 | Configuring classpath | Running…
Moritz
  • 489
  • 1
  • 5
  • 18
0
votes
1 answer

Some CodeNarc rules throwing ClassNotFoundException

So I'm using CodeNarc as an ant task in maven. For my custom ruleset, I'm able to use IllegalRegexRule. However, when I try to add something else, I sometimes get a ClassNotFoundException. For example, once I've added this to my ruleset.xml
Inbl
  • 630
  • 2
  • 5
  • 18
0
votes
1 answer

How to make CodeNarc force maven build to fail

I'm trying to integrate CodeNarc into a maven based project and I've been running into problems. I want to use a custom ruleset, and when a rule is violated, I'd like my maven build to fail. How can I configure codenarc so that violations of rules…
Inbl
  • 630
  • 2
  • 5
  • 18
0
votes
1 answer

How create a single CodeNarc report for a multiple-project Gradle build

I have a Gradle multi-projects build where each subproject creates its own CodeNarc report. Is it possibile to create a single CodeNarc analysis report for all the projects in my build instead of a separate report for each of them?
pditommaso
  • 3,186
  • 6
  • 28
  • 43
0
votes
1 answer

Grails codenarc script not installing

I'm using Grails2.3.8 with codenarc 0.21, executing it using grails --non-interactive codenarc To install the codenarc plugin, I have in BuildConfig.groovy, grails.project.dependency.resolution, section plugins, the following: provided…
CharlesW
  • 955
  • 8
  • 18
0
votes
0 answers

CodeNarc rule violation for constants

[SRC]final String DATE_PATTERN_FOR_DIRECTORIES = "yyyy-MM-dd-kk-mm-ss" [MSG]The property name DATE_PATTERN_FOR_DIRECTORIES in class UploadTask does not match the pattern [a-z][a-zA-Z0-9]* I have a constant DATE_PATTERN_FOR_DIRECTORIES which…
Xelian
  • 16,680
  • 25
  • 99
  • 152
0
votes
1 answer

Depth of conditional nesting rules in Grails

I am doing some Static Code Analysis (SCA) on my Grails application. I have to check 'Depth of conditional nesting', but I am not able to find any Grails plugins do that. In CheckStyle (for Java projects (code)) there is NestedForDepth,…
Sun
  • 3,444
  • 7
  • 53
  • 83