<commit_before>package io.gitlab.arturbosch.detekt.cli

import io.gitlab.arturbosch.detekt.api.CompositeConfig
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.YamlConfig
import io.gitlab.arturbosch.detekt.core.PathFilter
import java.io.File
import java.nio.file.Path
import java.nio.file.Paths

/**
 * @author <NAME>
 */

fun Main.createPathFilters(): List<PathFilter> = filters.letIfNonEmpty { split(*SEPARATORS).map(::PathFilter) }

fun Main.createRulePaths(): List<Path> = rules.letIfNonEmpty { split(*SEPARATORS).map { Paths.get(it) } }

private fun <T> String?.letIfNonEmpty(init: String.() -> List<T>): List<T> =
		if (this == null || this.isEmpty()) listOf<T>() else this.init()

fun Main.loadConfiguration(): Config = when {
	!config.isNullOrBlank() -> parsePathConfig(config!!)
	!configResource.isNullOrBlank() -> parseResourceConfig(configResource!!)
	formatting -> FormatConfig(useTabs)
	else -> Config.empty
}.apply {
	if (debug) println("\n$this\n")
}

private fun parseResourceConfig(config: String): Config {
	val urls = MultipleClasspathResourceConverter().convert(config)
	return if (urls.size == 1) {
		YamlConfig.loadResource(urls[0])
	} else {
		urls.map { YamlConfig.loadResource(it) }.reduce { composite, config -> CompositeConfig(config, composite) }
	}
}
<commit_msg>Use PathConverter for rules property<commit_after>package io.gitlab.arturbosch.detekt.cli

import io.gitlab.arturbosch.detekt.api.CompositeConfig
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.YamlConfig
import io.gitlab.arturbosch.detekt.core.PathFilter
import java.io.File
import java.nio.file.Path

/**
 * @author <NAME>
 */

fun Main.createPathFilters(): List<PathFilter> = filters.letIfNonEmpty { split(*SEPARATORS).map(::PathFilter) }

fun Main.createRulePaths(): List<Path> = rules.letIfNonEmpty {
	MultipleExistingPathConverter().convert(this)
}

private fun <T> String?.letIfNonEmpty(init: String.() -> List<T>): List<T> =
		if (this == null || this.isEmpty()) listOf<T>() else this.init()

fun Main.loadConfiguration(): Config = when {
	!config.isNullOrBlank() -> parsePathConfig(config!!)
	!configResource.isNullOrBlank() -> parseResourceConfig(configResource!!)
	formatting -> FormatConfig(useTabs)
	else -> Config.empty
}.apply {
	if (debug) println("\n$this\n")
}

private fun parseResourceConfig(config: String): Config {
	val urls = MultipleClasspathResourceConverter().convert(config)
	return if (urls.size == 1) {
		YamlConfig.loadResource(urls[0])
	} else {
		urls.map { YamlConfig.loadResource(it) }.reduce { composite, config -> CompositeConfig(config, composite) }
	}
}

{'fraction_non_alphanumeric': 0.1493604213694507, 'fraction_numerical': 0.0015048908954100827, 'mean_word_length': 5.598014888337469, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2895369', 'n_tokens_mistral': 913, 'n_tokens_neox': 920, 'n_words': 161}