tags:

views:

200

answers:

1

Hi,

I´d like to create a PMD rule that checks for a regex expression in any file (txt, html, jsp, etc.). The rule does not use Java or XPath structure.

The idea is to read the file and add violations according to the line analyzed. I don´t know how to do this using Rule methods...

Any idea?

Thanks,

Andre

A: 

You would have to create a Java run that looked for a property containing the regex. It should be fairly straight forward. Extend AbstractRule so in say Rule.start you could use the RuleContext.getSourceCodeFile() to retrieve the file, load it and run your regex over it.

mlk