Skip to content

Tech/migrate state util into features#4504

Open
ChristianHuehn wants to merge 15 commits into
mainfrom
tech/migrate-state-util-into-features
Open

Tech/migrate state util into features#4504
ChristianHuehn wants to merge 15 commits into
mainfrom
tech/migrate-state-util-into-features

Conversation

@ChristianHuehn

@ChristianHuehn ChristianHuehn commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

{Meaningful title}

Please read the CONTRIBUTING.md before opening a PR.

Closes: #

Description

Descriptive pull request text, answering:

  • What problem/issue are you fixing?
  • What does this PR implement and how?

Definition of Done

A PR is only ready for merge once all the following acceptance criteria are fulfilled:

  • Changes have been manually tested
  • All TODOs related to this PR have been closed
  • There are automated tests for newly written code and bug fixes
  • All bugs discovered while working on this PR have been submitted as issues (if not already an open issue)
  • Documentation (GH-pages, analysis/visualization READMEs, parser READMEs, --help, etc.) has been updated (almost always necessary except for bug fixes)
  • CHANGELOG.md has been updated

Screenshots or gifs

Summary by CodeRabbit

  • Documentation

    • Added several planning documents covering upcoming visualization, layout, and state-organization work.
  • Refactor

    • Restructured shared data and model definitions for clearer reuse across the app.
    • Streamlined file-loading and map-related helpers into more consistent entry points.
    • Tightened internal dependency boundaries and moved test data to a shared location.
  • Tests

    • Updated many tests to use the shared mock data and new helper paths.
    • Removed obsolete test coverage tied to deleted UI helpers.

christian-huehn-mw and others added 15 commits June 25, 2026 08:53
Sole consumer is navBar/services/readFiles.ts; relocate the whole
gameObjectsParser module (importer, validator, schema, mocks, specs)
into features/navBar/util/. Verified by dependency-cruiser (0 errors)
and jest.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
TruncateTextPipe had no template usage and no class references outside
its own spec. Removing the orphan. dependency-cruiser clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Re-verified every fan-out move candidate against the real import graph
with dependency-cruiser + jest. Most util predictions were wrong (grep
blind spot for intra-util relative imports / state-core consumers /
app.config effect registration). Only gameObjectsParser move + dead
truncateText pipe deletion held up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…pHelper cycle

buildingArrayToMap had no production callers (only its own test) and was
the sole reason util/algorithm/treeMapHelper imported CodeMapBuilding from
the codeMap feature. Removing it eliminates the util->feature inversion and
30 of the 126 no-circular warnings (126 -> 96). CodeMapBuilding stays in
the codeMap feature where it belongs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ks into codeMap

The 5 CodeMapBuilding test fixtures (CODE_MAP_BUILDING*, CONSTANT_HIGHLIGHT)
lived in the shared util/dataMocks god-file but are consumed only by codeMap
specs, forcing util/ to import up into the codeMap feature. Move them to a
codeMap-owned features/codeMap/rendering/codeMapBuilding.mocks.ts and repoint
the 3 codeMap specs. Removes the last util->codeMap inversion; CodeMapBuilding
stays in the feature. dependency-cruiser 0 errors, 143 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ks/ root folder

dataMocks is a ~2500-line cross-layer test-fixture file that was sitting in
util/ and obscuring real util problems. Move it to app/codeCharta/mocks/ (a
sibling of util/), repoint all 57 importers, and fix its one same-dir import
(./codeMapHelper -> ../util/codeMapHelper). Pure relocation: dependency-cruiser
0 errors, tests green across every import depth.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nalysis

dataMocks (now in mocks/) and *.mocks.ts files are test fixtures, not
production architecture, yet dataMocks alone added ~67 edges as a hub node
that obscured real structure in the graph. Exclude mocks/ and *.mocks.ts so
the dependency graph and boundary rules reflect production code only
(fixtures are imported solely by tests). 4622 -> 4555 dependencies cruised.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mockHelper.ts had zero references anywhere (production or test). Orphan, like
the truncateText pipe — removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ture

fileParser + fileValidator are consumed only by loadFile in production, so
relocate them to features/loadFile/util/. The one cross-feature consumer (the
globalSettings spec using getNameDataPair) now imports it via loadFile's public
facade, which is the depcruise-legal way to cross features. generatedSchema.json
stays in util/ (generated artifact) and is imported feature->util. mockHelper
already removed. dependency-cruiser 0 errors, 74 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
codeCharta.model (the leaf domain types) was reaching up into two higher
layers, forming type-only cycles:
- NameDataPair.content needed ExportCCFile -> codeCharta.model <-> codeCharta.api.model
- CcState.files needed FileState -> codeCharta.model <-> model/files/files

