Automated Code Validators for Groovy Server Pages

Are there any automated code analysis / static code analysis tools (e.g. CodeNarc) for Groovy Server Pages (.gsp)?

+7
grails groovy code-review static-code-analysis
source share
1 answer

You can use the codenarc plugin to check your gsp pages / files.

Just install

codenarc.processViews = true 

in your BuildConfig.groovy file, and they will be included in the code character checks.

Here is an example of setting code in BuildConfig.groovy

 codenarc.processTestUnit = false codenarc.processTestIntegration = false codenarc.processViews = true codenarc.propertiesFile = 'grails-app/conf/codenarc.properties' codenarc.ruleSetFiles = [ "rulesets/basic.xml", "rulesets/braces.xml", "rulesets/grails.xml", "rulesets/groovyism.xml", ] 

Here we also define the external codenarc.properties file, which we use to enable / disable parts of the rules from each included set of rules. An example codenarc.properties file codenarc.properties here:

 # some gsp MUST have embedded CSS and/or embedded Javascript which requires the use of semicolons. UnnecessarySemicolon.doNotApplyToFileNames = *.gsp # we're not going to enforce these UnnecessaryGString.enabled = false UnnecessaryReturnKeyword.enabled = false 

Hope that helps

Tom

+2
source share

All Articles