Skip to content

Commit

Permalink
Add suggestions from review #3406
Browse files Browse the repository at this point in the history
  • Loading branch information
Nereboss committed Nov 22, 2023
1 parent 868bb00 commit 4ddd31b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package de.maibornwolff.codecharta.util

import picocli.CommandLine

class StringToListInputConverter : CommandLine.ITypeConverter<List<String>> {
override fun convert(value: String?): List<String>? {
class CommaSeparatedStringToListConverter : CommandLine.ITypeConverter<List<String>> {
override fun convert(value: String?): List<String> {
if (value != null) {
return value.split(",")
.map { e -> e.trim() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class StringToListInputConverterTest {
fun `should return empty list for null input`() {
val input = null

val stringToListInputConverter = StringToListInputConverter()
val stringToListInputConverter = CommaSeparatedStringToListConverter()
val result = stringToListInputConverter.convert(input)
val expected = listOf<String>()

Expand All @@ -20,7 +20,7 @@ class StringToListInputConverterTest {
fun `should return empty list for empty string input`() {
val input = ""

val stringToListInputConverter = StringToListInputConverter()
val stringToListInputConverter = CommaSeparatedStringToListConverter()
val result = stringToListInputConverter.convert(input)
val expected = listOf<String>()

Expand All @@ -31,7 +31,7 @@ class StringToListInputConverterTest {
fun `should return list with single entry for single string input`() {
val input = "entry"

val stringToListInputConverter = StringToListInputConverter()
val stringToListInputConverter = CommaSeparatedStringToListConverter()
val result = stringToListInputConverter.convert(input)
val expected = listOf(input)

Expand All @@ -42,7 +42,7 @@ class StringToListInputConverterTest {
fun `should return list with all entries for input string with multiple values`() {
val input = "entry1, entry2, entry3"

val stringToListInputConverter = StringToListInputConverter()
val stringToListInputConverter = CommaSeparatedStringToListConverter()
val result = stringToListInputConverter.convert(input)
val expected = listOf("entry1", "entry2", "entry3")

Expand All @@ -53,7 +53,7 @@ class StringToListInputConverterTest {
fun `should remove whitespace for all entries`() {
val input = " entry1 , entry2, entry3, \n, \t, \r"

val stringToListInputConverter = StringToListInputConverter()
val stringToListInputConverter = CommaSeparatedStringToListConverter()
val result = stringToListInputConverter.convert(input)
val expected = listOf("entry1", "entry2", "entry3")

Expand All @@ -64,7 +64,7 @@ class StringToListInputConverterTest {
fun `should return all but empty entries for input string with multiple values`() {
val input = "entry1, , entry2, , ,entry3"

val stringToListInputConverter = StringToListInputConverter()
val stringToListInputConverter = CommaSeparatedStringToListConverter()
val result = stringToListInputConverter.convert(input)
val expected = listOf("entry1", "entry2", "entry3")

Expand All @@ -75,7 +75,7 @@ class StringToListInputConverterTest {
fun `should return empty list for input string with empty values only`() {
val input = " , , , ,,"

val stringToListInputConverter = StringToListInputConverter()
val stringToListInputConverter = CommaSeparatedStringToListConverter()
val result = stringToListInputConverter.convert(input)
val expected = listOf<String>()

Expand Down
1 change: 0 additions & 1 deletion analysis/parser/RawTextParser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies {
implementation group: 'org.json', name: 'json', version: json_version
implementation group: 'com.google.code.gson', name: 'gson', version: gson_version
implementation group: 'com.github.kotlin-inquirer', name: 'kotlin-inquirer', version: kotlin_inquirer_version
implementation project(path: ':import:SourceCodeParser')

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: junit5_version
testImplementation group: 'org.assertj', name: 'assertj-core', version: assertj_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import de.maibornwolff.codecharta.serialization.ProjectSerializer
import de.maibornwolff.codecharta.tools.interactiveparser.InteractiveParser
import de.maibornwolff.codecharta.tools.interactiveparser.ParserDialogInterface
import de.maibornwolff.codecharta.tools.interactiveparser.util.CodeChartaConstants
import de.maibornwolff.codecharta.util.CommaSeparatedStringToListConverter
import de.maibornwolff.codecharta.util.InputHelper
import de.maibornwolff.codecharta.util.StringToListInputConverter
import mu.KotlinLogging
import picocli.CommandLine
import java.io.File
Expand Down Expand Up @@ -46,7 +46,7 @@ class RawTextParser(
arity = "0..",
names = ["-m", "--metrics"],
description = ["metrics to be computed (select all if not specified)"],
converter = [(StringToListInputConverter::class)]
converter = [(CommaSeparatedStringToListConverter::class)]
)
private var metrics: List<String> = listOf()

Expand All @@ -65,13 +65,13 @@ class RawTextParser(
@CommandLine.Option(
names = ["-e", "--exclude"],
description = ["exclude file/folder according to regex pattern"],
converter = [(StringToListInputConverter::class)])
converter = [(CommaSeparatedStringToListConverter::class)])
private var exclude: List<String> = listOf()

@CommandLine.Option(
names = ["-fe", "--file-extensions"],
description = ["parse only files with specified extensions (default: any)"],
converter = [(StringToListInputConverter::class)]
converter = [(CommaSeparatedStringToListConverter::class)]
)
private var fileExtensions: List<String> = listOf()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MetricCollectorTest {
}

@Test
fun `Should exlude regex patterns`() {
fun `Should exclude regex patterns`() {
val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, exclude = listOf(".*\\.excluded$", "foobar")).parse()

Assertions.assertThat(result.size).isEqualTo(4)
Expand All @@ -43,7 +43,7 @@ class MetricCollectorTest {
}

@Test
fun `Should include only spedified File extensions`() {
fun `Should include only specified File extensions`() {
val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, fileExtensions = listOf("includedtoo")).parse()

Assertions.assertThat(result.size).isEqualTo(1)
Expand Down

0 comments on commit 4ddd31b

Please sign in to comment.