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/fixed folders validation #1213

Merged
merged 84 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
17229fe
Add example json representing folder structure in docs
NearW Aug 19, 2020
f41a00b
Update model with optional fixed and margin attributes
NearW Aug 19, 2020
ca3c79d
Adds first steps to build the map, missing transformation of coordinates
NearW Aug 19, 2020
730caed
Refactor improve performance by counting nodes and blacklisted nodes …
NearW Aug 25, 2020
10eb72a
Refactor improve performance by removing one loop
NearW Aug 26, 2020
888b7b8
Fix typo in y properties
NearW Aug 26, 2020
303022a
Add coordinate transformation, map is finally visible, but not scalab…
NearW Aug 26, 2020
1778aa9
Add edges to example json
NearW Aug 26, 2020
58deb03
Refactor use values in line
NearW Aug 26, 2020
36f6b91
Add size increases based on margin
NearW Aug 26, 2020
2305ca7
Refactor abstract methods and improved readability
NearW Aug 26, 2020
c002608
Fix broken tests after changing the method header
NearW Aug 26, 2020
3e1dc51
Remove margin since it's not required anymore
NearW Aug 26, 2020
233637c
Merge remote-tracking branch 'origin/feature/fixed-folders' into feat…
NearW Aug 26, 2020
2d9f8f9
Add snapshot test for fixed folders
NearW Aug 26, 2020
f367a10
Merge remote-tracking branch 'remotes/origin/main' into feature/fixed…
NearW Aug 27, 2020
2960825
Fix incoming and outgoing edge points are now set correctly
NearW Aug 27, 2020
cccde47
Fix root folder name should be set based on the root-name of the map
NearW Aug 27, 2020
ceba8f4
Add API.md to document the changes for the cc.json-api
NearW Aug 27, 2020
56dfbfd
Update api-versions for tests and files
NearW Aug 27, 2020
a6f2aa7
Merge remote-tracking branch 'remotes/origin/feature/fixed-folders' i…
NearW Aug 27, 2020
840c6ab
Presentation add example cc.json
NearW Aug 31, 2020
d6f6857
Presentation rename example cc.json
NearW Aug 31, 2020
e7c4c49
Add validation for fixed folders, not finalized
NearW Aug 31, 2020
5ddef9a
Merge remote-tracking branch 'remotes/origin/feature/epic-fixed-folde…
NearW Sep 1, 2020
ab58613
Merge remote-tracking branch 'origin/feature/fixed-folders' into feat…
NearW Sep 1, 2020
6f1ae36
Merge remote-tracking branch 'remotes/origin/feature/fixed-folders' i…
NearW Sep 1, 2020
568c5e3
Add finalized validation
NearW Sep 1, 2020
319c6f2
Update collect errors again instead of throwing them instantly
NearW Sep 1, 2020
cabcbca
Update e2e test to use the error messages enum instead of plain strings
NearW Sep 1, 2020
b962c94
Fix missing whitespace in test of dialog message
NearW Sep 2, 2020
074b66b
Merge main
NearW Sep 7, 2020
21a9db5
Merge remote-tracking branch 'remotes/origin/feature/fixed-folders' i…
NearW Sep 7, 2020
a2db4c6
Update rename fixed attributes
NearW Sep 7, 2020
34917ec
Update snapshot since ids are no longer pre-decorated
NearW Sep 7, 2020
513401e
Merge remote-tracking branch 'remotes/origin/feature/fixed-folders' i…
NearW Sep 7, 2020
b601723
Update tests with renamed fixed attributes
NearW Sep 7, 2020
12d9944
Refactor move static functions to helper file
NearW Sep 8, 2020
fbda6dd
Refactor convert class with static functions to exported objects with…
NearW Sep 8, 2020
1e1092f
Refactor convert class with static functions to exported objects with…
NearW Sep 8, 2020
80f33d4
Add no-else-return rule and fix errors
NearW Sep 8, 2020
60275e2
Refactor use null propagation operator
NearW Sep 8, 2020
501d6d8
Merge remote-tracking branch 'remotes/origin/feature/fixed-folders' i…
NearW Sep 8, 2020
3f8803a
Update snapshots and remove unused snapshots
NearW Sep 8, 2020
dffc10b
Merge remote-tracking branch 'remotes/origin/feature/fixed-folders' i…
NearW Sep 8, 2020
6a53b3c
Add eslint rule no-lonely-if and autofix errors
NearW Sep 8, 2020
d97e4ad
Update visualization/app/codeCharta/util/treeMapGenerator.spec.ts
NearW Sep 8, 2020
59cc740
Update visualization/app/codeCharta/util/fileHelper.ts
NearW Sep 8, 2020
cb8c3a2
Merge remote-tracking branch 'remotes/origin/feature/epic-fixed-folde…
NearW Sep 9, 2020
34e58ca
Merge epic branch
NearW Sep 9, 2020
7a5f1c5
Refactor rename isNodeToBeFlat to shouldNodeBeFlat
NearW Sep 9, 2020
f29b493
Refactor use null coalescing to shorten code
NearW Sep 9, 2020
603b6e5
Refactor move shortcut return to the top to improve performance
NearW Sep 9, 2020
14d6e7b
Update snapshot after renaming test
NearW Sep 9, 2020
18d027a
Refactor rearrange function and add return statements to prevent obso…
NearW Sep 9, 2020
a1bc49a
Refactor remove obsolete check in condition if attribute types are em…
NearW Sep 9, 2020
2cc4e80
Merge feature/fixed-folders
NearW Sep 9, 2020
9638931
Add e2e test to ensure lower api versions are working without errors …
NearW Sep 9, 2020
061ec81
Refactor replace custom type KeyValuePair with Record<string, number>
NearW Sep 9, 2020
497043a
Update jsonschema
NearW Sep 9, 2020
2e31884
Refactor replace _.cloneDeep with the rfdc library
NearW Sep 9, 2020
8324274
Update snapshot with new api version
NearW Sep 9, 2020
757a892
Add fixedPosition attribute of folders resulting in errors during val…
NearW Sep 9, 2020
2cc8042
Fix outOfBounds-Check not checking for negative width and height
NearW Sep 9, 2020
35d2e47
Add another test to ensure the new out of bounds function is working
NearW Sep 9, 2020
8629c1f
Add print found api version when a warning is thrown
NearW Sep 9, 2020
2e4bc7f
Update visualization/app/codeCharta/util/fileValidator.ts
NearW Sep 9, 2020
5bbbd7e
Update remove individual titles and use a generic title for errors an…
NearW Sep 9, 2020
aae78dd
Merge remote-tracking branch 'origin/feature/fixed-folders-validation…
NearW Sep 9, 2020
84122db
Refactor check if both nodes have the fixedPosition attribute before …
NearW Sep 9, 2020
9cfc0ea
Refactor remove obsolete .values() call
NearW Sep 9, 2020
5f49cb2
Add found duplicate node to error message
NearW Sep 9, 2020
e12040f
Update snapshot with new file names
NearW Sep 9, 2020
0887132
Fix broken e2e test with wrong warning message
NearW Sep 9, 2020
f1c3f20
Refactor use root instead of whole file as parameter to validate fixe…
NearW Sep 9, 2020
2ce7a46
Refactor reorder functions
NearW Sep 9, 2020
e00337c
Revert "Refactor replace custom type KeyValuePair with Record<string,…
NearW Sep 9, 2020
5b8c399
Update json schema with KeyValuePair instead of Record again
NearW Sep 9, 2020
ecc8ea8
Merge remote-tracking branch 'remotes/origin/feature/epic-fixed-folde…
NearW Sep 10, 2020
b804b0c
Merge remote-tracking branch 'remotes/origin/feature/fixed-folders' i…
NearW Sep 10, 2020
5f8daa4
Merge remote-tracking branch 'remotes/origin/feature/epic-fixed-folde…
NearW Sep 10, 2020
17288d9
Move API.md from visualization to root of project
NearW Sep 10, 2020
a366647
Add throw an error if we encountered a fixed folder and the api versi…
NearW Sep 10, 2020
dab3ff7
Merge remote-tracking branch 'remotes/origin/feature/epic-fixed-folde…
NearW Sep 11, 2020
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
25 changes: 23 additions & 2 deletions analysis/tools/ValidationTool/src/main/resources/cc.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
},
"type": "object"
},
"fixedPosition": {
"$ref": "#/definitions/FixedPosition"
},
"id": {
"type": "number"
},
Expand Down Expand Up @@ -165,6 +168,24 @@
"required": ["apiVersion", "nodes", "projectName"],
"type": "object"
},
"FixedPosition": {
"properties": {
"height": {
"type": "number"
},
"left": {
"type": "number"
},
"top": {
"type": "number"
},
"width": {
"type": "number"
}
},
"required": ["height", "left", "top", "width"],
"type": "object"
},
"KeyValuePair": {
"additionalProperties": {
"type": "number"
Expand Down Expand Up @@ -210,7 +231,7 @@
"type": "object"
}
],
"minItems": 1,
"minItems": 0,
"type": "array"
},
"nodes": {
Expand All @@ -234,7 +255,7 @@
"type": "object"
}
],
"minItems": 1,
"minItems": 0,
"type": "array"
}
},
Expand Down
1 change: 1 addition & 0 deletions visualization/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
"@typescript-eslint/no-unused-vars": ["error"],
"object-shorthand": ["error", "always"],
"no-else-return": ["error"],
"no-lonely-if": ["error"],

