Skip to content

Refactor duplicated node creation logic to follow DRY principles #87

@coderabbitai

Description

@coderabbitai

Overview

As identified in PR #86, there is significant code duplication in the codebase that should be refactored to follow the DRY (Don't Repeat Yourself) principle.

Specific Issue in dependency_xml_analyzer.rs

In src/c_sharp_graph/dependency_xml_analyzer.rs (lines ~119-285), namespace node creation logic is repeated three times and type node creation logic is repeated twice. This duplication:

  • Increases maintenance burden
  • Creates risk of inconsistencies (e.g., tracking bugs that exist in one branch but not others)
  • Makes the code harder to understand and modify

Suggested approach:
Extract helper functions like:

  • get_or_create_namespace_node(...)
  • get_or_create_type_node(...)

These helpers should encapsulate the shared logic for node creation, syntax type assignment, tracking increments, and edge creation.

Broader Scope

There are other places throughout the codebase where similar duplication exists and should be addressed as part of a broader refactoring effort to improve code maintainability.

References

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.kind/featureCategorizes issue or PR as related to a new feature.priority/backlogHigher priority than priority/awaiting-more-evidence.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions