org.codenarc.rule.gosu.AbstractGosuRule.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gs-codenarc-ext Show documentation
Show all versions of gs-codenarc-ext Show documentation
A CodeNarc extension library for gosu.
package org.codenarc.rule.gosu
import org.codenarc.plugin.FileViolations
import org.codenarc.plugin.disablerules.DisableRulesInCommentsPlugin
import org.codenarc.results.FileResults
import org.codenarc.rule.AbstractRule
import org.codenarc.rule.Violation
import org.codenarc.source.SourceCode
import org.codenarc.source.SourceString
abstract class AbstractGosuRule extends AbstractRule {
protected DisableRulesInCommentsPlugin filter = new DisableRulesInCommentsPlugin()
abstract void gosuApplyTo(SourceCode sourceCode, List violations)
@Override
void applyTo(SourceCode sourceCode, List violations) {
gosuApplyTo(sourceCode, violations)
filterViolations(sourceCode.text, violations)
}
protected void filterViolations(String sourceText, List violations) {
SourceString sourceCode = new SourceString(sourceText)
FileResults fileResults = new FileResults('path', violations, sourceCode)
FileViolations fileViolations = new FileViolations(fileResults)
filter.processViolationsForFile(fileViolations)
}
}