Skip to content

Commit

Permalink
Run the experimental rules by default
Browse files Browse the repository at this point in the history
There is no need for a separate build task to run the experimental rules. The
experimental rules can be executed by default in the "ktlint" task. Also, the
baseline has been fixed so there is no longer a need to use extension "_kt"
for the baseline test files.

Closes pinterest#1222
  • Loading branch information
Paul Dingemans committed Dec 13, 2021
1 parent 8642e87 commit fd17608
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
13 changes: 4 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,12 @@ dependencies {
}

task ktlint(type: JavaExec, group: LifecycleBasePlugin.VERIFICATION_GROUP) {
description = "Check Kotlin code style."
description = "Check Kotlin code style including experimental rules."
classpath = configurations.ktlint
main = 'com.pinterest.ktlint.Main'
args '**/src/**/*.kt', '--baseline=ktlint-baseline.xml', '--verbose'
}

task ktlint_experimental(type: JavaExec, group: LifecycleBasePlugin.VERIFICATION_GROUP) {
description = "Check Kotlin code style with experimental rules."
classpath = configurations.ktlint
main = 'com.pinterest.ktlint.Main'
args '**/src/**/*.kt', '--verbose', '--experimental'
// Experimental rules run by default run on the ktlint code base itself. Experimental rules should not be released if
// we are not pleased ourselves with the results on the ktlint code base.
args '**/src/**/*.kt', '--baseline=ktlint/src/test/resources/ktlint-test-baseline.xml', '--experimental', '--verbose'
}

/**
Expand Down
11 changes: 11 additions & 0 deletions ktlint/src/test/resources/ktlint-test-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
<file name="ktlint/src/test/resources/TestBaselineExtraErrorFile.kt">
<error line="3" column="34" source="no-empty-class-body" />
<error line="4" column="1" source="no-blank-line-before-rbrace" />
</file>
<file name="ktlint/src/test/resources/TestBaselineFile.kt">
<error line="3" column="24" source="no-empty-class-body" />
<error line="4" column="1" source="no-blank-line-before-rbrace" />
</file>
</baseline>
10 changes: 0 additions & 10 deletions ktlint/src/test/resources/test-baseline.xml

This file was deleted.

0 comments on commit fd17608

Please # to comment.