Fix by making the leaf stop importing upward:
- Move NameDataPair into codeCharta.api.model (next to ExportCCFile); repoint
  its 8 type importers.
- Move FileState/FileSelectionState into codeCharta.model; model/files/files
  re-exports them (natural files->model direction), so its 47 importers are
  untouched.

Both edges removed: dependency-cruiser warnings 96 -> 94, 0 errors, tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The fileValidator move left a 4-level relative path pointing at codeCharta/
instead of features/loadFile/. e2e files aren't type-checked by jest and
depcruise ignores unresolvable modules, so tsc surfaced it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ehind a barrel

Step 1 of incrementally breaking up the 363-line model god-file. Definitions
now live in model/domain.model.ts (leaf .cc.json domain types) and
model/state.model.ts (the ngrx state tree, which imports the domain one-way).
codeCharta.model.ts becomes a pure barrel re-exporting both, so all 416
existing importers keep working unchanged. Consumers can migrate to the
specific files over time, then the barrel can be dropped.

Verified: dependency-cruiser 0 errors / 94 warnings / no new cycles, tsc 0
errors across all importers, model tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…+ pin the wire DTO

loadFile now owns cc.json ingestion: moved urlExtractor in, and extracted the
wire-parsing functions (getCCFile, getCCFileAndDecorateFileChecksum) out of the
mixed util/fileHelper into loadFile/util/ccFileHelper. The cross-feature callers
reach them through loadFile's facade (navBar upload, globalSettings url-reset).
util/fileHelper keeps only getSelectedFilesSize (a FileState helper, no wire
format). fileDownloader (export side) stays shared.

Adds a dependency-cruiser rule 'wire-dto-only-in-serialization-boundary' that
confines codeCharta.api.model to the loadFile feature, the navBar gameObjects
importer, and util/fileDownloader — so rendering/state/UI can't couple to the
wire format and the upcoming cc.json 2.0 change stays contained to the converter.

tsc 0 errors, dependency-cruiser 0 errors / 94 warnings, tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds planning docs and refactors shared models, load-file helpers, fixture imports, and tree-map/file-helper utilities while tightening dependency-cruiser rules around the API model boundary.

Changes

Planning Documents

Layer / File(s) Summary
Migration roadmaps
plans/2026-06-24-go-zoneless.md, plans/2026-06-24-migrate-remaining-ui-to-features.md, plans/2026-06-25-state-util-into-features.md
Adds roadmap documents describing zoneless change detection, remaining UI migration into features, and state/util relocation analysis.
Layout switcher plan
plans/2026-06-24-on-map-layout-switcher.md
Adds the on-map layout switcher specification covering the overlay, layout mapping, and shared-service sync.

Code and Test Refactor

