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/2708/show changed files in delta mode #2890

Merged
merged 32 commits into from Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
538ba0f
Improve delta generator spec #2708
knoffi Jul 15, 2022
c7feb84
Improve nodePath spec #2708
knoffi Jul 15, 2022
0b37caa
Fix grammar in file count display #2708
knoffi Jul 15, 2022
1a154cc
Add mocked display of changed files #2708
knoffi Jul 15, 2022
9fd665c
Fix information display about changed files #2708
knoffi Jul 15, 2022
97861ab
Add file comparing in delta generator #2708
knoffi Jul 18, 2022
5acb25e
Add metricsChanged by delta generator #2708
knoffi Jul 19, 2022
f871d85
Merge branch 'main' into feature/2708/show-changed-files-in-delta-mode
MW-Friedrich Jul 21, 2022
abdc1d5
Add display of changed files in html from store #2708
knoffi Jul 21, 2022
40b33cb
Fix fileCount selector spec #2708
knoffi Jul 21, 2022
ce64b72
Add collecting of metric changes from children #2708
knoffi Jul 21, 2022
9825e07
Merge branch 'feature/2708/show-changed-files-in-delta-mode' of https…
knoffi Jul 21, 2022
642af10
Refactor FileCount property #2708
knoffi Jul 21, 2022
47d512c
Fix snapshots for delta generator spec #2708
knoffi Jul 22, 2022
9d19757
Fix logic of delta generator #2708
knoffi Jul 22, 2022
27221f5
Document changelog #2708
knoffi Jul 25, 2022
71bc9c6
Refactor deltaGenerator internally #2708
knoffi Jul 25, 2022
5a13982
Fix file-changed-logic in deltaGenerator #2708
knoffi Jul 26, 2022
675e7dd
Merge branch 'main' into feature/2708/show-changed-files-in-delta-mode
knoffi Jul 26, 2022
f371c7d
Merge branch 'main' into feature/2708/show-changed-files-in-delta-mode
MW-Friedrich Jul 26, 2022
aa4eeec
Merge branch 'main' into feature/2708/show-changed-files-in-delta-mode
jannikr Jul 26, 2022
c3d7d95
Change google link to https #2708
knoffi Jul 26, 2022
4840d25
Adjust test mocks and snapshots #2708
knoffi Jul 26, 2022
66464d8
Merge branch 'main' into feature/2708/show-changed-files-in-delta-mode
MW-Friedrich Jul 26, 2022
58aff39
Refactor test mock objects #2708
knoffi Jul 27, 2022
21e0ba0
Refactor mock objects for unit tests #2708
knoffi Jul 27, 2022
ee2dd60
Refactor test mock objects #2707
knoffi Jul 27, 2022
d9f0293
Refactor mock files in deltaGenerator spec #2708
knoffi Jul 27, 2022
f2492c5
Merge branch 'main' into feature/2708/show-changed-files-in-delta-mode
knoffi Jul 27, 2022
d446965
Try out comment to disable sonar in line #2708
knoffi Jul 27, 2022
72d612d
fix SonarQube not excluding dataMocks.ts
MW-Friedrich Jul 27, 2022
bf191c6
Merge branch 'main' into feature/2708/show-changed-files-in-delta-mode
MW-Friedrich Jul 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/)
### Added 🚀

- Add a description for the statements metric [#2883](https://github.com/MaibornWolff/codecharta/pull/2883)
- Add display of changed files in delta mode (changed := metric values changed or list of applied metrics changed) [#2890](https://github.com/MaibornWolff/codecharta/pull/2890)

### Changed

Expand Down
1 change: 1 addition & 0 deletions visualization/app/codeCharta/codeCharta.model.ts
Expand Up @@ -37,6 +37,7 @@ export interface FileCount {
all?: number
added: number
removed: number
changed: number
}

interface squarifiedNode {
Expand Down
2 changes: 1 addition & 1 deletion visualization/app/codeCharta/codeCharta.service.spec.ts
Expand Up @@ -82,7 +82,7 @@ describe("codeChartaService", () => {
children: [
{
attributes: { functions: 10, mcc: 1, rloc: 100 },
link: "http://www.google.de",
link: "https://www.google.de",
name: "big leaf",
path: "/root/big leaf",
type: NodeType.FILE,
Expand Down
Expand Up @@ -55,6 +55,10 @@ cc-attribute-side-bar-header-section {
.removed-files {
color: rgb(255, 14, 14);
}

.changed-files {
color: rgb(14, 46, 255);
}
}
}

Expand Down
Expand Up @@ -8,11 +8,11 @@ describe("getFileCount", () => {

it("should return file count object with default values when it receives a building with no attributes and changed files", () => {
const node = {}
expect(getFileCount(node)).toEqual({ all: 0, added: 0, removed: 0 })
expect(getFileCount(node)).toEqual({ all: 0, added: 0, removed: 0, changed: 0 })
})

it("should return file count object that has the same values as the value assignments of the received attributes and changed files", () => {
const node = { attributes: { unary: 4 }, fileCount: { added: 2, removed: 1 } }
expect(getFileCount(node)).toEqual({ all: 4, added: 2, removed: 1 })
const node = { attributes: { unary: 4 }, fileCount: { added: 2, removed: 1, changed: 3 } }
expect(getFileCount(node)).toEqual({ all: 4, added: 2, removed: 1, changed: 3 })
})
})
Expand Up @@ -10,7 +10,8 @@ export const getFileCount = (node?: Pick<CodeMapNode, "attributes" | "fileCount"
return {
all: node.attributes?.unary ?? 0,
added: node.fileCount?.added ?? 0,
removed: node.fileCount?.removed ?? 0
removed: node.fileCount?.removed ?? 0,
changed: node.fileCount?.changed ?? 0
}
}

Expand Down
Expand Up @@ -3,12 +3,11 @@
{{ node.path }}
<span *ngIf="node.children?.length && fileCount$ | async as fileCount" class="cc-node-file-count">
(
{{ fileCount.all > 1 ? fileCount.all + " files" : fileCount.all + " file" }}
{{ fileCount.all }} {{ fileCount.all === 1 ? "file" : "files" }}
<span *ngIf="node.children?.length && (isDeltaMode$ | async)" class="cc-node-file-count">
| <span class="added-files" title="Number of added files"> Δ{{ fileCount.added }}</span> |
<span class="removed-files" title="Number of removed files">
Δ{{ fileCount.removed > 0 ? -fileCount.removed : 0 }}</span
></span
<span class="removed-files" title="Number of removed files"> Δ{{ fileCount.removed > 0 ? -fileCount.removed : 0 }}</span> |
<span class="files-with-metric-changes" title="Number of files with metric changes"> Δ{{ fileCount.changed }}</span> </span
>)
</span>
</span>
Expand Down
Expand Up @@ -54,14 +54,50 @@ describe("nodePathComponent", () => {
attributes: { unary: 2 },
fileCount: {
added: 1,
removed: 2
removed: 2,
changed: 3
}
}
isDeltaStateSelectorMock.mockImplementationOnce(() => true)
selectedNodeSelectorMock.mockImplementation(() => node)

const { container } = await render(NodePathComponent, { componentProperties: { node } })

expect(container.textContent.replace(/\s+/g, " ")).toContain("some/folder ( 2 files | Δ1 | Δ-2 | Δ3)")
})
it("should display amount of files with correct english grammar, when an empty folder is selected and delta mode is enabled", async () => {
const node = {
children: [{}] as CodeMapNode[],
path: "some/emptyFolder",
attributes: { unary: 0 },
fileCount: {
added: 0,
removed: 2,
changed: 0
}
}
isDeltaStateSelectorMock.mockImplementationOnce(() => true)
selectedNodeSelectorMock.mockImplementation(() => node)

const { container } = await render(NodePathComponent, { componentProperties: { node } })

expect(container.textContent).toContain(" 0 files ") // because "zero file" is not grammatically correct
})
it("should display amount of files with correct english grammar, when a folder with 1 file is selected and delta mode is enabled", async () => {
const node = {
children: [{}] as CodeMapNode[],
path: "some/folderWithOneFile",
attributes: { unary: 1 },
fileCount: {
added: 1,
removed: 0
}
}
isDeltaStateSelectorMock.mockImplementationOnce(() => true)
selectedNodeSelectorMock.mockImplementation(() => node)

const { container } = await render(NodePathComponent, { componentProperties: { node } })

expect(container.textContent.replace(/\s+/g, " ")).toContain("some/folder ( 2 files | Δ1 | Δ-2)")
expect(container.textContent).toContain(" 1 file ") // because "one files" is not grammatically correct
})
})
Expand Up @@ -30,7 +30,7 @@ Object {
"id": 1,
"isExcluded": false,
"isFlattened": false,
"link": "http://www.google.de",
"link": "https://www.google.de",
"name": "big leaf",
"path": "/root/big leaf",
"type": "File",
Expand Down
Expand Up @@ -61,7 +61,7 @@ Array [
},
"isLeaf": true,
"length": 911.751015307185,
"link": "http://www.google.de",
"link": "https://www.google.de",
"mapNodeDepth": 1,
"markingColor": undefined,
"name": "big leaf",
Expand Down
Expand Up @@ -9,7 +9,7 @@ jest.mock("../../../../state/selectors/accumulatedData/accumulatedData.selector"
type: "Folder",
path: "/root",
children: [
{ name: "big leaf", type: "File", path: "/root/big leaf", link: "http://www.google.de" },
{ name: "big leaf", type: "File", path: "/root/big leaf", link: "https://www.google.de" },
{
name: "Parent Leaf",
type: "Folder",
Expand Down
Expand Up @@ -30,7 +30,7 @@ Object {
"mcc": 1,
"rloc": 100,
},
"link": "http://www.google.de",
"link": "https://www.google.de",
"name": "big leaf",
"path": "/root/file1/file1/big leaf",
"type": "File",
Expand Down Expand Up @@ -76,7 +76,7 @@ Object {
"mcc": 2,
"rloc": 200,
},
"link": "http://www.google.de",
"link": "https://www.google.de",
"name": "big leaf",
"path": "/root/file2/file2/big leaf",
"type": "File",
Expand Down Expand Up @@ -121,7 +121,7 @@ Object {
"mcc": 1,
"rloc": 100,
},
"link": "http://www.google.de",
"link": "https://www.google.de",
"name": "big leaf",
"path": "/root/file1/file1/big leaf",
"type": "File",
Expand Down Expand Up @@ -167,7 +167,7 @@ Object {
"mcc": 2,
"rloc": 200,
},
"link": "http://www.google.de",
"link": "https://www.google.de",
"name": "big leaf",
"path": "/root/file2/file2/big leaf",
"type": "File",
Expand Down Expand Up @@ -248,7 +248,7 @@ Object {
"mcc": 1,
"rloc": 100,
},
"link": "http://www.google.de",
"link": "https://www.google.de",
"name": "big leaf",
"path": "/root/file1/big leaf",
"type": "File",
Expand Down Expand Up @@ -294,7 +294,7 @@ Object {
"mcc": 2,
"rloc": 200,
},
"link": "http://www.google.de",
"link": "https://www.google.de",
"name": "big leaf",
"path": "/root/file2/big leaf",
"type": "File",
Expand Down Expand Up @@ -367,7 +367,7 @@ Object {
"mcc": 1,
"rloc": 100,
},
"link": "http://www.google.de",
"link": "https://www.google.de",
"name": "big leaf",
"path": "/root/big leaf",
"type": "File",
Expand Down