Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1066/attribute descriptors for svn tokeii raw #3176

Merged
merged 17 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

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

- Add an option to hide floor lables under the Area Metric Options. This recalculates the map. [#3175](https://github.com/MaibornWolff/codecharta/pull/3175)
### Added 🚀

- Add an option to hide floor labels under the Area Metric Options. This recalculates the map. [#3175](https://github.com/MaibornWolff/codecharta/pull/3175)

### Chore 👨‍💻 👩‍💻

- Add attribute descriptors (metric descriptions) to TokeiImporter and SVNlogParser [#3176](https://github.com/MaibornWolff/codecharta/pull/3176)

## [1.113.0] - 2022-12-15

Expand Down
1 change: 0 additions & 1 deletion analysis/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ buildscript {
assertj_version = '3.23.1'
hamcrest_version = '1.4-atlassian-1'
hamkrest_version = '1.8.0.1'
junit4_version = '4.13.2'
junit5_version = '5.9.1'
junit_platform_version = '1.9.1'
jsonassert_version = '1.5.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NodeRemover(private val project: Project) {
copyAttributeTypes(),
copyAttributeDescriptors(),
removeBlacklistItems(paths)
).build(true)
).build(cleanAttributeDescriptors = true)
}

private fun filterNodes(path: List<String>, node: MutableNode): MutableNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SubProjectExtractor(private val project: Project) {
copyAttributeTypes(),
copyAttributeDescriptors(),
copyBlacklist()
).build(true)
).build(cleanAttributeDescriptors = true)
}