Layer / File(s) Summary
Shared model contracts
visualization/app/codeCharta/codeCharta.api.model.ts, visualization/app/codeCharta/codeCharta.model.ts, visualization/app/codeCharta/model/domain.model.ts, visualization/app/codeCharta/model/state.model.ts, visualization/app/codeCharta/model/files/files.ts, visualization/.dependency-cruiser.js
Adds shared domain/state model modules, re-exports them through codeCharta.model and files.ts, and adds a dependency rule for the API model boundary.
Load-file facade and helpers
visualization/app/codeCharta/features/loadFile/..., visualization/app/codeCharta/features/navBar/..., visualization/app/codeCharta/features/globalSettings/components/globalConfigurationDialog/..., visualization/app/codeCharta/features/navBar/util/gameObjectsParser/..., visualization/app/codeCharta/util/algorithm/treeMapLayout/treeMapGenerator.spec.ts
Adds the load-file facade and checksum helper, updates parser/validation modules, and rewires load-file, parser, and related tests to the new model and facade paths.
Shared fixture migration
visualization/app/codeCharta/mocks/dataMocks.ts, visualization/app/codeCharta/features/codeMap/rendering/codeMapBuilding.mocks.ts, visualization/app/codeCharta/features/.../*.spec.ts, visualization/app/codeCharta/state/.../*.spec.ts, visualization/app/codeCharta/util/.../*.spec.ts, visualization/app/codeCharta/model/files/files.helper.spec.ts
Moves CodeMapBuilding fixtures into feature-local mocks, removes them from shared mocks, and retargets specs to mocks/dataMocks.
TreeMap helper cleanup
visualization/app/codeCharta/util/algorithm/treeMapLayout/treeMapHelper.ts, visualization/app/codeCharta/util/algorithm/treeMapLayout/treeMapHelper.spec.ts
Removes buildingArrayToMap from treeMapHelper and deletes the associated spec coverage.
File helper cleanup
visualization/app/codeCharta/util/fileHelper.ts, visualization/app/codeCharta/util/fileHelper.spec.ts
Reduces fileHelper and its spec to getSelectedFilesSize only.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • christian-spahn-mw

Poem

Hop, hop— the models split so neat,
Facades and fixtures tap their feet.
Zoneless breezes brush the map,
A tree-map twig gives one last clap.
Bunny-approved! 🐰

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description is just the template with placeholders and does not explain the problem, implementation, or testing. Replace the template text with a real summary of the issue, what changed, how it was validated, and add screenshots only if relevant.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main refactor: migrating state/util code into feature-owned locations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tech/migrate-state-util-into-features

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'CodeCharta Visualization'

Failed conditions
14.0% Duplication on New Code (required ≤ 8%)

See analysis details on SonarQube Cloud

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (5)
visualization/app/codeCharta/util/fileHelper.spec.ts (1)

8-54: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add Arrange/Act/Assert comments to this spec.

The test name is fine, but the body no longer follows the required Arrange-Act-Assert structure with comments.

Suggested update
         it("should sum up sizes of selected files", () => {
+            // Arrange
             const file1 = {
                 fileMeta: {
                     fileName: "file1",
                     fileChecksum: "invalid-md5-checksum-1",
                     projectName: "Sample Project",
@@
             const severalFiles: FileState[] = [
                 {
                     file: file1,
                     selectedAs: FileSelectionState.Partial
                 },
@@
                 }
             ]
 
-            expect(getSelectedFilesSize(severalFiles)).toBe(20)
+            // Act
+            const totalSize = getSelectedFilesSize(severalFiles)
+
+            // Assert
+            expect(totalSize).toBe(20)
         })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@visualization/app/codeCharta/util/fileHelper.spec.ts` around lines 8 - 54,
The spec for getSelectedFilesSize no longer shows the required
Arrange-Act-Assert structure. Update the test body in fileHelper.spec.ts by
adding explicit Arrange, Act, and Assert comments around the existing setup of
file1/file2/unselectedFile and severalFiles, the call to getSelectedFilesSize,
and the expect assertion, keeping the current test name and behavior unchanged.

Source: Coding guidelines

visualization/app/codeCharta/features/loadFile/util/ccFileHelper.ts (1)

48-55: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

potentiallyUpdateBlacklistTypes mutates the caller's input in place.

entry.type is reassigned directly on the items of the passed-in array, which is fileContent.blacklist from the original NameDataPair.content. This produces a side effect on the source object that survives outside the function. Prefer returning a new array.

♻️ Non-mutating variant
-function potentiallyUpdateBlacklistTypes(blacklist): BlacklistItem[] {
-    for (const entry of blacklist) {
-        if (entry.type === ExportBlacklistType.hide) {
-            entry.type = "flatten"
-        }
-    }
-    return blacklist
-}
+function potentiallyUpdateBlacklistTypes(blacklist): BlacklistItem[] {
+    return blacklist.map(entry =>
+        entry.type === ExportBlacklistType.hide ? { ...entry, type: "flatten" } : entry
+    )
+}
As per coding guidelines: "Prefer immutable data structures, especially in the model layer."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@visualization/app/codeCharta/features/loadFile/util/ccFileHelper.ts` around
lines 48 - 55, `potentiallyUpdateBlacklistTypes` is mutating the input blacklist
array and its items in place, which leaks changes back into
`NameDataPair.content.fileContent.blacklist`. Update the function to return a
new `BlacklistItem[]` instead of modifying the passed-in array, preserving
immutability. Use the `potentiallyUpdateBlacklistTypes` helper in
`ccFileHelper.ts` to map each entry to a copied object and change `type` only on
the copy when `ExportBlacklistType.hide` is encountered.

Source: Coding guidelines

visualization/.dependency-cruiser.js (1)

137-140: 📐 Maintainability & Code Quality | 🔵 Trivial

Architectural improvement: Keep mocks in the dependency graph for enforceability

While the current codebase has no production files importing mocks (verified by the exclusion of *.mocks.ts files), keeping the mocks/ directory and *.mocks.ts files entirely excluded from the dependency graph is risky for future maintainability. This configuration prevents dependency-cruiser from flagging any accidental future imports of mocks into production code, as these paths are invisible to the rules.

Recommendation:
Remove the exclusion of app/codeCharta/mocks/ and *.mocks.ts from the path array in visualization/.dependency-cruiser.js (lines 137-140). Instead, explicitly define a rule that forbids non-test production files from importing these mocks. This ensures the graph remains complete and that any accidental usage is caught immediately rather than silently ignored.

// .dependency-cruiser.js
// Instead of excluding these paths, define a rule like:
// {
//   name: "no-mock-imports",
//   severity: "error",
//   comment: "Do not import mocks in production code. Only test files should import from mocks.",
//   path: ["^app/codeCharta/"], // All app code
//   to: ["(mocks/|\\.mocks\\.ts$)"], // Targeting mocks
//   condition: ["not_path: \\.(spec|e2e|test|po)\\.ts$"] // Exclude test files
// }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@visualization/.dependency-cruiser.js` around lines 137 - 140, The
dependency-cruiser config is hiding mocks from the graph by excluding
app/codeCharta/mocks/ and *.mocks.ts in the path array, which prevents future
mock imports from being enforced. Update visualization/.dependency-cruiser.js by
removing those exclusions and instead add an explicit no-mock-imports rule that
matches production code and forbids imports into the mocks folder or *.mocks.ts
files, while allowing test files such as spec/test/e2e/po to keep using them.
Keep the existing node_modules exception unchanged and ensure the new rule is
the place where mock usage is blocked.
visualization/app/codeCharta/features/globalSettings/components/globalConfigurationDialog/confirmResetMapDialog/confirmResetMapDialog.spec.ts (1)

8-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Unify the facade import path and consolidate into one statement.

Lines 8/11 use ../../../../loadFile/facade while lines 9/10 use ../../../../../features/loadFile/facade; both resolve to the same module. jest.mock("../../../../loadFile/facade") (Line 21) still mocks the same resolved module, so this works, but the divergent spellings are confusing. Merge all four into a single import using one consistent path.

♻️ Proposed consolidation
-import { getNameDataPair } from "../../../../loadFile/facade"
-import { LoadFileService } from "../../../../../features/loadFile/facade"
-import { LoadInitialFileService, sampleFile1, sampleFile2 } from "../../../../../features/loadFile/facade"
-import { UrlExtractor } from "../../../../loadFile/facade"
+import { getNameDataPair, LoadFileService, LoadInitialFileService, sampleFile1, sampleFile2, UrlExtractor } from "../../../../loadFile/facade"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@visualization/app/codeCharta/features/globalSettings/components/globalConfigurationDialog/confirmResetMapDialog/confirmResetMapDialog.spec.ts`
around lines 8 - 11, The spec has duplicate imports from the same facade module
using two different relative paths, which is confusing and should be
consolidated. Update the imports in confirmResetMapDialog.spec.ts to use one
consistent path for all symbols, and merge getNameDataPair, LoadFileService,
LoadInitialFileService, sampleFile1, sampleFile2, and UrlExtractor into a single
import statement that matches the existing jest.mock target.
visualization/app/codeCharta/features/loadFile/util/urlExtractor.ts (1)

3-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consolidate the two imports from codeCharta.api.model.

Lines 3 and 5 both pull from ../../../codeCharta.api.model; merge them into a single import statement for clarity.

♻️ Proposed consolidation
-import { NameDataPair } from "../../../codeCharta.api.model"
 import { getCCFileAndDecorateFileChecksum } from "./ccFileHelper"
-import { ExportCCFile, ExportWrappedCCFile } from "../../../codeCharta.api.model"
+import { NameDataPair, ExportCCFile, ExportWrappedCCFile } from "../../../codeCharta.api.model"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@visualization/app/codeCharta/features/loadFile/util/urlExtractor.ts` around
lines 3 - 5, Consolidate the duplicate imports from codeCharta.api.model in
urlExtractor.ts by merging the NameDataPair, ExportCCFile, and
ExportWrappedCCFile symbols into a single import statement; keep the existing
ccFileHelper import unchanged and update the top-level import block so there is
only one reference to ../../../codeCharta.api.model.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@visualization/app/codeCharta/codeCharta.api.model.ts`:
- Around line 3-7: NameDataPair.content is typed as non-nullable, but
getCCFileAndDecorateFileChecksum can return null and that value is being passed
through unchanged. Update the callers in uploadFiles.service and urlExtractor to
guard against null before constructing or assigning NameDataPair, or, if null is
a valid state, change NameDataPair.content in codeCharta.api.model.ts to reflect
ExportCCFile | null (or optional) and adjust downstream consumers accordingly.
Use the NameDataPair interface and getCCFileAndDecorateFileChecksum as the key
symbols when making the change.

In `@visualization/app/codeCharta/features/loadFile/util/ccFileHelper.spec.ts`:
- Around line 78-85: The test case in ccFileHelper.spec.ts is duplicated and
misleading because it uses the same description as an earlier test while
asserting on fileSettings.attributeDescriptors; rename the test to a unique,
descriptive title that matches the assertion so it clearly reflects the behavior
being verified in getCCFile and stays distinct from the other “should return
attributeTypes if nodes exist” case.

---

Nitpick comments:
In `@visualization/.dependency-cruiser.js`:
- Around line 137-140: The dependency-cruiser config is hiding mocks from the
graph by excluding app/codeCharta/mocks/ and *.mocks.ts in the path array, which
prevents future mock imports from being enforced. Update
visualization/.dependency-cruiser.js by removing those exclusions and instead
add an explicit no-mock-imports rule that matches production code and forbids
imports into the mocks folder or *.mocks.ts files, while allowing test files
such as spec/test/e2e/po to keep using them. Keep the existing node_modules
exception unchanged and ensure the new rule is the place where mock usage is
blocked.

In
`@visualization/app/codeCharta/features/globalSettings/components/globalConfigurationDialog/confirmResetMapDialog/confirmResetMapDialog.spec.ts`:
- Around line 8-11: The spec has duplicate imports from the same facade module
using two different relative paths, which is confusing and should be
consolidated. Update the imports in confirmResetMapDialog.spec.ts to use one
consistent path for all symbols, and merge getNameDataPair, LoadFileService,
LoadInitialFileService, sampleFile1, sampleFile2, and UrlExtractor into a single
import statement that matches the existing jest.mock target.

In `@visualization/app/codeCharta/features/loadFile/util/ccFileHelper.ts`:
- Around line 48-55: `potentiallyUpdateBlacklistTypes` is mutating the input
blacklist array and its items in place, which leaks changes back into
`NameDataPair.content.fileContent.blacklist`. Update the function to return a
new `BlacklistItem[]` instead of modifying the passed-in array, preserving
immutability. Use the `potentiallyUpdateBlacklistTypes` helper in
`ccFileHelper.ts` to map each entry to a copied object and change `type` only on
the copy when `ExportBlacklistType.hide` is encountered.

In `@visualization/app/codeCharta/features/loadFile/util/urlExtractor.ts`:
- Around line 3-5: Consolidate the duplicate imports from codeCharta.api.model
in urlExtractor.ts by merging the NameDataPair, ExportCCFile, and
ExportWrappedCCFile symbols into a single import statement; keep the existing
ccFileHelper import unchanged and update the top-level import block so there is
only one reference to ../../../codeCharta.api.model.

In `@visualization/app/codeCharta/util/fileHelper.spec.ts`:
- Around line 8-54: The spec for getSelectedFilesSize no longer shows the
required Arrange-Act-Assert structure. Update the test body in
fileHelper.spec.ts by adding explicit Arrange, Act, and Assert comments around
the existing setup of file1/file2/unselectedFile and severalFiles, the call to
getSelectedFilesSize, and the expect assertion, keeping the current test name
and behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9e0df91c-0da5-45e8-a49d-64510b350cec

📥 Commits

Reviewing files that changed from the base of the PR and between 066912e and a9cba44.

⛔ Files ignored due to path filters (2)
  • visualization/app/codeCharta/features/loadFile/util/__snapshots__/ccFileHelper.spec.ts.snap is excluded by !**/*.snap
  • visualization/app/codeCharta/features/navBar/util/gameObjectsParser/__snapshots__/gameObjectsImporter.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (94)
  • plans/2026-06-24-go-zoneless.md
  • plans/2026-06-24-migrate-remaining-ui-to-features.md
  • plans/2026-06-24-on-map-layout-switcher.md
  • plans/2026-06-25-state-util-into-features.md
  • visualization/.dependency-cruiser.js
  • visualization/app/codeCharta/codeCharta.api.model.ts
  • visualization/app/codeCharta/codeCharta.model.ts
  • visualization/app/codeCharta/features/3dPrint/components/export3DMapDialog/export3DMapDialog.component.spec.ts
  • visualization/app/codeCharta/features/codeMap/arrow/codeMap.arrow.service.spec.ts
  • visualization/app/codeCharta/features/codeMap/codeMap.mouseEvent.service.spec.ts
  • visualization/app/codeCharta/features/codeMap/codeMap.render.service.spec.ts
  • visualization/app/codeCharta/features/codeMap/rendering/codeMapBuilding.mocks.ts
  • visualization/app/codeCharta/features/codeMap/rendering/codeMapBuilding.spec.ts
  • visualization/app/codeCharta/features/codeMap/rendering/codeMapMesh.spec.ts
  • visualization/app/codeCharta/features/codeMap/rendering/geometryGenerator.spec.ts
  • visualization/app/codeCharta/features/codeMap/threeViewer/threeSceneService.spec.ts
  • visualization/app/codeCharta/features/fileExtensionBar/selectors/hoveredNodeMetricDistribution.selector.spec.ts
  • visualization/app/codeCharta/features/globalSettings/components/globalConfigurationDialog/confirmResetMapDialog/confirmResetMapDialog.component.ts
  • visualization/app/codeCharta/features/globalSettings/components/globalConfigurationDialog/confirmResetMapDialog/confirmResetMapDialog.spec.ts
  • visualization/app/codeCharta/features/globalSettings/components/globalConfigurationDialog/resetMapButton/resetMapButton.component.spec.ts
  • visualization/app/codeCharta/features/labelSettings/components/labelSettingsPanel/labelSettingsPanel.component.spec.ts
  • visualization/app/codeCharta/features/labelSettings/services/labelCollision.service.spec.ts
  • visualization/app/codeCharta/features/loadFile/facade.ts
  • visualization/app/codeCharta/features/loadFile/services/loadFile.service.spec.ts
  • visualization/app/codeCharta/features/loadFile/services/loadFile.service.ts
  • visualization/app/codeCharta/features/loadFile/services/loadFilesValidationToErrorDialog.spec.ts
  • visualization/app/codeCharta/features/loadFile/services/loadFilesValidationToErrorDialog.ts
  • visualization/app/codeCharta/features/loadFile/services/loadInitialFile.service.spec.ts
  • visualization/app/codeCharta/features/loadFile/services/loadInitialFile.service.ts
  • visualization/app/codeCharta/features/loadFile/util/ccFileHelper.spec.ts
  • visualization/app/codeCharta/features/loadFile/util/ccFileHelper.ts
  • visualization/app/codeCharta/features/loadFile/util/fileParser.ts
  • visualization/app/codeCharta/features/loadFile/util/fileValidator.spec.ts
  • visualization/app/codeCharta/features/loadFile/util/fileValidator.ts
  • visualization/app/codeCharta/features/loadFile/util/urlExtractor.spec.ts
  • visualization/app/codeCharta/features/loadFile/util/urlExtractor.ts
  • visualization/app/codeCharta/features/metricsBar/services/nodeSelection.service.spec.ts
  • visualization/app/codeCharta/features/navBar/components/deltaSelector/deltaSelector.component.spec.ts
  • visualization/app/codeCharta/features/navBar/components/mapSelector/mapSelector.component.spec.ts
  • visualization/app/codeCharta/features/navBar/components/navBarFolderButton/navBarFolderButton.e2e.ts
  • visualization/app/codeCharta/features/navBar/services/fileSelectionMode.service.spec.ts
  • visualization/app/codeCharta/features/navBar/services/readFiles.ts
  • visualization/app/codeCharta/features/navBar/services/uploadFiles.service.spec.ts
  • visualization/app/codeCharta/features/navBar/services/uploadFiles.service.ts
  • visualization/app/codeCharta/features/navBar/util/gameObjectsParser/gameObjectsImporter.spec.ts
  • visualization/app/codeCharta/features/navBar/util/gameObjectsParser/gameObjectsImporter.ts
  • visualization/app/codeCharta/features/navBar/util/gameObjectsParser/gameObjectsMocks.ts
  • visualization/app/codeCharta/features/navBar/util/gameObjectsParser/gameObjectsSchema.json
  • visualization/app/codeCharta/features/navBar/util/gameObjectsParser/gameObjectsValidator.spec.ts
  • visualization/app/codeCharta/features/navBar/util/gameObjectsParser/gameObjectsValidator.ts
  • visualization/app/codeCharta/features/sidebarExplorer/selectors/sortNode.spec.ts
  • visualization/app/codeCharta/features/viewCubeToolbox/components/viewCubeToolbox/viewCubeToolbox.component.spec.ts
  • visualization/app/codeCharta/mocks/dataMocks.ts
  • visualization/app/codeCharta/model/domain.model.ts
  • visualization/app/codeCharta/model/files/files.helper.spec.ts
  • visualization/app/codeCharta/model/files/files.ts
  • visualization/app/codeCharta/model/state.model.ts
  • visualization/app/codeCharta/state/effects/addBlacklistItemsIfNotResultsInEmptyMap/addBlacklistItemsIfNotResultsInEmptyMap.effect.spec.ts
  • visualization/app/codeCharta/state/effects/resetColorRange/resetColorRange.effect.spec.ts
  • visualization/app/codeCharta/state/effects/unfocusNodes/unfocusNodes.effect.spec.ts
  • visualization/app/codeCharta/state/effects/updateFileSettings/updateFileSettings.effect.spec.ts
  • visualization/app/codeCharta/state/effects/updateFileSettings/utils/blacklist.merger.spec.ts
  • visualization/app/codeCharta/state/effects/updateFileSettings/utils/edges.merger.spec.ts
  • visualization/app/codeCharta/state/effects/updateFileSettings/utils/markedPackages.merger.spec.ts
  • visualization/app/codeCharta/state/effects/updateQueryParameters/updateQueryParameters.spec.ts
  • visualization/app/codeCharta/state/selectors/accumulatedData/idToNode.selector.spec.ts
  • visualization/app/codeCharta/state/selectors/accumulatedData/metricData/edgeMetricData.calculator.spec.ts
  • visualization/app/codeCharta/state/selectors/accumulatedData/metricData/nodeMetricData.calculator.spec.ts
  • visualization/app/codeCharta/state/selectors/accumulatedData/metricData/sortedNodeEdgeMetricsMap.selector.spec.ts
  • visualization/app/codeCharta/state/selectors/amountOfBuildingsWithSelectedEdgeMetric/amountOfBuildingsWithSelectedEdgeMetric.selector.spec.ts
  • visualization/app/codeCharta/state/selectors/areMultipleMapsVisible.selector.spec.ts
  • visualization/app/codeCharta/state/selectors/searchedNodes/getNodesByGitignorePath.spec.ts
  • visualization/app/codeCharta/state/selectors/visibleFileStates/visibleFileStates.selector.spec.ts
  • visualization/app/codeCharta/state/store/fileSettings/attributeTypes/attributeTypes.reducer.spec.ts
  • visualization/app/codeCharta/state/store/fileSettings/edges/edges.reducer.spec.ts
  • visualization/app/codeCharta/state/store/fileSettings/markedPackages/markedPackages.reducer.spec.ts
  • visualization/app/codeCharta/state/store/files/files.reducer.spec.ts
  • visualization/app/codeCharta/state/store/util/getPartialDefaultState.spec.ts
  • visualization/app/codeCharta/util/algorithm/streetLayout/horizontalStreet.spec.ts
  • visualization/app/codeCharta/util/algorithm/streetLayout/house.spec.ts
  • visualization/app/codeCharta/util/algorithm/streetLayout/streetLayoutGenerator.spec.ts
  • visualization/app/codeCharta/util/algorithm/treeMapLayout/treeMapGenerator.spec.ts
  • visualization/app/codeCharta/util/algorithm/treeMapLayout/treeMapHelper.spec.ts
  • visualization/app/codeCharta/util/algorithm/treeMapLayout/treeMapHelper.ts
  • visualization/app/codeCharta/util/codeMapHelper.spec.ts
  • visualization/app/codeCharta/util/deltaGenerator.spec.ts
  • visualization/app/codeCharta/util/fileDownloader.spec.ts
  • visualization/app/codeCharta/util/fileExtension/fileExtensionCalculator.spec.ts
  • visualization/app/codeCharta/util/fileHelper.spec.ts
  • visualization/app/codeCharta/util/fileHelper.ts
  • visualization/app/codeCharta/util/mockHelper.ts
  • visualization/app/codeCharta/util/nodeDecorator.spec.ts
  • visualization/app/codeCharta/util/pipes/truncateText.pipe.ts
  • visualization/app/codeCharta/util/pipes/truncateText.spec.ts
💤 Files with no reviewable changes (5)
  • visualization/app/codeCharta/util/pipes/truncateText.pipe.ts
  • visualization/app/codeCharta/util/pipes/truncateText.spec.ts
  • visualization/app/codeCharta/util/mockHelper.ts
  • visualization/app/codeCharta/util/algorithm/treeMapLayout/treeMapHelper.ts
  • visualization/app/codeCharta/util/fileHelper.ts

Comment on lines +3 to +7
export interface NameDataPair {
fileName: string
fileSize: number
content: ExportCCFile
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check strictNullChecks/strict config and confirm producer return type
fd -t f 'tsconfig*.json' visualization | xargs -I{} sh -c 'echo "== {} =="; cat {}'
ast-grep run --pattern 'export function getCCFileAndDecorateFileChecksum($_): $RET { $$$ }' --lang typescript visualization/app/codeCharta/features/loadFile/util/ccFileHelper.ts

Repository: MaibornWolff/codecharta

Length of output: 3711


Handle nullable return from getCCFileAndDecorateFileChecksum before assigning to content.

The producer getCCFileAndDecorateFileChecksum returns ExportCCFile | null (see features/loadFile/util/ccFileHelper.ts line 57). Code in features/navBar/services/uploadFiles.service.ts (line 55) and features/loadFile/util/urlExtractor.ts (line 70) assigns this result directly to NameDataPair.content, which is typed as non-nullable ExportCCFile. Although strictNullChecks is disabled in visualization/tsconfig.json, this allows null to flow into downstream consumers that assume a valid object, risking runtime crashes (e.g., accessing content.nodes).

Validate the result before assignment or update the interface to reflect the nullable state:

  • Add a null check before creating or assigning to NameDataPair.
  • If null is a valid upstream state, update NameDataPair.content to content?: ExportCCFile | null.
Relevant snippets
// File: visualization/app/codeCharta/features/navBar/services/uploadFiles.service.ts:55
// Direct assignment of nullable result to non-nullable property
content: getCCFileAndDecorateFileChecksum(content)

// File: visualization/app/codeCharta/features/loadFile/util/urlExtractor.ts:70
// Explicit cast to non-nullable type
const content: ExportCCFile = getCCFileAndDecorateFileChecksum(responseData)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@visualization/app/codeCharta/codeCharta.api.model.ts` around lines 3 - 7,
NameDataPair.content is typed as non-nullable, but
getCCFileAndDecorateFileChecksum can return null and that value is being passed
through unchanged. Update the callers in uploadFiles.service and urlExtractor to
guard against null before constructing or assigning NameDataPair, or, if null is
a valid state, change NameDataPair.content in codeCharta.api.model.ts to reflect
ExportCCFile | null (or optional) and adjust downstream consumers accordingly.
Use the NameDataPair interface and getCCFileAndDecorateFileChecksum as the key
symbols when making the change.

Comment on lines +78 to +85
it("should return attributeTypes if nodes exist", () => {
fileContent.attributeDescriptors = TEST_ATTRIBUTE_DESCRIPTORS_HALF_FILLED

const nameDataPair: NameDataPair = { content: fileContent, fileName: "fileName", fileSize: 30 }
const result = getCCFile(nameDataPair)

expect(result.settings.fileSettings.attributeDescriptors).toEqual(TEST_ATTRIBUTE_DESCRIPTORS_HALF_FILLED)
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Duplicate/incorrect test description.

This test reuses the exact name of the test at Line 63 but actually asserts on attributeDescriptors. Rename for clarity and uniqueness.

📝 Suggested rename
-        it("should return attributeTypes if nodes exist", () => {
+        it("should return attributeDescriptors when provided", () => {
             fileContent.attributeDescriptors = TEST_ATTRIBUTE_DESCRIPTORS_HALF_FILLED
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it("should return attributeTypes if nodes exist", () => {
fileContent.attributeDescriptors = TEST_ATTRIBUTE_DESCRIPTORS_HALF_FILLED
const nameDataPair: NameDataPair = { content: fileContent, fileName: "fileName", fileSize: 30 }
const result = getCCFile(nameDataPair)
expect(result.settings.fileSettings.attributeDescriptors).toEqual(TEST_ATTRIBUTE_DESCRIPTORS_HALF_FILLED)
})
it("should return attributeDescriptors when provided", () => {
fileContent.attributeDescriptors = TEST_ATTRIBUTE_DESCRIPTORS_HALF_FILLED
const nameDataPair: NameDataPair = { content: fileContent, fileName: "fileName", fileSize: 30 }
const result = getCCFile(nameDataPair)
expect(result.settings.fileSettings.attributeDescriptors).toEqual(TEST_ATTRIBUTE_DESCRIPTORS_HALF_FILLED)
})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@visualization/app/codeCharta/features/loadFile/util/ccFileHelper.spec.ts`
around lines 78 - 85, The test case in ccFileHelper.spec.ts is duplicated and
misleading because it uses the same description as an earlier test while
asserting on fileSettings.attributeDescriptors; rename the test to a unique,
descriptive title that matches the assertion so it clearly reflects the behavior
being verified in getCCFile and stays distinct from the other “should return
attributeTypes if nodes exist” case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants