Skip to content

refactor: eliminate respond_to? violations, add thorough specs#85

Merged
ronaldtse merged 3 commits into
mainfrom
rt-perf-more
May 11, 2026
Merged

refactor: eliminate respond_to? violations, add thorough specs#85
ronaldtse merged 3 commits into
mainfrom
rt-perf-more

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

  • Eliminate all respond_to? violations — 6 occurrences replaced with proper type checks, no-op base methods, and model-driven declarations
  • Add model-driven id to UmlModel — UML Model elements CAN have xmi:id in XMI schema; now properly declared
  • Add thorough specs for all perf implementations (248 → 299 examples)

Code changes

File Change
parser_pipeline.rb Remove respond_to?(:valid_encoding?) and respond_to?(:build_index)
root.rb Add no-op build_index (OCP: pipeline calls unconditionally)
parsing.rb Replace respond_to?(:read) with is_a?(String)
ea_root/code_generation.rb Abstract classes get root_tag { nil }
ea_root/extension_lifecycle.rb Check klass.root_tag truthiness instead of respond_to?
uml/uml_model.rb Add id attribute and mapping
sparx/index.rb Remove respond_to?(:id) and respond_to?(:packaged_element) guards

Spec additions

  • namespace_detector_spec.rb (new): regex extraction, version detection, regex vs Nokogiri parity across all fixtures
  • index_spec.rb (rewritten): concrete assertions against known fixture data, EAStub indexing, parent tracking, minimal XML edge case
  • parser_pipeline_spec.rb: step isolation, context mutation verification, base Root compatibility
  • extension_loading_spec.rb: abstract vs stereotype root_tag tests
  • versioning_spec.rb: fallback idempotency guard, detect_register, parse_with_detected_version
  • fixtures.rb: remove stale ea-xmi-2.4.2.xmi entry (file doesn't exist)

ronaldtse added 3 commits May 11, 2026 17:18
…o UmlModel

- Remove 6 respond_to? calls across parser_pipeline, parsing, ea_root, index
- Add build_index no-op to base Root (OCP: pipeline calls unconditionally)
- Abstract classes define root_tag returning nil (replaces respond_to? check)
- Replace respond_to?(:read) with is_a?(String) type check
- Add id attribute to UmlModel (model-driven: UML Model can have xmi:id)
- Remove respond_to?(:packaged_element) guard (Profile always has it)
- New namespace_detector_spec: regex extraction, version detection,
  regex vs Nokogiri parity across all fixtures
- Rewritten index_spec: concrete assertions against known fixture data,
  EAStub indexing (commit b2593bd), parent tracking, minimal XML edge case
- Extended parser_pipeline_spec: step isolation, context mutation,
  base Root compatibility
- Extended extension_loading_spec: abstract vs stereotype root_tag tests
- Extended versioning_spec: fallback idempotency, detect_register,
  parse_with_detected_version
- Remove stale ea-xmi-2.4.2.xmi from fixture registry

248 -> 299 examples, 0 failures
@ronaldtse ronaldtse merged commit 5c8b20c into main May 11, 2026
11 of 13 checks passed
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.

1 participant