All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codenarc.rule.gosu.AbstractGosuRule.groovy Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
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)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy