Skip to content

Commit

Permalink
Allow the indent size to be configured (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen authored and jeremymailen committed Jun 22, 2017
1 parent 1f7eda0 commit 79a9a28
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ open class KotlinterExtension {

/** Don't fail build on lint issues */
var ignoreFailures = false

var indentSize = 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class KotlinterPlugin : Plugin<Project> {
project.afterEvaluate {
project.tasks.withType(LintTask::class.java) { lintTask ->
lintTask.ignoreFailures = kotlinterExtention.ignoreFailures
lintTask.indentSize = kotlinterExtention.indentSize
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ open class LintTask : SourceTask() {
@Input
var ignoreFailures = false

@Input
var indentSize = 4

@TaskAction
fun run() {
var errors = ""
Expand Down Expand Up @@ -58,7 +61,7 @@ open class LintTask : SourceTask() {
}

private fun lintKt(file: File, ruleSets: List<RuleSet>, onError: (line: Int, col: Int, detail: String) -> Unit) {
KtLint.lint(file.readText(), ruleSets) { error ->
KtLint.lint(file.readText(), ruleSets, mapOf("indent_size" to indentSize.toString())) { error ->
onError(error.line, error.col, error.detail)
}
}
Expand Down

0 comments on commit 79a9a28

Please sign in to comment.