Skip to content

Commit e51ece4

Browse files
committed
Handle relative path configuration file
1 parent 857f0cb commit e51ece4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Diff for: src/main/java/io/gitlab/arturbosch/detekt/config/DetektConfigurationForm.form

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</constraints>
3131
<properties>
3232
<text value=""/>
33-
<toolTipText value="Path to detekt configuration file"/>
33+
<toolTipText value="Path to detekt configuration file. A relative path can be used, and will be relative to project directory."/>
3434
</properties>
3535
</component>
3636
</children>

Diff for: src/main/kotlin/io/gitlab/arturbosch/detekt/config/DetektConfigStorage.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.intellij.openapi.components.Storage
77
import com.intellij.openapi.components.StoragePathMacros
88
import com.intellij.openapi.project.Project
99
import com.intellij.util.xmlb.annotations.Tag
10+
import java.io.File
1011

1112
/**
1213
* @author Dmytro Primshyts
@@ -15,7 +16,7 @@ import com.intellij.util.xmlb.annotations.Tag
1516
name = "DetektProjectConfiguration",
1617
storages = [(Storage(StoragePathMacros.WORKSPACE_FILE))]
1718
)
18-
class DetektConfigStorage : PersistentStateComponent<DetektConfigStorage> {
19+
class DetektConfigStorage(val project: Project) : PersistentStateComponent<DetektConfigStorage> {
1920

2021
@Tag
2122
var enableDetekt: Boolean = false
@@ -34,6 +35,12 @@ class DetektConfigStorage : PersistentStateComponent<DetektConfigStorage> {
3435

3536
@Tag
3637
var rulesPath: String = ""
38+
set(value) {
39+
field = if (value.isBlank() || File(value).isAbsolute)
40+
value
41+
else
42+
project.basePath + "/" + value
43+
}
3744

3845
override fun getState(): DetektConfigStorage? = this
3946

0 commit comments

Comments
 (0)