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

com.netflix.nebula.lint.rule.dependency.DependencyViolationUtil.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.rule.dependency

import com.netflix.nebula.lint.GradleViolation
import com.netflix.nebula.lint.rule.GradleDependency
import groovy.transform.CompileStatic
import org.codehaus.groovy.ast.expr.MethodCallExpression

@CompileStatic
class DependencyViolationUtil {

    static void replaceProjectDependencyConfiguration(GradleViolation violation, MethodCallExpression call, String configuration, String project) {
        violation.replaceWith(call, "$configuration project('$project')")
    }

    static void replaceDependencyConfiguration(GradleViolation violation, MethodCallExpression call, String conf, GradleDependency dep) {
        violation.replaceWith(call, "$conf '${dep.toNotation()}'")
    }

    static void replaceDependencyConfiguration(GradleViolation violation, MethodCallExpression call, String conf) {
        List lines = violation.files.text.readLines()
        List closureLines = lines.subList(call.lineNumber-1, call.lastLineNumber)
        String codeBlock = closureLines.join('\n').trim()
        violation.replaceWith(call, codeBlock.replace(call.methodAsString, conf))
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy