Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into refactor/3250/ngrx
Browse files Browse the repository at this point in the history
  • Loading branch information
shaman-apprentice committed Apr 27, 2023
2 parents d5423b9 + c067e0c commit 0cb2a02
Show file tree
Hide file tree
Showing 33 changed files with 1,171 additions and 91 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

## [unreleased] (Added 🚀 | Changed | Removed 🗑 | Fixed 🐞 | Chore 👨‍💻 👩‍💻)

### Added 🚀

- Add automatic parser suggestions to recommend usable parsers for a codebase (supports GitLogParser and SonarImporter) when running `ccsh` command [#3275](https://github.com/MaibornWolff/codecharta/pull/3275) </br>
![image](https://user-images.githubusercontent.com/129938897/234309117-c9edd4e7-7c53-4ba7-b849-ec9c3f8f3215.png)

### Changed

- Changed default behavior when launching ccsh without arguments to parser suggestions [#3275](https://github.com/MaibornWolff/codecharta/pull/3275)
- Old interactive parser selection now reachable by passing -i or --interactive as arguments [#3275](https://github.com/MaibornWolff/codecharta/pull/3275)

### Fixed 🐞

- Fix suspicious metrics and risk profile docs not loading [#3272](https://github.com/MaibornWolff/codecharta/pull/3272)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.maibornwolff.codecharta.model.Project
import de.maibornwolff.codecharta.serialization.ProjectDeserializer
import de.maibornwolff.codecharta.tools.interactiveparser.InteractiveParser
import de.maibornwolff.codecharta.tools.interactiveparser.ParserDialogInterface
import de.maibornwolff.codecharta.tools.interactiveparser.util.InteractiveParserHelper
import picocli.CommandLine
import java.io.BufferedWriter
import java.io.File
Expand All @@ -18,9 +19,9 @@ import java.io.Writer
import java.util.concurrent.Callable

@CommandLine.Command(
name = "csvexport",
description = ["generates csv file with header"],
footer = ["Copyright(c) 2022, MaibornWolff GmbH"]
name = InteractiveParserHelper.CSVExporterConstants.name,
description = [InteractiveParserHelper.CSVExporterConstants.description],
footer = [InteractiveParserHelper.GeneralConstants.GenericFooter]
)
class CSVExporter : Callable<Void>, InteractiveParser {

Expand Down Expand Up @@ -98,6 +99,13 @@ class CSVExporter : Callable<Void>, InteractiveParser {
}

override fun getDialog(): ParserDialogInterface = ParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
return false
}

override fun getName(): String {
return InteractiveParserHelper.CSVExporterConstants.name
}
}

private fun Node.toAttributeList(attributeNames: List<String>): List<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import de.maibornwolff.codecharta.serialization.ProjectDeserializer
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.InteractiveParserHelper
import picocli.CommandLine
import java.io.File
import java.io.PrintStream
import java.util.concurrent.Callable

@CommandLine.Command(
name = "edgefilter",
description = ["aggregates edgeAttributes as nodeAttributes into a new cc.json file"],
footer = ["Copyright(c) 2022, MaibornWolff GmbH"]
name = InteractiveParserHelper.EdgeFilterConstants.name,
description = [InteractiveParserHelper.EdgeFilterConstants.description],
footer = [InteractiveParserHelper.GeneralConstants.GenericFooter]
)
class EdgeFilter(
private val output: PrintStream = System.out
Expand Down Expand Up @@ -48,4 +49,11 @@ class EdgeFilter(
}

override fun getDialog(): ParserDialogInterface = ParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
return false
}

override fun getName(): String {
return InteractiveParserHelper.EdgeFilterConstants.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import de.maibornwolff.codecharta.serialization.ProjectDeserializer
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.InteractiveParserHelper
import mu.KotlinLogging
import picocli.CommandLine
import java.io.File
import java.io.PrintStream
import java.util.concurrent.Callable

@CommandLine.Command(
name = "merge",
description = ["merges multiple cc.json files"],
footer = ["Copyright(c) 2020, MaibornWolff GmbH"]
name = InteractiveParserHelper.MergeFilterConstants.name,
description = [InteractiveParserHelper.MergeFilterConstants.description],
footer = [InteractiveParserHelper.GeneralConstants.GenericFooter]
)
class MergeFilter(
private val output: PrintStream = System.out
Expand Down Expand Up @@ -99,4 +100,11 @@ class MergeFilter(
}

override fun getDialog(): ParserDialogInterface = ParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
return false
}

override fun getName(): String {
return InteractiveParserHelper.MergeFilterConstants.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import de.maibornwolff.codecharta.serialization.ProjectDeserializer
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.InteractiveParserHelper
import mu.KotlinLogging
import picocli.CommandLine
import java.io.File
Expand All @@ -13,9 +14,9 @@ import java.io.PrintStream
import java.util.concurrent.Callable

@CommandLine.Command(
name = "modify",
description = ["changes the structure of cc.json files"],
footer = ["Copyright(c) 2022, MaibornWolff GmbH"]
name = InteractiveParserHelper.StructureModifierConstants.name,
description = [InteractiveParserHelper.StructureModifierConstants.description],
footer = [InteractiveParserHelper.GeneralConstants.GenericFooter]
)
class StructureModifier(
private val input: InputStream = System.`in`,
Expand Down Expand Up @@ -100,4 +101,11 @@ class StructureModifier(
}

override fun getDialog(): ParserDialogInterface = ParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
return false
}

override fun getName(): String {
return InteractiveParserHelper.StructureModifierConstants.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.maibornwolff.codecharta.importer.csv
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.InteractiveParserHelper
import picocli.CommandLine
import java.io.File
import java.io.IOException
Expand All @@ -11,9 +12,9 @@ import java.io.PrintStream
import java.util.concurrent.Callable

@CommandLine.Command(
name = "csvimport",
description = ["generates cc.json from csv with header"],
footer = ["Copyright(c) 2022, MaibornWolff GmbH"]
name = InteractiveParserHelper.CSVImporterConstants.name,
description = [InteractiveParserHelper.CSVImporterConstants.description],
footer = [InteractiveParserHelper.GeneralConstants.GenericFooter]
)
class CSVImporter(
private val output: PrintStream = System.out
Expand Down Expand Up @@ -60,4 +61,10 @@ class CSVImporter(
}

override fun getDialog(): ParserDialogInterface = ParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
return false
}
override fun getName(): String {
return InteractiveParserHelper.CSVImporterConstants.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import de.maibornwolff.codecharta.importer.csv.CSVProjectBuilder
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.InteractiveParserHelper
import de.maibornwolff.codecharta.translator.MetricNameTranslator
import picocli.CommandLine
import java.io.File
Expand All @@ -13,9 +14,9 @@ import java.io.PrintStream
import java.util.concurrent.Callable

@CommandLine.Command(
name = "sourcemonitorimport",
description = ["generates cc.json from sourcemonitor csv"],
footer = ["Copyright(c) 2020, MaibornWolff GmbH"]
name = InteractiveParserHelper.SourceMonitorImporterConstants.name,
description = [InteractiveParserHelper.SourceMonitorImporterConstants.description],
footer = [InteractiveParserHelper.GeneralConstants.GenericFooter]
)
class SourceMonitorImporter(
private val output: PrintStream = System.out
Expand Down Expand Up @@ -84,4 +85,10 @@ class SourceMonitorImporter(
}

override fun getDialog(): ParserDialogInterface = ParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
return false
}
override fun getName(): String {
return InteractiveParserHelper.SourceMonitorImporterConstants.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import de.maibornwolff.codecharta.model.AttributeTypes
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.InteractiveParserHelper
import de.maibornwolff.codecharta.translator.MetricNameTranslator
import picocli.CommandLine
import java.io.File
Expand All @@ -14,9 +15,9 @@ import java.io.PrintStream
import java.util.concurrent.Callable

@CommandLine.Command(
name = "codemaatimport",
description = ["generates cc.json from codemaat coupling csv"],
footer = ["Copyright(c) 2022, MaibornWolff GmbH"]
name = InteractiveParserHelper.CodeMaatImporterConstants.name,
description = [InteractiveParserHelper.CodeMaatImporterConstants.description],
footer = [InteractiveParserHelper.GeneralConstants.GenericFooter]
)
class CodeMaatImporter(
private val output: PrintStream = System.out) : Callable<Void>, InteractiveParser {
Expand Down Expand Up @@ -79,4 +80,11 @@ class CodeMaatImporter(
}

override fun getDialog(): ParserDialogInterface = ParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
return false
}

override fun getName(): String {
return InteractiveParserHelper.CodeMaatImporterConstants.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import de.maibornwolff.codecharta.serialization.ProjectDeserializer
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.InteractiveParserHelper
import org.mozilla.universalchardet.UniversalDetector
import picocli.CommandLine
import java.io.File
Expand All @@ -21,14 +22,15 @@ import java.io.InputStream
import java.io.PrintStream
import java.nio.charset.Charset
import java.nio.file.Files
import java.nio.file.Paths
import java.util.concurrent.Callable
import java.util.stream.Stream

@CommandLine.Command(
name = "gitlogparser",
description = ["git log parser - generates cc.json from git-log files"],
name = InteractiveParserHelper.GitLogParserConstants.name,
description = [InteractiveParserHelper.GitLogParserConstants.description],
subcommands = [LogScanCommand::class, RepoScanCommand::class],
footer = ["Copyright(c) 2022, MaibornWolff GmbH"]
footer = [InteractiveParserHelper.GeneralConstants.GenericFooter]
)
class GitLogParser(
private val input: InputStream = System.`in`,
Expand Down Expand Up @@ -152,4 +154,25 @@ class GitLogParser(
}

override fun getDialog(): ParserDialogInterface = ParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
if (resourceToBeParsed.endsWith(".git")) {
return true
}

val searchFile = if (resourceToBeParsed == "") {
File(Paths.get("").toAbsolutePath().toString())
} else {
File(resourceToBeParsed)
}

return searchFile.walk()
.maxDepth(1)
.asSequence()
.map { it.name }
.filter { it.endsWith(".git") }
.any()
}
override fun getName(): String {
return InteractiveParserHelper.GitLogParserConstants.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ class LogScanCommand : Callable<Void>, InteractiveParser {
}

override fun getDialog(): ParserDialogInterface = LogScanParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
return false
}

override fun getName(): String {
return "log-scan"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@ class RepoScanCommand : Callable<Void>, InteractiveParser {
}

override fun getDialog(): ParserDialogInterface = RepoScanParserDialog
override fun isApplicable(resourceToBeParsed: String): Boolean {
return false
}

override fun getName(): String {
return "repo-scan"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,33 @@ package de.maibornwolff.codecharta.importer.gitlogparser

import de.maibornwolff.codecharta.importer.gitlogparser.GitLogParser.Companion.main
import de.maibornwolff.codecharta.serialization.ProjectDeserializer
import org.assertj.core.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import java.io.File

class GitLogParserTest {
companion object {
@JvmStatic
fun provideValidInputFiles(): List<Arguments> {
return listOf(
Arguments.of("src/test/resources/my/git/repo"),
Arguments.of("src/test/resources/my/git/repo/Test.git"))
}

@JvmStatic
fun provideInvalidInputFiles(): List<Arguments> {
return listOf(
Arguments.of("src/test/resources/my/empty/repo"),
Arguments.of("src/test/resources/this/does/not/exist"),
Arguments.of(""),
Arguments.of("src/test/resources/my"))
}
}

@Test
fun `should create json uncompressed file repo-scan`() {
Expand Down Expand Up @@ -62,4 +83,18 @@ class GitLogParserTest {

assertTrue(file.exists())
}

@ParameterizedTest
@MethodSource("provideValidInputFiles")
fun `should be identified as applicable for given directory path containing a git folder`(resourceToBeParsed: String) {
val isUsable = GitLogParser().isApplicable(resourceToBeParsed)
Assertions.assertThat(isUsable).isTrue()
}

@ParameterizedTest
@MethodSource("provideInvalidInputFiles")
fun `should NOT be identified as applicable if no git folder is present at given path`(resourceToBeParsed: String) {
val isUsable = GitLogParser().isApplicable(resourceToBeParsed)
Assertions.assertThat(isUsable).isFalse()
}
}
Empty file.
Loading

0 comments on commit 0cb2a02

Please sign in to comment.