Skip to content

Commit 3be39fe

Browse files
committed
add linter
1 parent 67cdf05 commit 3be39fe

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

plugins/expressions-converter/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
kotlin("jvm")
44
id("com.github.johnrengelman.shadow") version "7.1.2"
55
kotlin("libs.publisher")
6+
id("org.jmailen.kotlinter")
67
}
78

89
group = "org.jetbrains.kotlinx.dataframe"
@@ -46,6 +47,14 @@ tasks.test {
4647
}
4748
}
4849

50+
kotlinter {
51+
ignoreFailures = false
52+
reporters = arrayOf("checkstyle", "plain")
53+
disabledRules = arrayOf(
54+
"max-line-length",
55+
)
56+
}
57+
4958
sourceSets {
5059
main {
5160
java.setSrcDirs(listOf("src"))

plugins/expressions-converter/tests/org/jetbrains/kotlinx/dataframe/classpathFromClassloader.kt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ fun classpathFromClassloader(currentClassLoader: ClassLoader, unpackJarCollectio
6262
setWritable(true, true)
6363
setExecutable(true, true)
6464

65-
Runtime.getRuntime().addShutdownHook(Thread {
66-
deleteRecursively()
67-
})
65+
Runtime.getRuntime().addShutdownHook(
66+
Thread {
67+
deleteRecursively()
68+
}
69+
)
6870
}
6971
}
7072
return allRelatedClassLoaders(currentClassLoader).flatMap { classLoader ->
@@ -198,7 +200,7 @@ fun classpathFromClass(classLoader: ClassLoader, klass: KClass<out Any>): List<F
198200
fun classpathFromClass(klass: KClass<out Any>): List<File>? =
199201
classpathFromClass(klass.java.classLoader, klass)
200202

201-
inline fun <reified T: Any> classpathFromClass(): List<File>? = classpathFromClass(T::class)
203+
inline fun <reified T : Any> classpathFromClass(): List<File>? = classpathFromClass(T::class)
202204

203205
fun classpathFromFQN(classLoader: ClassLoader, fqn: String): List<File>? {
204206
val clp = "${fqn.replace('.', '/')}.class"
@@ -207,8 +209,8 @@ fun classpathFromFQN(classLoader: ClassLoader, fqn: String): List<File>? {
207209

208210
fun File.matchMaybeVersionedFile(baseName: String) =
209211
name == baseName ||
210-
name == baseName.removeSuffix(".jar") || // for classes dirs
211-
Regex(Regex.escape(baseName.removeSuffix(".jar")) + "(-\\d.*)?\\.jar").matches(name)
212+
name == baseName.removeSuffix(".jar") || // for classes dirs
213+
Regex(Regex.escape(baseName.removeSuffix(".jar")) + "(-\\d.*)?\\.jar").matches(name)
212214

213215
fun File.hasParentNamed(baseName: String): Boolean =
214216
nameWithoutExtension == baseName || parentFile?.hasParentNamed(baseName) ?: false
@@ -310,7 +312,6 @@ fun scriptCompilationClasspathFromContextOrNull(
310312
?: classpathFromClasspathProperty()?.takeAndFilter()
311313
}
312314

313-
314315
fun scriptCompilationClasspathFromContext(
315316
vararg keyNames: String,
316317
classLoader: ClassLoader = Thread.currentThread().contextClassLoader,
@@ -363,19 +364,21 @@ object KotlinJars {
363364
val kotlinBaseJars = kotlinCompilerJars + kotlinLibsJars + kotlinScriptingJars
364365

365366
val classpath = explicitCompilerClasspath
366-
// search classpath from context classloader and `java.class.path` property
367-
?: (classpathFromFQN(Thread.currentThread().contextClassLoader, "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
368-
?: classpathFromClassloader(Thread.currentThread().contextClassLoader)?.takeIf { it.isNotEmpty() }
369-
?: classpathFromClasspathProperty()
370-
)?.filter { f -> kotlinBaseJars.any { f.matchMaybeVersionedFile(it) } }?.takeIf { it.isNotEmpty() }
367+
// search classpath from context classloader and `java.class.path` property
368+
?: (
369+
classpathFromFQN(Thread.currentThread().contextClassLoader, "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
370+
?: classpathFromClassloader(Thread.currentThread().contextClassLoader)?.takeIf { it.isNotEmpty() }
371+
?: classpathFromClasspathProperty()
372+
)?.filter { f -> kotlinBaseJars.any { f.matchMaybeVersionedFile(it) } }?.takeIf { it.isNotEmpty() }
371373
// if autodetected, additionally check for presence of the compiler jars
372-
if (classpath == null || (explicitCompilerClasspath == null && classpath.none { f ->
374+
if (classpath == null || (
375+
explicitCompilerClasspath == null && classpath.none { f ->
373376
kotlinCompilerJars.any {
374-
f.matchMaybeVersionedFile(
375-
it
376-
)
377+
f.matchMaybeVersionedFile(it)
377378
}
378-
})) {
379+
}
380+
)
381+
) {
379382
throw FileNotFoundException("Cannot find kotlin compiler jar, set kotlin.compiler.classpath property to proper location")
380383
}
381384
return classpath
@@ -422,5 +425,4 @@ object KotlinJars {
422425
"kotlin.reflect.full.KClasses" // using a class that is a part of the kotlin-reflect.jar
423426
)
424427
}
425-
426428
}

plugins/expressions-converter/tests/org/jetbrains/kotlinx/dataframe/commonFirWithPluginFrontendConfiguration.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.jetbrains.kotlinx.dataframe
33
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
44

55
fun TestConfigurationBuilder.commonFirWithPluginFrontendConfiguration() {
6-
76
defaultDirectives {
87
// +ENABLE_PLUGIN_PHASES
98
// +FIR_DUMP

plugins/expressions-converter/tests/org/jetbrains/kotlinx/dataframe/pathUtil.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ private fun splitJarUrl(url: String): Pair<String, String>? {
6767
jarPath = jarPath.substring(1)
6868
}
6969
}
70-
7170
}
7271
return Pair(jarPath, resourcePath)
7372
}

0 commit comments

Comments
 (0)