private fun extractNodes(extractionPattern: List<String>, node: MutableNode): MutableList<MutableNode> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class ParserDialogTest {
val outputFileName = "sampleOutputFile"
val printLevels = BigDecimal(0)
val setRoot = ""
val moveTo = ""
val moveFrom = ""
val remove = ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SourceMonitorImporter(
val csvProjectBuilder =
CSVProjectBuilder(pathSeparator, csvDelimiter, "File Name", sourceMonitorReplacement, getAttributeDescriptors())
files.map { it.inputStream() }.forEach<InputStream> { csvProjectBuilder.parseCSVStream(it) }
val project = csvProjectBuilder.build(true)
val project = csvProjectBuilder.build(cleanAttributeDescriptors = true)

ProjectSerializer.serializeToFileOrStream(project, outputFile, output, compress)

Expand Down
7 changes: 1 addition & 6 deletions analysis/import/MetricGardenerImporter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@ dependencies {
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: jackson_version
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: jackson_version

implementation group: 'org.slf4j', name: 'slf4j-simple', version: slf4j_version
implementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: jersey_version
implementation group: 'com.sun.activation', name: 'javax.activation', version: '1.2.0'

implementation group: 'com.lordcodes.turtle', name: 'turtle', version: '0.8.0'

testImplementation group: 'junit', name: 'junit', version: junit4_version
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: junit5_version
testImplementation group: 'org.assertj', name: 'assertj-core', version: assertj_version
testImplementation group: 'org.hamcrest', name: 'hamcrest-core', version: hamcrest_version
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: hamcrest_version
testImplementation group: 'io.mockk', name: 'mockk', version: mockk_version
testImplementation group: 'com.github.tomakehurst', name: 'wiremock', version: wiremock_version

testRuntimeOnly group: 'org.junit.vintage', name: 'junit-vintage-engine', version: junit5_version
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import de.maibornwolff.codecharta.importer.metricgardenerimporter.model.MetricGa
import de.maibornwolff.codecharta.importer.metricgardenerimporter.model.MetricGardenerNodes
import de.maibornwolff.codecharta.model.MutableNode
import de.maibornwolff.codecharta.model.NodeType
import org.junit.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

internal class MetricGardenerProjectBuilderTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package de.maibornwolff.codecharta.importer.metricgardenerimporter.model

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import de.maibornwolff.codecharta.model.Path
import org.junit.Assert.assertNotEquals
import org.junit.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotEquals
import org.junit.jupiter.api.Test

internal class MetricGardenerNodeTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.maibornwolff.codecharta.importer.metricgardenerimporter.model

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.junit.Assert.assertNotEquals
import org.junit.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotEquals
import org.junit.jupiter.api.Test

internal class MetricGardenerNodesTest {

Expand Down
4 changes: 1 addition & 3 deletions analysis/import/SVNLogParser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ dependencies {
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlin_logging_version
implementation group: 'com.googlecode.juniversalchardet', name: 'juniversalchardet', version: juniversalchardet_version

implementation group: 'org.slf4j', name: 'slf4j-simple', version: slf4j_version
implementation group: 'com.github.kotlin-inquirer', name: 'kotlin-inquirer', version: kotlin_inquirer_version

testImplementation group: 'junit', name: 'junit', version: junit4_version
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 project(path: ':model', configuration: 'testOutput')

testRuntimeOnly group: 'org.junit.vintage', name: 'junit-vintage-engine', version: junit5_version
}

test {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.maibornwolff.codecharta.importer.svnlogparser

import de.maibornwolff.codecharta.model.AttributeDescriptor

fun getAttributeDescriptors(): Map<String, AttributeDescriptor> {
val descriptors = mutableMapOf<String, AttributeDescriptor>()
val ghLink = "https://github.com/MaibornWolff/codecharta/blob/main/analysis/import/SVNLogParser/README.md"
descriptors["age_in_weeks"] = AttributeDescriptor(title = "Age in Weeks", description = "File age in weeks", link = ghLink)
descriptors["number_of_commits"] = AttributeDescriptor(title = "Number of Commits", description = "Number of commits", link = ghLink)
descriptors["highly_coupled_files"] = AttributeDescriptor(title = "Highly Coupled Files", description = "Number of highly coupled files (>=35% of times modified the same time) with this file", link = ghLink)
descriptors["median_coupled_files"] = AttributeDescriptor(title = "Median Coupled Files", description = "Median of number of other files that where committed with this file", link = ghLink)
descriptors["number_of_renames"] = AttributeDescriptor(title = "Number of Renames", description = "Number of file renames", link = ghLink)
descriptors["weeks_with_commits"] = AttributeDescriptor(title = "Weeks with Commits", description = "Number of weeks in which commits occurred", link = ghLink)
descriptors["number_of_authors"] = AttributeDescriptor(title = "Number of Authors", description = "Number of authors", link = ghLink)
descriptors["temporal_coupling"] = AttributeDescriptor(title = "Temporal Coupling", description = "The degree of temporal coupling between two files (>=35%)", link = ghLink)
descriptors["successive_weeks_with_commits"] = AttributeDescriptor(title = "Successive Weeks with Commits", description = "Number of successive weeks in which the file was included in a commit", link = ghLink)
descriptors["range_of_weeks_with_commits"] = AttributeDescriptor(title = "Week Range of Commits", description = "Average number of weeks between commits", link = ghLink)

return descriptors.toMap()
phanlezz marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.maibornwolff.codecharta.importer.svnlogparser.converter

import de.maibornwolff.codecharta.importer.svnlogparser.getAttributeDescriptors
import de.maibornwolff.codecharta.importer.svnlogparser.input.VersionControlledFile
import de.maibornwolff.codecharta.importer.svnlogparser.input.metrics.MetricsFactory
import de.maibornwolff.codecharta.model.Edge
Expand Down Expand Up @@ -54,8 +55,9 @@ class ProjectConverter(private val containsAuthors: Boolean) {
val metrics = metricsFactory.createMetrics()
projectBuilder.addAttributeTypes(AttributeTypesFactory.createNodeAttributeTypes(metrics))
projectBuilder.addAttributeTypes(AttributeTypesFactory.createEdgeAttributeTypes(metrics))
projectBuilder.addAttributeDescriptions(getAttributeDescriptors())

return projectBuilder.build()
return projectBuilder.build(cleanAttributeDescriptors = true)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,29 @@ package de.maibornwolff.codecharta.importer.svnlogparser

import de.maibornwolff.codecharta.importer.svnlogparser.converter.ProjectConverter
import de.maibornwolff.codecharta.importer.svnlogparser.input.metrics.MetricsFactory
import de.maibornwolff.codecharta.importer.svnlogparser.parser.LogParserStrategy
import de.maibornwolff.codecharta.importer.svnlogparser.parser.svn.SVNLogParserStrategy
import de.maibornwolff.codecharta.model.Project
import de.maibornwolff.codecharta.serialization.ProjectDeserializer
import de.maibornwolff.codecharta.serialization.ProjectSerializer
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.jupiter.api.Test
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.io.InputStreamReader
import java.io.OutputStreamWriter
import java.nio.file.Files
import java.nio.file.Paths
import java.util.Arrays

@RunWith(Parameterized::class)
class SVNLogProjectCreatorGoldenTest(
val svn: String,
private val strategy: LogParserStrategy,
private val containsAuthors: Boolean,
private val logFilename: String,
private val expectedProjectFilename: String
) {

companion object {
@JvmStatic
@Parameterized.Parameters(name = "{index}: {0}")
fun data(): Collection<Array<Any>> {
return Arrays.asList(
arrayOf("svn", SVNLogParserStrategy(), true, "example_svn.log", "expected_svn.json"),
)
}
}
class SVNLogProjectCreatorGoldenTest {
private val svn = "svn"
private val strategy = SVNLogParserStrategy()
private val containsAuthors = true
private val logFilename = "example_svn.log"
private val expectedProjectFilename = "expected_svn.json"

private val metricsFactory = MetricsFactory(
Arrays.asList(
listOf(
"number_of_authors",
"number_of_commits",
"weeks_with_commits",
Expand All @@ -51,7 +35,7 @@ class SVNLogProjectCreatorGoldenTest(

@Test
@Throws(Exception::class)
fun logParserGoldenTest() {
fun `log parser golden test`() {
// given
val projectConverter = ProjectConverter(containsAuthors)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package de.maibornwolff.codecharta.importer.svnlogparser.converter
import de.maibornwolff.codecharta.importer.svnlogparser.input.metrics.MetricsFactory
import de.maibornwolff.codecharta.model.AttributeType
import org.assertj.core.api.Assertions
import org.junit.Test
import org.junit.jupiter.api.Test

class AttributeTypesFactoryTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import de.maibornwolff.codecharta.importer.svnlogparser.input.metrics.MetricsFac
import io.mockk.every
import io.mockk.mockk
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.time.OffsetDateTime
import java.util.Arrays

class ProjectConverterTest {

private val metricsFactory = mockk<MetricsFactory>()

@Before
@BeforeEach
fun setup() {
every { metricsFactory.createMetrics() } returns listOf()
}
Expand All @@ -27,7 +26,7 @@ class ProjectConverterTest {

@Test
@Throws(Exception::class)
fun canCreateAnEmptyProject() {
fun `can create an empty project`() {
// given
val projectConverter = ProjectConverter(true)

Expand All @@ -39,35 +38,35 @@ class ProjectConverterTest {
}

@Test
fun canConvertProjectWithAuthors() {
fun `can convert project with authors`() {
// given
val projectConverter = ProjectConverter(true)
val file1 = VersionControlledFile("File 1", metricsFactory)
file1.registerCommit(Commit("Author", modificationsByFilename("File 1", "File 2"), OffsetDateTime.now()))

// when
val project = projectConverter.convert(Arrays.asList(file1), metricsFactory)
val project = projectConverter.convert(listOf(file1), metricsFactory)

// then
assertThat(project.rootNode.children.toMutableList()[0].attributes.containsKey("authors")).isTrue()
}

@Test
fun canConvertProjectWithoutAuthors() {
fun `can convert project without authors`() {
// given
val projectConverter = ProjectConverter(false)
val file1 = VersionControlledFile("File 1", metricsFactory)
file1.registerCommit(Commit("Author", modificationsByFilename("File 1", "File 2"), OffsetDateTime.now()))

// when
val project = projectConverter.convert(Arrays.asList(file1), metricsFactory)
val project = projectConverter.convert(listOf(file1), metricsFactory)

// then
assertThat(project.rootNode.children.toMutableList()[0].attributes.containsKey("authors")).isFalse()
}

@Test
fun edgesAreRegisteredInProject() {
fun `edges are registered in project`() {
// given
val projectConverter = ProjectConverter(true)
val metricsFactory = MetricsFactory().createMetrics()
Expand Down
Loading