Skip to content

Commit

Permalink
Fix ignore delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Jan 2, 2016
1 parent aaa815b commit 16fc8e5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ It assists a centralized build tools team in gently introducing and maintaining
To apply this plugin:

plugins {
id 'nebula.lint' version '0.3.0'
id 'nebula.lint' version '0.4.0'
}

Alternatively:
Expand Down
5 changes: 5 additions & 0 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ repositories {

dependencies {
compile('org.codenarc:CodeNarc:latest.release')

gradleLint.ignore('dependency-parentheses') {
compile('com.google.guava:guava:latest.release')
}

testCompile group: 'com.netflix.nebula', name: 'nebula-test',
version: '+'
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class GradleLintExtension {
}
}

// do nothing, these are just markers for the linter
void ignore(Closure c) { }
void ignore(String ruleName, Closure c) { }
void ignore(String r1, String r2, Closure c) { }
void ignore(String r1, String r2, String r3, Closure c) { }
void ignore(String r1, String r2, String r3, String r4, Closure c) { }
void ignore(String r1, String r2, String r3, String r4, String r5, Closure c) { }
// pass-thru markers for the linter to know which blocks of code to ignore
void ignore(Closure c) { c() }
void ignore(String ruleName, Closure c) { c() }
void ignore(String r1, String r2, Closure c) { c() }
void ignore(String r1, String r2, String r3, Closure c) { c() }
void ignore(String r1, String r2, String r3, String r4, Closure c) { c() }
void ignore(String r1, String r2, String r3, String r4, String r5, Closure c) { c() }
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.netflix.nebula.lint.rule

import com.netflix.nebula.lint.plugin.GradleLintPlugin
import com.netflix.nebula.lint.plugin.LintRuleRegistry
import org.codehaus.groovy.ast.expr.MethodCallExpression
import org.codenarc.rule.AbstractAstVisitorRule
import org.codenarc.rule.AstVisitor
import org.gradle.api.plugins.JavaPlugin
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import spock.lang.Unroll
Expand Down Expand Up @@ -150,6 +152,22 @@ class AbstractGradleLintVisitorSpec extends AbstractRuleSpec {
/'no-plugins-allowed','other-rule'/ | false
}
def 'ignore closure properly delegates'() {
when:
project.with {
plugins.apply(JavaPlugin)
plugins.apply(GradleLintPlugin)
dependencies {
gradleLint.ignore {
compile 'com.google.guava:guava:19.0'
}
}
}
then:
project.configurations.compile.dependencies.any { it.name == 'guava' }
}
static class SimpleLintVisitor extends AbstractGradleLintVisitor {
List<GradleDependency> visitedDeps = []
List<String> appliedPlugins = []
Expand Down

0 comments on commit 16fc8e5

Please sign in to comment.