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

com.netflix.nebula.lint.GradleLintInfoBrokerAction.groovy Maven / Gradle / Ivy

Go to download

Pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts

There is a newer version: 20.2.2
Show newest version
package com.netflix.nebula.lint

import groovy.transform.Canonical
import org.gradle.api.Project

@Canonical
class GradleLintInfoBrokerAction extends GradleLintViolationAction {
    Project project

    @Override
    void lintFinished(Collection violations) {
        project.getPlugins().withId('nebula.info-broker') {
            def reportItems = violations.collect { buildReportItem(it) }
            it.addReport('gradleLintViolations', reportItems)
        }
    }

    @Override
    void lintFixesApplied(Collection violations) {
        project.getPlugins().withId('nebula.info-broker') {
            def reportItems = violations.findAll { !it.fixes.any { it.reasonForNotFixing } }
                    .collect { buildReportItem(it) }
            it.addReport('fixedGradleLintViolations', reportItems)
        }
    }

    LintReportItem buildReportItem(GradleViolation v) {
        def buildFilePath = project.rootDir.toURI().relativize(v.file.toURI()).toString()
        new LintReportItem(buildFilePath, v.rule.name, v.rule.getPriority() as String,
                v.lineNumber ?: -1, v.sourceLine ?: 'unspecified', v.message ?: "")
    }
}

@Canonical
class LintReportItem {
    String buildFilePath
    String ruleId
    String severity
    Integer lineNumber
    String sourceLine
    String message
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy