Skip to content

Commit ea4aab5

Browse files
committed
Handle relative path configuration file
1 parent fe4f444 commit ea4aab5

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="Selects path to your custom detekt configuration file"/>
33+
<toolTipText value="Selects path to your custom 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
@@ -37,6 +38,12 @@ class DetektConfigStorage : PersistentStateComponent<DetektConfigStorage> {
3738

3839
@Tag
3940
var rulesPath: String = ""
41+
set(value) {
42+
field = if (value.isBlank() || File(value).isAbsolute)
43+
value
44+
else
45+
project.basePath + "/" + value
46+
}
4047

4148
override fun getState(): DetektConfigStorage? = this
4249

0 commit comments

Comments
 (0)