com.netflix.nebula.lint.rule.dependency.DependencyViolationUtil.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-lint-plugin Show documentation
Show all versions of gradle-lint-plugin Show documentation
Pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts
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