diff --git a/CHANGELOG.md b/CHANGELOG.md index 92eef2e762..05ae072c80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/) ## [unreleased] (Added 🚀 | Changed | Removed 🗑 | Fixed 🐞 | Chore 👨‍💻 👩‍💻) +### Changed + +- Changed short form of parameter `--file-extensions` of RawTextParser from `-f` to `-fe` [#3405](https://github.com/MaibornWolff/codecharta/pull/3405) +- Update readme and gh-pages for RawTextParser [#3405](https://github.com/MaibornWolff/codecharta/pull/3405) + +### Fixed 🐞 + +- Fix RawTextParser producing incorrect output when no (or multiple) file extensions were specified in interactive mode [#3405](https://github.com/MaibornWolff/codecharta/pull/3405) + ## [1.120.1] - 2023-11-17 ### Removed 🗑 diff --git a/analysis/parser/RawTextParser/README.md b/analysis/parser/RawTextParser/README.md index 7af0a9d173..aee844f5d1 100644 --- a/analysis/parser/RawTextParser/README.md +++ b/analysis/parser/RawTextParser/README.md @@ -9,28 +9,33 @@ This parser analyzes code regardless of the programming language used to generat ## Parameters ``` -Usage: rawtextparser [-hv] [--withoutDefaultExcludes] - [--maxIndentationLevel=] - [--tabWidth=] [-o=] - [-p=] [-e=]... [-m - [=...]]... FILE or FOLDER +Usage: rawtextparser [-hv] [-nc] [--without-default-excludes] + [--max-indentation-level=] + [-o=] [--tab-width=] + [-e=]... [-fe=[\s*, + \s*...]]... [-m[=...]]... + FILE or FOLDER generates cc.json from projects or source code files - FILE or FOLDER file/project to parse - --maxIndentationLevel= - maximum Indentation Level (default 10) - --tabWidth= tab width used (estimated if not provided) - --withoutDefaultExcludes - include build, target, dist, resources and out folders - as well as files/folders starting with '.' - -e, --exclude= exclude file/folder according to regex pattern - -h, --help displays this help and exits + FILE or FOLDER file/project to parse + -e, --exclude= exclude file/folder according to regex pattern + -fe, --file-extensions=[\s*,\s*...] + parse only files with specified extensions + (default: any) + -h, --help displays this help and exits -m, --metrics[=...] - metrics to be computed (select all if not specified) - -o, --outputFile= - output File (or empty for stdout) - -p, --projectName= - project name - -v, --verbose verbose mode + metrics to be computed (select all if not specified) + --max-indentation-level= + maximum Indentation Level (default 10) + -nc, --not-compressed save uncompressed output File + -o, --output-file= + output File (or empty for stdout) + --tab-width= + tab width used (estimated if not provided) + -v, --verbose verbose mode + --without-default-excludes + include build, target, dist, resources and out + folders as well as files/folders starting with + '.' ``` ## Examples @@ -42,7 +47,7 @@ ccsh rawtextparser foo/bar/project ``` ``` -ccsh rawtextparser foo.txt --maxIndentationLevel=6 tabWidth=4 --metrics=IndentationLevel +ccsh rawtextparser foo.txt --max-indentation-level=6 tab-width=4 --metrics=IndentationLevel ``` ``` diff --git a/analysis/parser/RawTextParser/build.gradle b/analysis/parser/RawTextParser/build.gradle index 0fd929b06a..1bef8c4eb0 100644 --- a/analysis/parser/RawTextParser/build.gradle +++ b/analysis/parser/RawTextParser/build.gradle @@ -12,6 +12,7 @@ dependencies { testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: junit5_version testImplementation group: 'org.assertj', name: 'assertj-core', version: assertj_version testImplementation group: 'io.mockk', name: 'mockk', version: mockk_version + testImplementation group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.1' } test { diff --git a/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/MetricCollector.kt b/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/MetricCollector.kt index 407284a7f1..cf6f1c4752 100644 --- a/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/MetricCollector.kt +++ b/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/MetricCollector.kt @@ -58,7 +58,10 @@ class MetricCollector( } private fun isParsableFileExtension(path: String): Boolean { - return fileExtensions.isEmpty() || fileExtensions.contains(path.substringAfterLast(".")) + return fileExtensions.isEmpty() || + fileExtensions.contentEquals(arrayOf("")) || + fileExtensions.contains(path.substringAfterLast(".")) || + fileExtensions.contains(".${path.substringAfterLast(".")}") } private fun isPathExcluded(path: String): Boolean { diff --git a/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/ParserDialog.kt b/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/ParserDialog.kt index 81d9446b5d..c41b78f8e8 100644 --- a/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/ParserDialog.kt +++ b/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/ParserDialog.kt @@ -18,7 +18,7 @@ class ParserDialog { ) val outputFileName: String = KInquirer.promptInput( - message = "What is the name of the output file?", + message = "What is the name of the output file (leave empty to print to stdout)?", ) val isCompressed = (outputFileName.isEmpty()) || KInquirer.promptConfirm( @@ -44,7 +44,7 @@ class ParserDialog { KInquirer.promptInput(message = "Do you want to exclude file/folder according to regex pattern?", default = "", hint = "regex1, regex2.. (leave empty if you don't want to exclude anything)") val fileExtensions: String = - KInquirer.promptInput(message = "Do you want to exclude file/folder according to regex pattern?", default = "", hint = "regex1, regex2.. (leave empty if you don't want to exclude anything)") + KInquirer.promptInput(message = "Do you only want to parse files with specific file-extensions? ", default = "", hint = "fileType1, fileType2... (leave empty to include all file-extensions)") val withoutDefaultExcludes: Boolean = KInquirer.promptConfirm(message = "Do you want to include build, target, dist, resources and out folders as well as files/folders starting with '.'?", default = false) diff --git a/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/RawTextParser.kt b/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/RawTextParser.kt index f7345f3ae6..57abbed0bb 100644 --- a/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/RawTextParser.kt +++ b/analysis/parser/RawTextParser/src/main/kotlin/de/maibornwolff/codecharta/parser/rawtextparser/RawTextParser.kt @@ -8,6 +8,7 @@ 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.InputHelper +import mu.KotlinLogging import picocli.CommandLine import java.io.File import java.io.IOException @@ -27,6 +28,8 @@ class RawTextParser( private val error: PrintStream = System.err, ) : Callable, InteractiveParser { + private val logger = KotlinLogging.logger {} + private val DEFAULT_EXCLUDES = arrayOf("/out/", "/build/", "/target/", "/dist/", "/resources/", "/\\..*") @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["displays this help and exits"]) @@ -61,8 +64,9 @@ class RawTextParser( private var exclude: Array = arrayOf() @CommandLine.Option( - names = ["-f", "--file-extensions"], - description = ["parse only files with specified extensions (defualt: any)"] + names = ["-fe", "--file-extensions"], + description = ["parse only files with specified extensions (default: any)"], + split = "\\s*,\\s*" ) private var fileExtensions: Array = arrayOf() @@ -97,6 +101,15 @@ class RawTextParser( val parameterMap = assembleParameterMap() val results: Map = MetricCollector(inputFile!!, exclude, fileExtensions, parameterMap, metrics).parse() + println() + + if (results.isEmpty()) { + println() + logger.error("No files with specified file extension(s) were found within the given folder - not generating an output file!") + return null + } + + logWarningsForNotFoundFileExtensions(results) val pipedProject = ProjectDeserializer.deserializeProject(input) val project = ProjectGenerator().generate(results, pipedProject) @@ -114,6 +127,25 @@ class RawTextParser( ).filterValues { it != null }.mapValues { it.value as Int } } + private fun logWarningsForNotFoundFileExtensions(results: Map) { + val notFoundFileExtensions = mutableListOf() + for (fileExtension in fileExtensions) { + var isFileExtensionIncluded = false + for (relativeFileName in results.keys) { + if (relativeFileName.contains(fileExtension)) { + isFileExtensionIncluded = true + } + } + if (!isFileExtensionIncluded) { + notFoundFileExtensions.add(fileExtension) + } + } + if (notFoundFileExtensions.isNotEmpty()) { + println() + notFoundFileExtensions.forEach { logger.warn("The specified file extension '$it' was not found within the given folder!") } + } + } + override fun getDialog(): ParserDialogInterface = ParserDialog override fun isApplicable(resourceToBeParsed: String): Boolean { println("Checking if RawTextParser is applicable...") diff --git a/analysis/parser/RawTextParser/src/test/kotlin/de/maibornwolff/codecharta/rawtextparser/MetricCollectorTest.kt b/analysis/parser/RawTextParser/src/test/kotlin/de/maibornwolff/codecharta/rawtextparser/MetricCollectorTest.kt index 51f9986741..03c5b2c93f 100644 --- a/analysis/parser/RawTextParser/src/test/kotlin/de/maibornwolff/codecharta/rawtextparser/MetricCollectorTest.kt +++ b/analysis/parser/RawTextParser/src/test/kotlin/de/maibornwolff/codecharta/rawtextparser/MetricCollectorTest.kt @@ -8,21 +8,21 @@ import java.io.File class MetricCollectorTest { @Test fun `Should collect information about a single file`() { - val result = MetricCollector(File("src/test/resources/sampleproject/tabs.xyz").absoluteFile).parse() + val result = MetricCollector(File("src/test/resources/sampleproject/tabs.included").absoluteFile).parse() Assertions.assertThat(result.size).isEqualTo(1) - Assertions.assertThat(result).containsKey("/tabs.xyz") - Assertions.assertThat(result["/tabs.xyz"]?.metricMap).isNotEmpty + Assertions.assertThat(result).containsKey("/tabs.included") + Assertions.assertThat(result["/tabs.included"]?.metricMap).isNotEmpty } @Test fun `Should collect information about all files within a project`() { val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile).parse() - Assertions.assertThat(result.size).isEqualTo(4) - Assertions.assertThat(result).containsKey("/tabs.xyz") - Assertions.assertThat(result).containsKey("/spaces/spaces_3.xyz") - Assertions.assertThat(result["/tabs.xyz"]?.metricMap).isNotEmpty + Assertions.assertThat(result.size).isEqualTo(5) + Assertions.assertThat(result).containsKey("/tabs.included") + Assertions.assertThat(result).containsKey("/spaces/spaces_3.included") + Assertions.assertThat(result["/tabs.included"]?.metricMap).isNotEmpty } @Test @@ -33,18 +33,59 @@ class MetricCollectorTest { } @Test - fun `Should exlude regex patterns`() { - val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, exclude = arrayOf(".*\\.xyz", "foobar")).parse() + fun `Should exclude regex patterns`() { + val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, exclude = arrayOf(".*\\.excluded$", "foobar")).parse() - Assertions.assertThat(result.size).isEqualTo(1) - Assertions.assertThat(result).containsKey("/spaces/spaces_xyz.wrong") + Assertions.assertThat(result.size).isEqualTo(4) + Assertions.assertThat(result).containsKey("/spaces/spaces_3.included") + Assertions.assertThat(result).containsKey("/spaces/spaces_5.includedtoo") + Assertions.assertThat(result).doesNotContainKey("/spaces/spaces_x_not_included.excluded") } @Test - fun `Should include only spedified File extensions`() { - val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, fileExtensions = arrayOf("wrong")).parse() + fun `Should include only specified File extension with one given`() { + val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, fileExtensions = arrayOf("includedtoo")).parse() Assertions.assertThat(result.size).isEqualTo(1) - Assertions.assertThat(result).containsKey("/spaces/spaces_xyz.wrong") + Assertions.assertThat(result).containsKey("/spaces/spaces_5.includedtoo") + Assertions.assertThat(result).doesNotContainKey("/spaces/spaces_3.included") + Assertions.assertThat(result).doesNotContainKey("tabs.included") + } + + @Test + fun `Should include only specified File extensions with multiple given`() { + val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, fileExtensions = arrayOf("included", "includedtoo")).parse() + + Assertions.assertThat(result.size).isEqualTo(4) + Assertions.assertThat(result).containsKey("/spaces/spaces_3.included") + Assertions.assertThat(result).containsKey("/spaces/spaces_4.included") + Assertions.assertThat(result).containsKey("/spaces/spaces_5.includedtoo") + Assertions.assertThat(result).doesNotContainKey("/spaces/spaces_x_not_included.excluded") + } + + @Test + fun `Should include all Files when no specific extensions were given (default for interactive mode)`() { + val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, fileExtensions = arrayOf("")).parse() + + Assertions.assertThat(result.size).isEqualTo(5) + Assertions.assertThat(result).containsKey("/spaces/spaces_x_not_included.excluded") + Assertions.assertThat(result).containsKey("/spaces/spaces_3.included") + Assertions.assertThat(result).containsKey("/spaces/spaces_4.included") + Assertions.assertThat(result).containsKey("/spaces/spaces_5.includedtoo") + Assertions.assertThat(result).containsKey("/tabs.included") + } + + @Test + fun `Should produce empty result if no valid file extensions were given`() { + val result = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, fileExtensions = arrayOf("none")).parse() + Assertions.assertThat(result.size).isEqualTo(0) + } + + @Test + fun `Should produce the same result whether the user included a dot in the filetype or not`() { + val resultWithoutDot = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, fileExtensions = arrayOf("included", "includedtoo")).parse() + val resultWithDot = MetricCollector(File("src/test/resources/sampleproject").absoluteFile, fileExtensions = arrayOf(".included", ".includedtoo")).parse() + + Assertions.assertThat(resultWithoutDot == resultWithDot) } } diff --git a/analysis/parser/RawTextParser/src/test/kotlin/de/maibornwolff/codecharta/rawtextparser/RawTextParserTest.kt b/analysis/parser/RawTextParser/src/test/kotlin/de/maibornwolff/codecharta/rawtextparser/RawTextParserTest.kt index 7b3c2baadd..5960065576 100644 --- a/analysis/parser/RawTextParser/src/test/kotlin/de/maibornwolff/codecharta/rawtextparser/RawTextParserTest.kt +++ b/analysis/parser/RawTextParser/src/test/kotlin/de/maibornwolff/codecharta/rawtextparser/RawTextParserTest.kt @@ -1,6 +1,5 @@ package de.maibornwolff.codecharta.rawtextparser -import com.google.gson.JsonParser import de.maibornwolff.codecharta.filter.mergefilter.MergeFilter import de.maibornwolff.codecharta.parser.rawtextparser.RawTextParser import de.maibornwolff.codecharta.parser.rawtextparser.RawTextParser.Companion.mainWithInOut @@ -8,8 +7,13 @@ import de.maibornwolff.codecharta.serialization.ProjectDeserializer import de.maibornwolff.codecharta.serialization.ProjectSerializer import de.maibornwolff.codecharta.util.InputHelper import io.mockk.every +import io.mockk.mockk import io.mockk.mockkObject +import io.mockk.slot import io.mockk.unmockkAll +import io.mockk.verify +import mu.KLogger +import mu.KotlinLogging import org.assertj.core.api.Assertions import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test @@ -17,6 +21,8 @@ import org.junit.jupiter.api.TestInstance import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource +import org.skyscreamer.jsonassert.JSONAssert +import org.skyscreamer.jsonassert.JSONCompareMode import picocli.CommandLine import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream @@ -39,7 +45,7 @@ class RawTextParserTest { fun provideValidInputFiles(): List { return listOf( Arguments.of("src/test/resources/sampleproject"), - Arguments.of("src/test/resources/sampleproject/tabs.xyz")) + Arguments.of("src/test/resources/sampleproject/tabs.included")) } } @@ -47,11 +53,9 @@ class RawTextParserTest { fun `should be able to process single file`() { val expectedResultFile = File("src/test/resources/cc_projects/project_3.cc.json").absoluteFile - val result = executeForOutput("", arrayOf("src/test/resources/sampleproject/tabs.xyz")) + val result = executeForOutput("", arrayOf("src/test/resources/sampleproject/tabs.included")) - val resultJSON = JsonParser.parseString(result) - val expectedJson = JsonParser.parseReader(expectedResultFile.reader()) - Assertions.assertThat(resultJSON).isEqualTo(expectedJson) + JSONAssert.assertEquals(result, expectedResultFile.readText(), JSONCompareMode.NON_EXTENSIBLE) } @Test @@ -63,16 +67,14 @@ class RawTextParserTest { arrayOf("src/test/resources/sampleproject/", "--tab-width=2", "--max-indentation-level=2", "-e=tabs*.") ) - val resultJSON = JsonParser.parseString(result) - val expectedJson = JsonParser.parseReader(expectedResultFile.reader()) - Assertions.assertThat(resultJSON).isEqualTo(expectedJson) + JSONAssert.assertEquals(result, expectedResultFile.readText(), JSONCompareMode.NON_EXTENSIBLE) } @Test fun `should merge with piped project`() { val pipedProject = "src/test/resources/cc_projects/project_4.cc.json" val partialResult = "src/test/resources/cc_projects/project_3.cc.json" - val fileToParse = "src/test/resources/sampleproject/tabs.xyz" + val fileToParse = "src/test/resources/sampleproject/tabs.included" val input = File(pipedProject).bufferedReader().readLines().joinToString(separator = "\n") { it } val partialProject1 = ProjectDeserializer.deserializeProject(File(partialResult).inputStream()) val partialProject2 = ProjectDeserializer.deserializeProject(File(pipedProject).inputStream()) @@ -84,8 +86,7 @@ class RawTextParserTest { val result = executeForOutput(input, arrayOf(fileToParse)) - val resultJSON = JsonParser.parseString(result) - Assertions.assertThat(resultJSON).isEqualTo(JsonParser.parseString(expected.toString())) + JSONAssert.assertEquals(result, expected.toString(), JSONCompareMode.NON_EXTENSIBLE) } fun executeForOutput(input: String, args: Array = emptyArray()) = @@ -116,7 +117,7 @@ class RawTextParserTest { @Test fun `should be identified as applicable for given path being a file`() { - val isUsable = RawTextParser().isApplicable("src/test/resources/sampleproject/tabs.xyz") + val isUsable = RawTextParser().isApplicable("src/test/resources/sampleproject/tabs.included") Assertions.assertThat(isUsable).isTrue() } @@ -153,4 +154,52 @@ class RawTextParserTest { Assertions.assertThat(errContent.toString()).contains("Input invalid file for RawTextParser, stopping execution") } + + @Test + fun `Should not produce an output and notify the user if the only specified extension was not found in the folder`() { + mockkObject(KotlinLogging) + val loggerMock = mockk() + val lambdaSlot = slot<(() -> Unit)>() + val messagesLogged = mutableListOf() + every { KotlinLogging.logger(capture(lambdaSlot)) } returns loggerMock + every { loggerMock.error(capture(messagesLogged)) } returns Unit + + val result = executeForOutput("", arrayOf("src/test/resources/sampleproject/", "--file-extensions=invalid")) + + Assertions.assertThat(result).isEmpty() + + verify { loggerMock.error(any()) } + Assertions.assertThat(messagesLogged).contains("No files with specified file extension(s) were found within the given folder - not generating an output file!") + } + + @Test + fun `Should warn the user if one of the specified extensions was not found in the folder`() { + mockkObject(KotlinLogging) + val loggerMock = mockk() + val lambdaSlot = slot<(() -> Unit)>() + val messagesLogged = mutableListOf() + every { KotlinLogging.logger(capture(lambdaSlot)) } returns loggerMock + every { loggerMock.warn(capture(messagesLogged)) } returns Unit + + val result = executeForOutput("", arrayOf("src/test/resources/sampleproject", "--file-extensions=invalid, included")) + + Assertions.assertThat(result).isNotEmpty() + Assertions.assertThat(messagesLogged).contains("The specified file extension 'invalid' was not found within the given folder!") + Assertions.assertThat(messagesLogged).doesNotContain("The specified file extension 'included' was not found within the given folder!") + } + + @Test + fun `Should not produce an output and notify the user if none of the specified extensions were found in the folder`() { + mockkObject(KotlinLogging) + val loggerMock = mockk() + val lambdaSlot = slot<(() -> Unit)>() + val messagesLogged = mutableListOf() + every { KotlinLogging.logger(capture(lambdaSlot)) } returns loggerMock + every { loggerMock.error(capture(messagesLogged)) } returns Unit + + val result = executeForOutput("", arrayOf("src/test/resources/sampleproject/", "--file-extensions=invalid1, invalid2, also_invalid")) + + Assertions.assertThat(result).isEmpty() + Assertions.assertThat(messagesLogged).contains("No files with specified file extension(s) were found within the given folder - not generating an output file!") + } } diff --git a/analysis/parser/RawTextParser/src/test/resources/cc_projects/project_3.cc.json b/analysis/parser/RawTextParser/src/test/resources/cc_projects/project_3.cc.json index fd44905048..2ab6d4cba9 100644 --- a/analysis/parser/RawTextParser/src/test/resources/cc_projects/project_3.cc.json +++ b/analysis/parser/RawTextParser/src/test/resources/cc_projects/project_3.cc.json @@ -1,5 +1,5 @@ { - "checksum": "f8498bc9be2f883fb003073d51b17b8b", + "checksum": "4d50b12a539de0139c1bd0b85367e14b", "data": { "projectName": "", "nodes": [ @@ -10,7 +10,7 @@ "link": "", "children": [ { - "name": "tabs.xyz", + "name": "tabs.included", "type": "File", "attributes": { "indentation_level_0+": 6, diff --git a/analysis/parser/RawTextParser/src/test/resources/cc_projects/project_4.cc.json b/analysis/parser/RawTextParser/src/test/resources/cc_projects/project_4.cc.json index fc126495b6..cbda7a7ada 100644 --- a/analysis/parser/RawTextParser/src/test/resources/cc_projects/project_4.cc.json +++ b/analysis/parser/RawTextParser/src/test/resources/cc_projects/project_4.cc.json @@ -1,5 +1,5 @@ { - "checksum": "8e426f4db76a5e9b3a72bcfadc338bd9", + "checksum": "eb374d0b890eb05b71595a5184a6d7e0", "data": { "projectName": "", "nodes": [ @@ -16,7 +16,7 @@ "link": "", "children": [ { - "name": "spaces_4.xyz", + "name": "spaces_4.included", "type": "File", "attributes": { "indentation_level_0+": 7, @@ -27,7 +27,7 @@ "children": [] }, { - "name": "spaces_3.xyz", + "name": "spaces_3.included", "type": "File", "attributes": { "indentation_level_0+": 5, @@ -38,7 +38,18 @@ "children": [] }, { - "name": "spaces_xyz.wrong", + "name":"spaces_5.includedtoo", + "type":"File", + "attributes": { + "indentation_level_0+":5.0, + "indentation_level_1+":3.0, + "indentation_level_2+":3.0 + }, + "link":"", + "children":[] + }, + { + "name": "spaces_x_not_included.excluded", "type": "File", "attributes": { "indentation_level_0+": 4, diff --git a/analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_3.xyz b/analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_3.included similarity index 100% rename from analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_3.xyz rename to analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_3.included diff --git a/analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_4.xyz b/analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_4.included similarity index 100% rename from analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_4.xyz rename to analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_4.included diff --git a/analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_5.includedtoo b/analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_5.includedtoo new file mode 100644 index 0000000000..3aa9450cef --- /dev/null +++ b/analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_5.includedtoo @@ -0,0 +1,6 @@ +foo + bar + barx + +foox + barx diff --git a/analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_xyz.wrong b/analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_x_not_included.excluded similarity index 100% rename from analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_xyz.wrong rename to analysis/parser/RawTextParser/src/test/resources/sampleproject/spaces/spaces_x_not_included.excluded diff --git a/analysis/parser/RawTextParser/src/test/resources/sampleproject/tabs.xyz b/analysis/parser/RawTextParser/src/test/resources/sampleproject/tabs.included similarity index 100% rename from analysis/parser/RawTextParser/src/test/resources/sampleproject/tabs.xyz rename to analysis/parser/RawTextParser/src/test/resources/sampleproject/tabs.included diff --git a/gh-pages/_docs/04-03-rawtextparser.md b/gh-pages/_docs/04-03-rawtextparser.md index d69321d248..e61247fa46 100644 --- a/gh-pages/_docs/04-03-rawtextparser.md +++ b/gh-pages/_docs/04-03-rawtextparser.md @@ -11,25 +11,25 @@ This parser analyzes code regardless of the programming language used to generat ## Usage and Parameters -| Parameter | description | -| -------------------------------------- | -------------------------------------------------------------------------------------------------- | -| `FILE or FOLDER` | file/project to parse | -| `--maxIndentationLevel=` | maximum Indentation Level (default 10) | -| `--tabWidth=` | tab width used (estimated if not provided) | -| `--withoutDefaultExcludes` | includes build, target, dist, resources and out folders as well as files/folders starting with '.' | -| `-e, --exclude=` | exclude file/folders according to regex pattern | -| `-h, --help` | displays help | -| `-m, --metrics[=...]` | metrics to be computed (select all if not specified) | -| `-o, --outputFile=` | output File (or empty for stdout) | -| `-nc, --not-compressed` | uncompresses outputfile to json format, if format of File is gzip | -| `-p, --projectName=` | project name | -| `-v, --verbose` | verbose mode | - -``` -Usage: rawtextparser [-chv] [--withoutDefaultExcludes] - [--maxIndentationLevel=] - [--tabWidth=] [-o=] [-c] - [-p=] [-e=]... [-m +| Parameter | description | +| ---------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `FILE or FOLDER` | file/project to parse | +| `--max-indentation-level=` | maximum Indentation Level (default 10) | +| `--tab-width=` | tab width used (estimated if not provided) | +| `--without-default-excludes` | includes build, target, dist, resources and out folders as well as files/folders starting with '.' | +| `-e, --exclude=` | exclude file/folders according to regex pattern | +| `-fe, --file-extensions` | include only files with the specified file extensions (include all if not specified) | +| `-h, --help` | displays help | +| `-m, --metrics[=...]` | metrics to be computed (select all if not specified) | +| `-o, --output-file=` | output File (or empty for stdout) | +| `-nc, --not-compressed` | uncompresses outputfile to json format, if format of File is gzip | +| `-v, --verbose` | verbose mode | + +``` +Usage: rawtextparser [-hv] [-nc] [--without-default-excludes] + [--max-indentation-level=] + [-o=] [--tab-width=] + [-e=]... [-f=]... [-m [=...]]... FILE or FOLDER ``` @@ -44,7 +44,7 @@ ccsh rawtextparser foo/bar/project ``` ``` -ccsh rawtextparser foo.txt --maxIndentationLevel=6 tabWidth=4 --metrics=IndentationLevel +ccsh rawtextparser foo.txt --max-indentation-level=6 tab-width=4 --metrics=IndentationLevel ``` ```