-
Hello, I am wandering, can I add custom rules in my project without adding them to diktat repository? Something like this (pseudocode):
module's
Project structure |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 26 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Hi, @SJOwl !
Alternatively, you can include your rules in diktat itself: diktat uses the same rules format as ktlint, so providing a jar with your rules as a classpath dependency for apply 'org.cqfn.diktat.diktat-gradle-plugin'
configurations.getByName("diktat").dependencies.add("your lint-rules") |
Beta Was this translation helpful? Give feedback.
Hi, @SJOwl !
Yes, you can use
diktat-test-framework
as a dependency for testing your rules. It's a pretty generic framework that doesn't even depend on ktlint, so you'll need something like our FixTestBase: basically, there are two things:TestComparatorUnit
is set up to run ktlint'sformat
methodTestComparatorUnit.compareFilesFromResources
is called to run and compare outputAlternatively, you can include your rules in diktat itself: diktat uses the same rules format as ktlint, so providing a jar with your rules as a classpath dependency for
diktat-gradle-plugin
should be enough. To do so you can include it indiktat
configuration that is created when applying diktat plugin, like that…