// Do not apply inappropriate rules below
"@typescript-eslint/no-use-before-define":
Expand Down
32 changes: 32 additions & 0 deletions visualization/API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# API-Changelog
NearW marked this conversation as resolved.
Show resolved Hide resolved

## 1.1

- An additional optional property `edges` has been added to the `cc.json`
- Defines an array of edges between buildings
- Use SCMLogParser to generate edges

```ts
export interface Edge {
fromNodeName: string
toNodeName: string
attributes: KeyValuePair
NearW marked this conversation as resolved.
Show resolved Hide resolved
}
```

## 1.2

- An additional optional property `fixed` has been added to the `cc.json`
- Property can be set to direct children of the root-folder
- Define `x` and `y` as the top-left corner of the folder
- Define `width` and `height` for the length in x and y-direction
- Folders can't overlap and must be defined in range of `[0-100]`

```ts
export interface Fixed {
x: number
y: number
width: number
height: number
}
```
2 changes: 1 addition & 1 deletion visualization/app/codeCharta/assets/sample1.cc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projectName": "Sample Project with Edges",
"apiVersion": "1.1",
"apiVersion": "1.2",
"nodes": [
{
"name": "root",
Expand Down
2 changes: 1 addition & 1 deletion visualization/app/codeCharta/assets/sample2.cc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projectName": "Sample Project",
"apiVersion": "1.1",
"apiVersion": "1.2",
"nodes": [
{
"name": "root",
Expand Down
2 changes: 1 addition & 1 deletion visualization/app/codeCharta/assets/sample3.cc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projectName": "Sample Project",
"apiVersion": "1.1",
"apiVersion": "1.2",
NearW marked this conversation as resolved.
Show resolved Hide resolved
"nodes": [
{
"name": "root",
Expand Down
3 changes: 2 additions & 1 deletion visualization/app/codeCharta/codeCharta.api.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export enum ExportBlacklistType {
export enum APIVersions {
ZERO_POINT_ONE = "0.1",
ONE_POINT_ZERO = "1.0",
ONE_POINT_ONE = "1.1"
ONE_POINT_ONE = "1.1",
ONE_POINT_TWO = "1.2"
}

export interface ExportScenario {
Expand Down
11 changes: 4 additions & 7 deletions visualization/app/codeCharta/codeCharta.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getCCFiles, isSingleState } from "./model/files/files.helper"
import { DialogService } from "./ui/dialog/dialog.service"
import { CCValidationResult, ERROR_MESSAGES } from "./util/fileValidator"
import { setNodeMetricData } from "./state/store/metricData/nodeMetricData/nodeMetricData.actions"
import packageJson from "../../package.json"
import { clone } from "./util/clone"

describe("codeChartaService", () => {
Expand Down Expand Up @@ -52,7 +53,7 @@ describe("codeChartaService", () => {

describe("loadFiles", () => {
const expected: CCFile = {
fileMeta: { apiVersion: "1.1", fileName, projectName: "Sample Map" },
fileMeta: { apiVersion: packageJson.codecharta.apiVersion, fileName, projectName: "Sample Map" },
map: {
attributes: {},
isExcluded: false,
Expand Down Expand Up @@ -169,8 +170,7 @@ describe("codeChartaService", () => {

it("should show error on invalid file", () => {
const expectedError: CCValidationResult = {
title: ERROR_MESSAGES.fileIsInvalid.title,
error: [ERROR_MESSAGES.fileIsInvalid.message],
error: [ERROR_MESSAGES.fileIsInvalid],
warning: []
}

Expand All @@ -182,8 +182,7 @@ describe("codeChartaService", () => {

it("should show error on a random string", () => {
const expectedError: CCValidationResult = {
title: ERROR_MESSAGES.apiVersionIsInvalid.title,
error: [ERROR_MESSAGES.apiVersionIsInvalid.message],
error: [ERROR_MESSAGES.apiVersionIsInvalid],
warning: []
}

Expand All @@ -195,7 +194,6 @@ describe("codeChartaService", () => {

it("should show error if a file is missing a required property", () => {
const expectedError: CCValidationResult = {
title: ERROR_MESSAGES.validationError.title,
error: ["Required error: should have required property 'projectName'"],
warning: []
}
Expand Down Expand Up @@ -224,7 +222,6 @@ describe("codeChartaService", () => {

it("should break the loop after the first invalid file was validated", () => {
const expectedError: CCValidationResult = {
title: ERROR_MESSAGES.validationError.title,
error: ["Required error: should have required property 'projectName'"],
warning: []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ export const fileWithFixedFolders: ExportCCFile = {
attributes: {},
children: [
{
name: "children_5",
name: "children_6",
type: NodeType.FILE,
attributes: {
custom_metric: 4
},
children: []
},
{
name: "children_6",
name: "children_7",
type: NodeType.FILE,
attributes: {
custom_metric: 0
Expand All @@ -111,15 +111,15 @@ export const fileWithFixedFolders: ExportCCFile = {
attributes: {},
children: [
{
name: "children_7",
name: "children_8",
type: NodeType.FILE,
attributes: {
custom_metric: 20
},
children: []
},
{
name: "children_8",
name: "children_9",
type: NodeType.FILE,
attributes: {
custom_metric: 5
Expand All @@ -140,15 +140,15 @@ export const fileWithFixedFolders: ExportCCFile = {
attributes: {},
children: [
{
name: "children_9",
name: "children_10",
type: NodeType.FILE,
attributes: {
custom_metric: 10
},
children: []
},
{
name: "children_10",
name: "children_11",
type: NodeType.FILE,
attributes: {
custom_metric: 0
Expand All @@ -169,15 +169,15 @@ export const fileWithFixedFolders: ExportCCFile = {
attributes: {},
children: [
{
name: "children_11",
name: "children_12",
type: NodeType.FILE,
attributes: {
custom_metric: 1
},
children: []
},
{
name: "children_12",
name: "children_13",
type: NodeType.FILE,
attributes: {
custom_metric: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projectName": "Sample Project with different edges",
"apiVersion": "1.1",
"apiVersion": "1.2",
"nodes": [
{
"name": "root",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"projectName": "Sample Project with Edges",
"apiVersion": "1.1",
"nodes": [
{
"name": "root",
"type": "Folder",
"attributes": {},
"children": [
{
"name": "sample1OnlyLeaf.scss",
"type": "File",
"attributes": {
"rloc": 400,
"functions": 10,
"mcc": 100,
"pairingRate": 32,
"avgCommits": 17
},
"link": "http://www.google.de"
},
{
"name": "bigLeaf.ts",
"type": "File",
"attributes": {
"rloc": 100,
"functions": 10,
"mcc": 1,
"pairingRate": 77,
"avgCommits": 56
},
"link": "http://www.google.de"
},
{
"name": "ParentLeaf",
"type": "Folder",
"attributes": {},
"children": [
{
"name": "smallLeaf.html",
"type": "File",
"attributes": {
"rloc": 30,
"functions": 100,
"mcc": 100,
"pairingRate": 60,
"avgCommits": 51
}
},
{
"name": "otherSmallLeaf.ts",
"type": "File",
"attributes": {
"rloc": 70,
"functions": 1000,
"mcc": 10,
"pairingRate": 65,
"avgCommits": 22
}
}
]
}
]
}
],
"edges": [
{
"fromNodeName": "/root/bigLeaf.ts",
"toNodeName": "/root/ParentLeaf/smallLeaf.html",
"attributes": {
"pairingRate": 89,
"avgCommits": 34
}
},
{
"fromNodeName": "/root/sample1OnlyLeaf.scss",
"toNodeName": "/root/ParentLeaf/smallLeaf.html",
"attributes": {
"pairingRate": 32,
"avgCommits": 17
}
},
{
"fromNodeName": "/root/ParentLeaf/otherSmallLeaf.ts",
"toNodeName": "/root/bigLeaf.ts",
"attributes": {
"pairingRate": 65,
"avgCommits": 22
}
}
],
"attributeTypes": {
"nodes": { "rloc": "absolute", "functions": "absolute", "mcc": "absolute", "pairingRate": "relative" },
"edges": { "pairingRate": "relative", "avgCommits": "absolute" }
}
}
4 changes: 2 additions & 2 deletions visualization/app/codeCharta/ui/dialog/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ export class DialogService {

const htmlMessage = this.buildHtmlMessage(warningSymbol, validationResult.warning)

this.showErrorDialog(htmlMessage, validationResult.title)
this.showErrorDialog(htmlMessage, "Validation Warning")
}

public showValidationErrorDialog(validationResult: CCValidationResult) {
const errorSymbol = '<i class="fa fa-exclamation-circle"></i> '

const htmlMessage = this.buildHtmlMessage(errorSymbol, validationResult.error)

this.showErrorDialogAndOpenFileChooser(htmlMessage, validationResult.title)
this.showErrorDialogAndOpenFileChooser(htmlMessage, "Validation Error")
}

private buildHtmlMessage(symbol: string, validationResult: string[]): string {
Expand Down
Loading