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
8
votes
1 answer

How to automatically find I18N Violations

Is there anyway to automatically find I18N violations in a Grails project? For example, should be flagged because it's not using to get the label value. It would…
Brad Rhoads
  • 1,828
  • 3
  • 29
  • 52
7
votes
1 answer

Configuring CodeNarc in Gradle

I am trying to wrap my head around using CodeNarc inside of Gradle. According to the CodeNarc docs, my project needs to have a config/codenarc/codenarc.xml config file defined. But then I see plenty of example config files (such as this…
smeeb
  • 27,777
  • 57
  • 250
  • 447
7
votes
3 answers

Static import statements which should never be after nonstatic imports

Codenarc is a framework that analyzes Groovy code for defects, bad practices, inconsistencies, style issues and more. Is there a reason for this rule: MisorderedStaticImports Rule: Checks for static import statements which should never be after…
Arturo Herrero
  • 12,772
  • 11
  • 42
  • 73
5
votes
1 answer

How to publish Codenarc report for Gradle project in Jenkins?

I am trying to generate Codenarc reports for my Gradle Groovy project and publish them in Jenkins. I successfully configured my Gradle project to produce Codenarc reports with: build.gradle apply plugin: 'codenarc' ... dependencies { codenarc…
Svante
  • 1,069
  • 3
  • 12
  • 28
4
votes
1 answer

Fix UnnecessaryGString violations in IntelliJ IDEA

When I analyzed my project using CodeNarc I get huge number of UnnecessaryGString violations. I can fix them one by one by pressing ALT+ENTER and choosing Convert to String option. This is very tedious process though. Is there any autofix in…
Michal Kordas
  • 10,475
  • 7
  • 58
  • 103
4
votes
1 answer

Run codenarc inspection in realtime in intellij

Is there any way to run inspections in real time in intellij, rather than just having to select Analyze > Inspect Code. In particular, I'd like to do real time codenarc analysis (similar to how Eclipse does with checkstyle) so when I save a file it…
Jeff Storey
  • 56,312
  • 72
  • 233
  • 406
3
votes
5 answers

grails-CodeNarc and Service Stateless ruleSet

I am trying to use codeNarc on a grails project, after installing it and running it I've have some rulesets violations messages that I would like to understand and resolve. The first on concern "GrailsStatelessService" and the second the …
KAdjevi
  • 33
  • 6
3
votes
1 answer

Codenarc unable to resolve groovy classes

I am using codenarc 1.4 with gradle to test groovy code in a Jenkins shared library, but when running it outputs errors saying it was unable to resolve groovy.lang.Closure though this doesn't seem to prevent the checks being run. An example of the…
user1013341
  • 336
  • 1
  • 9
3
votes
1 answer

Static code analysis for groovy with eclipse

I want to add static code analysis plugin to eclipse (Eclipse Mars 4.6). For that I added sonarlint plugin which contains rules for groovy project as well. But it could not analyse groovy files or can give any suggestions for the same. I searched…
P Punam
  • 151
  • 1
  • 8
3
votes
3 answers

Generate multiple report types using CodeNarc in Gradle

I want to generate both HTML and console report in CodeNarc in Gradle. My build.gradle: apply plugin: 'codenarc' ... codenarc { toolVersion = '0.24.1' configFile = file('config/codenarc/codenarc.groovy') reportFormat = 'html' } This…
Michal Kordas
  • 10,475
  • 7
  • 58
  • 103
3
votes
2 answers

Sonar runner codenarc sensor ignore violation from Codenarc

I have grails project with CodeNarc Plugin installed and generated xml report. Installed and configured SonarQube with following configurations and versions: Grails 2.3.7 SonarQube server- 4.5 SonarQube Runner- 2.4 CodeNarc Plugin- 0.22 …
Laxmi Salunkhe
  • 509
  • 1
  • 4
  • 19
3
votes
1 answer

How to include custom rules in the grails codenarc plugin

I have a set of custom rules for codenarc and they use inheritance and abstract classes to share some code. The question is how to use this rules without modifying codenarc and building the codenarc.jar myself or How to inject classes into codenarc…
deflomu
  • 596
  • 1
  • 4
  • 16
2
votes
1 answer

How to define which Folders/Directories the CodeNarc Gradle Plugin will scan/analyse

What do I want to do? I want to tell CodeNarc which folders/directories it is supposed to scan/analyse. I cant find anything about that on the official site (http://codenarc.sourceforge.net/) or on the gradle plugin documentation…
Saturas
  • 535
  • 1
  • 4
  • 12
2
votes
1 answer

How do I get the Gradle CodeNarc task to check the Gradle build files?

Gradle build files (*.gradle) are Groovy, so I'd like to perform code style checks on the build files, as with any other code in the project. So I figured CodeNarc would work for this. The minimum to get CodeNarc itself hooked into Gradle appears to…
Hakanai
  • 12,010
  • 10
  • 62
  • 132
2
votes
0 answers

not finding codenarc ruleset using build.gradle

Trying to apply codenarc to a spring boot project, however the gradle build is producing :codenarcMain NO-SOURCE. Please advise on what I am doing wrong. 1) Added plugins to build.gradle apply plugin: 'groovy' apply plugin: 'codenarc' 2) Then…
henninb
  • 133
  • 2
  • 11
1
2 3 4 5