Skip to content

Spike fine-grained filters#99

Draft
TheMrMilchmann wants to merge 1 commit into
nebula-plugins:mainfrom
TheMrMilchmann:feat/fine-grained-filters
Draft

Spike fine-grained filters#99
TheMrMilchmann wants to merge 1 commit into
nebula-plugins:mainfrom
TheMrMilchmann:feat/fine-grained-filters

Conversation

@TheMrMilchmann

Copy link
Copy Markdown
Contributor

This is a rough sketch of what I had in mind as a potential solution to #91. The core idea is that we define an extensible, serializable predicate data structure that loosely corresponds to ArchUnit's own predicate DSL.

This could then be used globally or per-rule (and hopefully eventually per sourceset) as follows:

archRules {
    ruleName("deprecated") {
        classesThat(not(simpleName("FailingCode")))
    }
}

Behind the scenes, this is trivially mapped to ArchUnit DescribedPredicate<JavaClass> instances using the visitor pattern and applied to each JavaClasses instance before checking the rule against it.

Let me know what you think of this approach, and if you like it, I'll flesh this out into a proper PR.

See #91

@wakingrufus

Copy link
Copy Markdown
Member

This is very clever, but I worry about exposing the archunit API in the plugin code this way, especially given the classpath isolation between the wrok action and plugin/buildscript. I also question whether it can work with configuration cache, as I am not sure the ArchrulesPredicate can actually be serialized.

I think a simpler solution would be apply a filter to the sourcesToCheck ConfigurableFileCollection, which is not as powerful, but much more likely to play well with Gradle

@TheMrMilchmann

Copy link
Copy Markdown
Contributor Author

This is not actually exposing the archunit APi in the plugin code, but replacing it. See nebula-archrules-gradle-plugin/src/main/kotlin/com/netflix/nebula/archrules/gradle/ArchrulesPredicate.kt

This is more upfront work but this way we could safely limit this to the serializable subset of predicates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants