Skip to content

Commit

Permalink
Make code more readable (#7146)
Browse files Browse the repository at this point in the history
* Add name to variables

* Add Language Annotation
  • Loading branch information
BraisGabin committed Apr 8, 2024
1 parent c8cd8b3 commit 637a318
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class KtFileModifier : FileProcessListener {
override fun onFinish(files: List<KtFile>, result: Detektion, bindingContext: BindingContext) {
files.filter { it.modificationStamp > 0 }
.map { it.absolutePath() to it.unnormalizeContent() }
.forEach {
result.add(ModificationNotification(it.first))
it.first.writeText(it.second)
.forEach { (path, content) ->
result.add(ModificationNotification(path))
path.writeText(content)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.github.detekt.psi.absolutePath
import io.github.detekt.psi.basePath
import io.github.detekt.psi.lineSeparator
import io.github.detekt.psi.relativePath
import org.intellij.lang.annotations.Language
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.com.intellij.openapi.util.text.StringUtilRt
import org.jetbrains.kotlin.psi.KtFile
Expand All @@ -26,7 +27,7 @@ open class KtCompiler(
return createKtFile(content, basePath, path)
}

fun createKtFile(content: String, basePath: Path, path: Path): KtFile {
fun createKtFile(@Language("kotlin") content: String, basePath: Path, path: Path): KtFile {
val normalizedAbsolutePath = path.absolute().normalize()
val lineSeparator = content.determineLineSeparator()

Expand Down

0 comments on commit 637a318

Please sign in to comment.