I have also looked for such a code quality test and have yet to find one.
Implementing this should be fairly trivial - if all text content in a GSP is required to be applied via tags, your GSP should consist entirely of element nodes and no text nodes.
This crux of the problem is predominantly an XML issue: how do you check a set of XML documents and flag those that contain text nodes?
Assuming you can import org.codehaus.groovy.grails.commons.GrailsResourceUtils
in a codenarc rule you can use the VIEWS_DIR_PATH
property to determine where all the GSP files live.
From there, the high level process you would need is:
- Build a collection of all the GSP files in the application
- For each file, load the content into an XML parser (Java has plenty) and check the node type for every node, flagging those files that contain text nodes
I appreciate that this is a very high level solution but conceptually it should work.