lutaml 0.10.4 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -0
- data/.rubocop_todo.yml +91 -101
- data/TODO.cleanups/01-resolve-production-todos.md +65 -0
- data/TODO.cleanups/02-reduce-metrics-offenses.md +37 -0
- data/TODO.cleanups/03-reduce-rspec-multiple-expectations.md +54 -0
- data/TODO.cleanups/04-reduce-rspec-example-length.md +45 -0
- data/TODO.cleanups/05-replace-marshal-load.md +37 -0
- data/TODO.cleanups/06-replace-eval-in-tests.md +41 -0
- data/TODO.cleanups/07-fix-lint-offenses.md +74 -0
- data/TODO.cleanups/08-reduce-memoized-helpers-and-nesting.md +43 -0
- data/TODO.cleanups/09-reduce-verified-doubles-and-rspec-style.md +57 -0
- data/TODO.cleanups/10-split-large-files.md +47 -0
- data/bin/console +0 -1
- data/lib/lutaml/cli/element_identifier.rb +3 -6
- data/lib/lutaml/cli/interactive_shell/bookmark_commands.rb +88 -0
- data/lib/lutaml/cli/interactive_shell/command_base.rb +28 -0
- data/lib/lutaml/cli/interactive_shell/export_handler.rb +67 -0
- data/lib/lutaml/cli/interactive_shell/help_display.rb +114 -0
- data/lib/lutaml/cli/interactive_shell/navigation_commands.rb +135 -0
- data/lib/lutaml/cli/interactive_shell/query_commands.rb +185 -0
- data/lib/lutaml/cli/interactive_shell.rb +116 -802
- data/lib/lutaml/cli/uml/build_command.rb +5 -5
- data/lib/lutaml/cli/uml/verify_command.rb +0 -1
- data/lib/lutaml/converter/xmi_to_uml.rb +3 -153
- data/lib/lutaml/converter/xmi_to_uml_generalization.rb +193 -0
- data/lib/lutaml/formatter/graphviz.rb +1 -2
- data/lib/lutaml/qea/database.rb +1 -47
- data/lib/lutaml/qea/factory/association_builder.rb +187 -0
- data/lib/lutaml/qea/factory/base_transformer.rb +0 -1
- data/lib/lutaml/qea/factory/class_transformer.rb +42 -594
- data/lib/lutaml/qea/factory/diagram_transformer.rb +0 -3
- data/lib/lutaml/qea/factory/generalization_builder.rb +211 -0
- data/lib/lutaml/qea/factory/package_transformer.rb +1 -2
- data/lib/lutaml/qea/factory/stereotype_loader.rb +34 -0
- data/lib/lutaml/qea/lookup_indexes.rb +54 -0
- data/lib/lutaml/qea/models/ea_datatype.rb +0 -2
- data/lib/lutaml/qea/validation/validation_engine.rb +0 -2
- data/lib/lutaml/uml/has_members.rb +0 -1
- data/lib/lutaml/uml/inheritance_walker.rb +91 -0
- data/lib/lutaml/uml/model_helpers.rb +129 -0
- data/lib/lutaml/uml/node/attribute.rb +3 -1
- data/lib/lutaml/uml/node/class_node.rb +3 -3
- data/lib/lutaml/uml/operation.rb +2 -0
- data/lib/lutaml/uml_repository/class_lookup_index.rb +40 -0
- data/lib/lutaml/uml_repository/exporters/markdown/class_page_builder.rb +177 -0
- data/lib/lutaml/uml_repository/exporters/markdown/formatting.rb +36 -0
- data/lib/lutaml/uml_repository/exporters/markdown/index_page_builder.rb +73 -0
- data/lib/lutaml/uml_repository/exporters/markdown/link_resolver.rb +40 -0
- data/lib/lutaml/uml_repository/exporters/markdown/package_page_builder.rb +107 -0
- data/lib/lutaml/uml_repository/exporters/markdown_exporter.rb +25 -538
- data/lib/lutaml/uml_repository/index_builder.rb +3 -271
- data/lib/lutaml/uml_repository/index_builders/association_index.rb +141 -0
- data/lib/lutaml/uml_repository/index_builders/class_index.rb +94 -0
- data/lib/lutaml/uml_repository/index_builders/package_index.rb +57 -0
- data/lib/lutaml/uml_repository/package_exporter.rb +10 -20
- data/lib/lutaml/uml_repository/package_loader.rb +37 -17
- data/lib/lutaml/uml_repository/repository/deprecated.rb +39 -0
- data/lib/lutaml/uml_repository/repository/loader.rb +112 -0
- data/lib/lutaml/uml_repository/repository.rb +6 -57
- data/lib/lutaml/uml_repository/static_site/association_serialization.rb +142 -0
- data/lib/lutaml/uml_repository/static_site/configuration.rb +0 -2
- data/lib/lutaml/uml_repository/static_site/data_transformer.rb +41 -878
- data/lib/lutaml/uml_repository/static_site/search_index_builder.rb +1 -4
- data/lib/lutaml/uml_repository/static_site/serializers/attribute_serializer.rb +78 -0
- data/lib/lutaml/uml_repository/static_site/serializers/class_serializer.rb +119 -0
- data/lib/lutaml/uml_repository/static_site/serializers/diagram_serializer.rb +59 -0
- data/lib/lutaml/uml_repository/static_site/serializers/inheritance_resolver.rb +250 -0
- data/lib/lutaml/uml_repository/static_site/serializers/metadata_builder.rb +48 -0
- data/lib/lutaml/uml_repository/static_site/serializers/operation_serializer.rb +57 -0
- data/lib/lutaml/uml_repository/static_site/serializers/package_serializer.rb +87 -0
- data/lib/lutaml/uml_repository/static_site/serializers/package_tree_builder.rb +89 -0
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/association_drop.rb +13 -35
- data/lib/lutaml/xmi/liquid_drops/attribute_drop.rb +12 -18
- data/lib/lutaml/xmi/liquid_drops/cardinality_drop.rb +14 -6
- data/lib/lutaml/xmi/liquid_drops/connector_drop.rb +0 -3
- data/lib/lutaml/xmi/liquid_drops/constraint_drop.rb +1 -3
- data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +13 -70
- data/lib/lutaml/xmi/liquid_drops/dependency_drop.rb +2 -5
- data/lib/lutaml/xmi/liquid_drops/diagram_drop.rb +5 -11
- data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +8 -16
- data/lib/lutaml/xmi/liquid_drops/enum_owned_literal_drop.rb +3 -9
- data/lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb +11 -13
- data/lib/lutaml/xmi/liquid_drops/generalization_drop.rb +27 -85
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +39 -91
- data/lib/lutaml/xmi/liquid_drops/operation_drop.rb +3 -9
- data/lib/lutaml/xmi/liquid_drops/package_drop.rb +16 -44
- data/lib/lutaml/xmi/liquid_drops/root_drop.rb +3 -11
- data/lib/lutaml/xmi/liquid_drops/source_target_drop.rb +2 -5
- data/lib/lutaml/xmi/parsers/xmi_base.rb +2 -749
- data/lib/lutaml/xmi/parsers/xmi_class_members.rb +45 -0
- data/lib/lutaml/xmi/parsers/xmi_connector.rb +251 -0
- data/lib/lutaml/xmi/parsers/xml.rb +7 -120
- data/lib/lutaml/xmi/xmi_lookup_service.rb +42 -0
- data/lib/lutaml.rb +0 -1
- metadata +48 -21
- data/lib/lutaml/cli/commands/base_command.rb +0 -118
- data/lib/lutaml/command_line.rb +0 -272
- data/lib/lutaml/sysml/allocate.rb +0 -9
- data/lib/lutaml/sysml/allocated.rb +0 -9
- data/lib/lutaml/sysml/binding_connector.rb +0 -9
- data/lib/lutaml/sysml/block.rb +0 -32
- data/lib/lutaml/sysml/constraint_block.rb +0 -14
- data/lib/lutaml/sysml/copy.rb +0 -8
- data/lib/lutaml/sysml/derive_requirement.rb +0 -9
- data/lib/lutaml/sysml/nested_connector_end.rb +0 -13
- data/lib/lutaml/sysml/refine.rb +0 -9
- data/lib/lutaml/sysml/requirement.rb +0 -44
- data/lib/lutaml/sysml/requirement_related.rb +0 -9
- data/lib/lutaml/sysml/satisfy.rb +0 -9
- data/lib/lutaml/sysml/test_case.rb +0 -25
- data/lib/lutaml/sysml/trace.rb +0 -9
- data/lib/lutaml/sysml/verify.rb +0 -8
- data/lib/lutaml/sysml/xmi_file.rb +0 -486
- data/lib/lutaml/sysml.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d1caee886e1e27cbbd7db3101f510bd0a1169050cbab47f48bdb31622e46c16
|
|
4
|
+
data.tar.gz: 4d42b151859f65339b67dffc2e5070e2851819daaf145295b05285d2cecc5e50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62f845a38a4336cee141fb710ced850a20332db561ab44fe08d16c9e780c75c2844b982176902c0eab600175561e7efd7b63136ba9eabc707ce07d424f1c0c9f
|
|
7
|
+
data.tar.gz: 0ce0fd5ae74fdd0ba9f795e39e4b7b0ead7492443f06eeee34dbbeaaf31fdab16601174dbf53f72d412c13581a8cac82cefdf4906c060f317d7f7afd2a8f3b1d
|
data/.rubocop.yml
CHANGED
|
@@ -17,3 +17,13 @@ plugins:
|
|
|
17
17
|
|
|
18
18
|
AllCops:
|
|
19
19
|
TargetRubyVersion: 3.2
|
|
20
|
+
|
|
21
|
+
# VerifiedDoubles is disabled because many spec files use double() to mock
|
|
22
|
+
# UML model classes (Lutaml::Uml::Class, Package, etc.) that don't implement
|
|
23
|
+
# all stubbed methods as real Ruby methods (they use Lutaml::Model::Serializable
|
|
24
|
+
# attribute declarations). Converting to instance_double would cause test failures
|
|
25
|
+
# due to method verification.
|
|
26
|
+
RSpec/VerifiedDoubles:
|
|
27
|
+
Enabled: false
|
|
28
|
+
Exclude:
|
|
29
|
+
- 'spec/**/*'
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,32 +1,52 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2026-04-
|
|
3
|
+
# on 2026-04-28 10:51:28 UTC using RuboCop version 1.86.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count:
|
|
9
|
+
# Offense count: 16
|
|
10
10
|
# This cop supports safe autocorrection (--autocorrect).
|
|
11
|
-
Layout/
|
|
11
|
+
Layout/EmptyLineAfterGuardClause:
|
|
12
12
|
Exclude:
|
|
13
|
-
- 'lib/lutaml/qea/factory/
|
|
13
|
+
- 'lib/lutaml/qea/factory/association_builder.rb'
|
|
14
|
+
- 'lib/lutaml/uml/inheritance_walker.rb'
|
|
15
|
+
- 'lib/lutaml/uml_repository/static_site/data_transformer.rb'
|
|
16
|
+
- 'lib/lutaml/uml_repository/static_site/serializers/class_serializer.rb'
|
|
17
|
+
- 'lib/lutaml/uml_repository/static_site/serializers/diagram_serializer.rb'
|
|
18
|
+
- 'lib/lutaml/uml_repository/static_site/serializers/inheritance_resolver.rb'
|
|
19
|
+
- 'lib/lutaml/uml_repository/static_site/serializers/package_serializer.rb'
|
|
20
|
+
|
|
21
|
+
# Offense count: 4
|
|
22
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
23
|
+
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
|
|
24
|
+
Layout/EmptyLineBetweenDefs:
|
|
25
|
+
Exclude:
|
|
26
|
+
- 'lib/lutaml/cli/interactive_shell/command_base.rb'
|
|
14
27
|
|
|
15
28
|
# Offense count: 1
|
|
16
29
|
# This cop supports safe autocorrection (--autocorrect).
|
|
17
|
-
|
|
18
|
-
# SupportedStylesAlignWith: start_of_line, relative_to_receiver
|
|
19
|
-
Layout/IndentationWidth:
|
|
30
|
+
Layout/EmptyLinesAfterModuleInclusion:
|
|
20
31
|
Exclude:
|
|
21
|
-
- 'lib/lutaml/
|
|
32
|
+
- 'lib/lutaml/uml_repository/repository.rb'
|
|
22
33
|
|
|
23
|
-
# Offense count:
|
|
34
|
+
# Offense count: 183
|
|
24
35
|
# This cop supports safe autocorrection (--autocorrect).
|
|
25
36
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
26
37
|
# URISchemes: http, https
|
|
27
38
|
Layout/LineLength:
|
|
28
39
|
Enabled: false
|
|
29
40
|
|
|
41
|
+
# Offense count: 2
|
|
42
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
43
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
|
44
|
+
# SupportedStyles: space, no_space, compact
|
|
45
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
|
46
|
+
Layout/SpaceInsideHashLiteralBraces:
|
|
47
|
+
Exclude:
|
|
48
|
+
- 'lib/lutaml/uml/model_helpers.rb'
|
|
49
|
+
|
|
30
50
|
# Offense count: 1
|
|
31
51
|
Lint/BinaryOperatorWithIdenticalOperands:
|
|
32
52
|
Exclude:
|
|
@@ -43,23 +63,12 @@ Lint/ConstantDefinitionInBlock:
|
|
|
43
63
|
- 'spec/lutaml/model_transformations_spec.rb'
|
|
44
64
|
- 'spec/lutaml/uml_repository/presenters/presenter_factory_spec.rb'
|
|
45
65
|
|
|
46
|
-
# Offense count:
|
|
47
|
-
Lint/CopDirectiveSyntax:
|
|
48
|
-
Exclude:
|
|
49
|
-
- 'lib/lutaml/uml_repository/repository.rb'
|
|
50
|
-
|
|
51
|
-
# Offense count: 8
|
|
66
|
+
# Offense count: 2
|
|
52
67
|
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
|
|
53
68
|
Lint/DuplicateBranch:
|
|
54
69
|
Exclude:
|
|
55
|
-
- 'lib/lutaml/
|
|
56
|
-
- 'lib/lutaml/cli/uml/verify_command.rb'
|
|
57
|
-
- 'lib/lutaml/qea/factory/base_transformer.rb'
|
|
58
|
-
- 'lib/lutaml/qea/models/ea_datatype.rb'
|
|
59
|
-
- 'lib/lutaml/qea/validation/validation_engine.rb'
|
|
70
|
+
- 'lib/lutaml/uml/model_helpers.rb'
|
|
60
71
|
- 'lib/lutaml/uml_repository/queries/package_query.rb'
|
|
61
|
-
- 'lib/lutaml/uml_repository/static_site/configuration.rb'
|
|
62
|
-
- 'lib/lutaml/uml_repository/static_site/search_index_builder.rb'
|
|
63
72
|
|
|
64
73
|
# Offense count: 4
|
|
65
74
|
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
|
@@ -89,6 +98,13 @@ Lint/MissingSuper:
|
|
|
89
98
|
Exclude:
|
|
90
99
|
- 'lib/lutaml/uml_repository/lazy_repository.rb'
|
|
91
100
|
|
|
101
|
+
# Offense count: 2
|
|
102
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
103
|
+
Lint/RedundantRequireStatement:
|
|
104
|
+
Exclude:
|
|
105
|
+
- 'lib/lutaml/qea/factory/generalization_builder.rb'
|
|
106
|
+
- 'lib/lutaml/uml_repository/static_site/serializers/inheritance_resolver.rb'
|
|
107
|
+
|
|
92
108
|
# Offense count: 1
|
|
93
109
|
# This cop supports safe autocorrection (--autocorrect).
|
|
94
110
|
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
|
|
@@ -97,62 +113,45 @@ Lint/UnusedMethodArgument:
|
|
|
97
113
|
Exclude:
|
|
98
114
|
- 'lib/lutaml/cli/uml/export_command.rb'
|
|
99
115
|
|
|
100
|
-
# Offense count:
|
|
116
|
+
# Offense count: 2
|
|
117
|
+
Lint/UselessConstantScoping:
|
|
118
|
+
Exclude:
|
|
119
|
+
- 'lib/lutaml/cli/interactive_shell.rb'
|
|
120
|
+
|
|
121
|
+
# Offense count: 52
|
|
101
122
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
102
123
|
Metrics/AbcSize:
|
|
103
|
-
|
|
104
|
-
- 'lib/lutaml/converter/xmi_to_uml.rb'
|
|
105
|
-
- 'lib/lutaml/model_transformations/parsers/base_parser.rb'
|
|
106
|
-
- 'lib/lutaml/qea/database.rb'
|
|
107
|
-
- 'lib/lutaml/uml_repository/index_builder.rb'
|
|
108
|
-
- 'lib/lutaml/uml_repository/queries/class_query.rb'
|
|
109
|
-
- 'lib/lutaml/uml_repository/queries/inheritance_query.rb'
|
|
110
|
-
- 'lib/lutaml/xmi/parsers/xmi_base.rb'
|
|
124
|
+
Enabled: false
|
|
111
125
|
|
|
112
|
-
# Offense count:
|
|
126
|
+
# Offense count: 4
|
|
113
127
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
|
|
114
128
|
# AllowedMethods: refine
|
|
115
129
|
Metrics/BlockLength:
|
|
116
|
-
Max:
|
|
130
|
+
Max: 53
|
|
117
131
|
|
|
118
|
-
# Offense count:
|
|
132
|
+
# Offense count: 37
|
|
119
133
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
120
134
|
Metrics/CyclomaticComplexity:
|
|
121
|
-
|
|
122
|
-
- 'lib/lutaml/cli/tree_view_formatter.rb'
|
|
123
|
-
- 'lib/lutaml/converter/xmi_to_uml.rb'
|
|
124
|
-
- 'lib/lutaml/qea/database.rb'
|
|
125
|
-
- 'lib/lutaml/qea/factory/enum_transformer.rb'
|
|
126
|
-
- 'lib/lutaml/uml_repository/index_builder.rb'
|
|
127
|
-
- 'lib/lutaml/uml_repository/queries/class_query.rb'
|
|
128
|
-
- 'lib/lutaml/uml_repository/queries/inheritance_query.rb'
|
|
129
|
-
- 'lib/lutaml/uml_repository/queries/search_query.rb'
|
|
130
|
-
- 'lib/lutaml/xmi/parsers/xmi_base.rb'
|
|
135
|
+
Enabled: false
|
|
131
136
|
|
|
132
|
-
# Offense count:
|
|
137
|
+
# Offense count: 65
|
|
133
138
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
134
139
|
Metrics/MethodLength:
|
|
135
|
-
Max:
|
|
140
|
+
Max: 62
|
|
136
141
|
|
|
137
|
-
# Offense count:
|
|
142
|
+
# Offense count: 29
|
|
138
143
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
139
144
|
Metrics/PerceivedComplexity:
|
|
140
|
-
|
|
141
|
-
- 'lib/lutaml/converter/xmi_to_uml.rb'
|
|
142
|
-
- 'lib/lutaml/qea/database.rb'
|
|
143
|
-
- 'lib/lutaml/qea/factory/enum_transformer.rb'
|
|
144
|
-
- 'lib/lutaml/uml_repository/index_builder.rb'
|
|
145
|
-
- 'lib/lutaml/uml_repository/queries/class_query.rb'
|
|
146
|
-
- 'lib/lutaml/uml_repository/queries/inheritance_query.rb'
|
|
147
|
-
- 'lib/lutaml/xmi/parsers/xmi_base.rb'
|
|
145
|
+
Enabled: false
|
|
148
146
|
|
|
149
|
-
# Offense count:
|
|
147
|
+
# Offense count: 3
|
|
150
148
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
|
151
149
|
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
|
|
152
150
|
Naming/MethodParameterName:
|
|
153
151
|
Exclude:
|
|
154
152
|
- 'lib/lutaml/cli/tree_view_formatter.rb'
|
|
155
153
|
- 'lib/lutaml/uml_repository/static_site/generator.rb'
|
|
154
|
+
- 'spec/lutaml/parsers/serialize_xmi_to_liquid_spec.rb'
|
|
156
155
|
|
|
157
156
|
# Offense count: 1
|
|
158
157
|
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
|
|
@@ -162,14 +161,13 @@ Naming/PredicateMethod:
|
|
|
162
161
|
Exclude:
|
|
163
162
|
- 'lib/lutaml/qea/factory/document_builder.rb'
|
|
164
163
|
|
|
165
|
-
# Offense count:
|
|
164
|
+
# Offense count: 3
|
|
166
165
|
# Configuration parameters: MinSize.
|
|
167
166
|
Performance/CollectionLiteralInLoop:
|
|
168
167
|
Exclude:
|
|
169
|
-
- 'lib/lutaml/xmi/parsers/
|
|
168
|
+
- 'lib/lutaml/xmi/parsers/xmi_connector.rb'
|
|
170
169
|
- 'spec/lutaml/qea/infrastructure/table_reader_spec.rb'
|
|
171
170
|
- 'spec/lutaml/uml_repository/index_builder_spec.rb'
|
|
172
|
-
- 'spec/lutaml/uml_repository/queries/inheritance_query_spec.rb'
|
|
173
171
|
|
|
174
172
|
# Offense count: 2
|
|
175
173
|
Performance/MapMethodChain:
|
|
@@ -211,10 +209,10 @@ RSpec/ContextWording:
|
|
|
211
209
|
RSpec/DescribeClass:
|
|
212
210
|
Enabled: false
|
|
213
211
|
|
|
214
|
-
# Offense count:
|
|
212
|
+
# Offense count: 649
|
|
215
213
|
# Configuration parameters: CountAsOne.
|
|
216
214
|
RSpec/ExampleLength:
|
|
217
|
-
Max:
|
|
215
|
+
Max: 30
|
|
218
216
|
|
|
219
217
|
# Offense count: 7
|
|
220
218
|
# This cop supports safe autocorrection (--autocorrect).
|
|
@@ -241,20 +239,6 @@ RSpec/IndexedLet:
|
|
|
241
239
|
- 'spec/lutaml/qea/repositories/base_repository_spec.rb'
|
|
242
240
|
- 'spec/lutaml/qea/repositories/object_repository_spec.rb'
|
|
243
241
|
|
|
244
|
-
# Offense count: 48
|
|
245
|
-
# Configuration parameters: AssignmentOnly.
|
|
246
|
-
RSpec/InstanceVariable:
|
|
247
|
-
Exclude:
|
|
248
|
-
- 'spec/lutaml/parsers/parse_xmi_spec.rb'
|
|
249
|
-
- 'spec/lutaml/qea/verification/comprehensive_equivalence_spec.rb'
|
|
250
|
-
|
|
251
|
-
# Offense count: 2
|
|
252
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
253
|
-
RSpec/IteratedExpectation:
|
|
254
|
-
Exclude:
|
|
255
|
-
- 'spec/lutaml/ea/diagram/layout_engine_spec.rb'
|
|
256
|
-
- 'spec/lutaml/uml_repository/queries/inheritance_query_spec.rb'
|
|
257
|
-
|
|
258
242
|
# Offense count: 15
|
|
259
243
|
RSpec/LeakyConstantDeclaration:
|
|
260
244
|
Exclude:
|
|
@@ -279,19 +263,19 @@ RSpec/MessageSpies:
|
|
|
279
263
|
- 'spec/lutaml/uml_repository/presenters/diagram_presenter_spec.rb'
|
|
280
264
|
- 'spec/lutaml/uml_repository/repository_spec.rb'
|
|
281
265
|
|
|
282
|
-
# Offense count:
|
|
266
|
+
# Offense count: 35
|
|
283
267
|
RSpec/MultipleExpectations:
|
|
284
|
-
Max:
|
|
268
|
+
Max: 6
|
|
285
269
|
|
|
286
|
-
# Offense count:
|
|
270
|
+
# Offense count: 151
|
|
287
271
|
# Configuration parameters: AllowSubject.
|
|
288
272
|
RSpec/MultipleMemoizedHelpers:
|
|
289
273
|
Max: 11
|
|
290
274
|
|
|
291
|
-
# Offense count:
|
|
275
|
+
# Offense count: 35
|
|
292
276
|
# Configuration parameters: AllowedGroups.
|
|
293
277
|
RSpec/NestedGroups:
|
|
294
|
-
Max:
|
|
278
|
+
Max: 4
|
|
295
279
|
|
|
296
280
|
# Offense count: 2
|
|
297
281
|
# Configuration parameters: AllowedPatterns.
|
|
@@ -301,13 +285,12 @@ RSpec/NoExpectationExample:
|
|
|
301
285
|
- 'spec/lutaml/qea/verification/comprehensive_equivalence_spec.rb'
|
|
302
286
|
- 'spec/lutaml/uml_repository/static_site/generator_spec.rb'
|
|
303
287
|
|
|
304
|
-
# Offense count:
|
|
288
|
+
# Offense count: 12
|
|
305
289
|
RSpec/RepeatedExample:
|
|
306
290
|
Exclude:
|
|
307
291
|
- 'spec/lutaml/cli/package_commands_spec.rb'
|
|
308
292
|
- 'spec/lutaml/ea/diagram/svg_renderer_spec.rb'
|
|
309
293
|
- 'spec/lutaml/qea/validation/validation_engine_spec.rb'
|
|
310
|
-
- 'spec/lutaml/uml_repository/presenters/diagram_presenter_spec.rb'
|
|
311
294
|
- 'spec/lutaml/uml_repository/static_site/data_transformer_spec.rb'
|
|
312
295
|
|
|
313
296
|
# Offense count: 2
|
|
@@ -315,7 +298,7 @@ RSpec/RepeatedExampleGroupDescription:
|
|
|
315
298
|
Exclude:
|
|
316
299
|
- 'spec/lutaml/uml/parsers/dsl_spec.rb'
|
|
317
300
|
|
|
318
|
-
# Offense count:
|
|
301
|
+
# Offense count: 5
|
|
319
302
|
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
|
|
320
303
|
# SupportedInflectors: default, active_support
|
|
321
304
|
RSpec/SpecFilePathFormat:
|
|
@@ -323,34 +306,18 @@ RSpec/SpecFilePathFormat:
|
|
|
323
306
|
- 'spec/express/parsers/exp_spec.rb'
|
|
324
307
|
- 'spec/lutaml/parser_qea_spec.rb'
|
|
325
308
|
- 'spec/lutaml/parsers/parse_xmi_spec.rb'
|
|
326
|
-
- 'spec/lutaml/parsers/serialize_generalization_by_name_spec.rb'
|
|
327
309
|
- 'spec/lutaml/parsers/serialize_xmi_to_liquid_spec.rb'
|
|
328
310
|
- 'spec/lutaml/uml_repository/web_ui/app_spec.rb'
|
|
329
311
|
|
|
330
|
-
# Offense count: 6
|
|
331
|
-
RSpec/UnspecifiedException:
|
|
332
|
-
Exclude:
|
|
333
|
-
- 'spec/lutaml/model_transformations/parsers/qea_parser_spec.rb'
|
|
334
|
-
- 'spec/lutaml/model_transformations/parsers/xmi_parser_spec.rb'
|
|
335
|
-
- 'spec/lutaml/model_transformations_spec.rb'
|
|
336
|
-
- 'spec/lutaml/parser_qea_spec.rb'
|
|
337
|
-
- 'spec/lutaml/qea/integration/full_parsing_spec.rb'
|
|
338
|
-
|
|
339
|
-
# Offense count: 212
|
|
340
|
-
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
|
341
|
-
RSpec/VerifiedDoubles:
|
|
342
|
-
Enabled: false
|
|
343
|
-
|
|
344
312
|
# Offense count: 3
|
|
345
313
|
Security/Eval:
|
|
346
314
|
Exclude:
|
|
347
315
|
- 'spec/lutaml/cli/uml/search_command_spec.rb'
|
|
348
316
|
|
|
349
|
-
# Offense count:
|
|
317
|
+
# Offense count: 2
|
|
350
318
|
Security/MarshalLoad:
|
|
351
319
|
Exclude:
|
|
352
320
|
- 'lib/lutaml/uml_repository/package_loader.rb'
|
|
353
|
-
- 'spec/lutaml/uml_repository/package_exporter_spec.rb'
|
|
354
321
|
|
|
355
322
|
# Offense count: 2
|
|
356
323
|
# This cop supports safe autocorrection (--autocorrect).
|
|
@@ -369,11 +336,18 @@ Style/EvalWithLocation:
|
|
|
369
336
|
Exclude:
|
|
370
337
|
- 'spec/lutaml/cli/uml/search_command_spec.rb'
|
|
371
338
|
|
|
339
|
+
# Offense count: 1
|
|
340
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
341
|
+
# Configuration parameters: AllowMethodComparison, ComparisonsThreshold.
|
|
342
|
+
Style/MultipleComparison:
|
|
343
|
+
Exclude:
|
|
344
|
+
- 'lib/lutaml/cli/interactive_shell.rb'
|
|
345
|
+
|
|
372
346
|
# Offense count: 1
|
|
373
347
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
374
348
|
Style/PartitionInsteadOfDoubleSelect:
|
|
375
349
|
Exclude:
|
|
376
|
-
- 'lib/lutaml/qea/factory/
|
|
350
|
+
- 'lib/lutaml/qea/factory/generalization_builder.rb'
|
|
377
351
|
|
|
378
352
|
# Offense count: 3
|
|
379
353
|
# Configuration parameters: Max.
|
|
@@ -381,3 +355,19 @@ Style/SafeNavigationChainLength:
|
|
|
381
355
|
Exclude:
|
|
382
356
|
- 'lib/lutaml/qea/validation/attribute_validator.rb'
|
|
383
357
|
- 'lib/lutaml/qea/validation/operation_validator.rb'
|
|
358
|
+
|
|
359
|
+
# Offense count: 1
|
|
360
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
361
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
|
362
|
+
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
363
|
+
Style/TrailingCommaInArguments:
|
|
364
|
+
Exclude:
|
|
365
|
+
- 'lib/lutaml/qea/factory/class_transformer.rb'
|
|
366
|
+
|
|
367
|
+
# Offense count: 2
|
|
368
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
369
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
|
370
|
+
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
371
|
+
Style/TrailingCommaInHashLiteral:
|
|
372
|
+
Exclude:
|
|
373
|
+
- 'lib/lutaml/cli/interactive_shell.rb'
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# 01 — Resolve 7 production TODOs
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
Seven `TODO`/`FIXME` comments in `lib/` represent incomplete features, missing validation, or known tech debt. They risk silent data loss or incorrect behavior.
|
|
6
|
+
|
|
7
|
+
## Items
|
|
8
|
+
|
|
9
|
+
### 1. `lib/lutaml/qea/factory/diagram_transformer.rb:28`
|
|
10
|
+
```ruby
|
|
11
|
+
# TODO: Fix diagram_type assignment -
|
|
12
|
+
# lutaml-model compatibility issue
|
|
13
|
+
# diagram.diagram_type = ea_diagram.diagram_type
|
|
14
|
+
```
|
|
15
|
+
**Impact**: Diagram type is silently dropped during QEA→UML transformation. The `diagram_type` attribute exists on `Lutaml::Uml::Diagram` but is never populated from QEA.
|
|
16
|
+
**Fix**: Investigate lutaml-model compatibility (likely a type mismatch or missing attribute). Either fix the assignment or document why it's intentionally omitted.
|
|
17
|
+
|
|
18
|
+
### 2. `lib/lutaml/qea/factory/package_transformer.rb:32`
|
|
19
|
+
```ruby
|
|
20
|
+
# TODO: Fix tagged_values assignment - temporarily commented out
|
|
21
|
+
# pkg.tagged_values = load_tagged_values(ea_package.ea_guid)
|
|
22
|
+
```
|
|
23
|
+
**Impact**: Tagged values (metadata/annotations) are silently dropped from packages during QEA→UML transformation. This causes XMI/QEA equivalence mismatches.
|
|
24
|
+
**Fix**: Check if `load_tagged_values` returns correct type. Likely needs the same serialization pattern used in class_transformer.
|
|
25
|
+
|
|
26
|
+
### 3. `lib/lutaml/formatter/graphviz.rb:56`
|
|
27
|
+
```ruby
|
|
28
|
+
# TODO: set rankdir
|
|
29
|
+
# @graph['rankdir'] = 'BT'
|
|
30
|
+
```
|
|
31
|
+
**Impact**: Graph direction can't be configured. The value is commented out.
|
|
32
|
+
**Fix**: Either expose as configurable option or remove dead code.
|
|
33
|
+
|
|
34
|
+
### 4. `lib/lutaml/uml/node/class_node.rb:19`
|
|
35
|
+
```ruby
|
|
36
|
+
@modifier = value.to_s # TODO: Validate?
|
|
37
|
+
```
|
|
38
|
+
**Impact**: No validation on modifier values — invalid strings accepted silently.
|
|
39
|
+
**Fix**: Add enum validation for known modifiers (`public`, `private`, `protected`, etc.) or remove the TODO if validation isn't needed.
|
|
40
|
+
|
|
41
|
+
### 5. `lib/lutaml/uml/node/attribute.rb:27`
|
|
42
|
+
```ruby
|
|
43
|
+
@access = value.to_s # TODO: Validate?
|
|
44
|
+
```
|
|
45
|
+
**Impact**: Same as #4 but for access modifiers on attributes.
|
|
46
|
+
**Fix**: Same as #4 — validate or remove TODO.
|
|
47
|
+
|
|
48
|
+
### 6. `lib/lutaml/uml/node/class_node.rb:24`
|
|
49
|
+
```ruby
|
|
50
|
+
type = member.to_a[0][0] # TODO: This is dumb
|
|
51
|
+
```
|
|
52
|
+
**Impact**: Fragile parsing of member data structure. The `TODO: This is dumb` indicates the developer knew it was wrong but shipped it.
|
|
53
|
+
**Fix**: Replace with structured member parsing using named access.
|
|
54
|
+
|
|
55
|
+
### 7. `lib/lutaml/uml/has_members.rb:8`
|
|
56
|
+
```ruby
|
|
57
|
+
# TODO: move to Parslet::Transform
|
|
58
|
+
```
|
|
59
|
+
**Impact**: Member type logic is in the model instead of the parser layer.
|
|
60
|
+
**Fix**: Evaluate whether moving to Parslet::Transform is still desirable. If not, remove the TODO.
|
|
61
|
+
|
|
62
|
+
## Verification
|
|
63
|
+
|
|
64
|
+
- `grep -rn "TODO\|FIXME" lib/ --include="*.rb"` should return 0 results (or only intentional ones)
|
|
65
|
+
- Full test suite passes: `bundle exec rspec`
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# 02 — Reduce Metrics/AbcSize and method complexity (212 + 130 + 11 + 11 + 8 offenses)
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
5 Metrics cops account for **372 offenses** across production code. The worst offenders are large methods that do too much, making them hard to test, debug, and maintain.
|
|
6
|
+
|
|
7
|
+
## Top targets by file
|
|
8
|
+
|
|
9
|
+
| File | AbcSize | MethodLength | Cyclomatic | Perceived | Lines |
|
|
10
|
+
|------|---------|-------------|------------|-----------|-------|
|
|
11
|
+
| `lib/lutaml/xmi/parsers/xmi_base.rb` | Yes | — | Yes | Yes | 1047 |
|
|
12
|
+
| `lib/lutaml/converter/xmi_to_uml.rb` | Yes | — | Yes | Yes | 474 |
|
|
13
|
+
| `lib/lutaml/uml_repository/index_builder.rb` | Yes | — | Yes | Yes | 480 |
|
|
14
|
+
| `lib/lutaml/qea/database.rb` | Yes | — | Yes | Yes | 477 |
|
|
15
|
+
| `lib/lutaml/uml_repository/queries/class_query.rb` | Yes | — | Yes | Yes | 151 |
|
|
16
|
+
| `lib/lutaml/uml_repository/queries/inheritance_query.rb` | Yes | — | Yes | Yes | — |
|
|
17
|
+
| `lib/lutaml/model_transformations/parsers/base_parser.rb` | Yes | — | — | — | — |
|
|
18
|
+
| `lib/lutaml/qea/factory/enum_transformer.rb` | — | — | Yes | Yes | — |
|
|
19
|
+
| `lib/lutaml/uml_repository/queries/search_query.rb` | — | — | Yes | — | — |
|
|
20
|
+
| `lib/lutaml/cli/tree_view_formatter.rb` | — | — | Yes | — | — |
|
|
21
|
+
|
|
22
|
+
## Approach
|
|
23
|
+
|
|
24
|
+
Extract helper methods from god methods. Common patterns:
|
|
25
|
+
|
|
26
|
+
1. **xmi_base.rb** — The 1047-line file has massive parsing methods. Extract per-element-type parsing into separate methods (already partially done).
|
|
27
|
+
2. **converter/xmi_to_uml.rb** — The `build_*` methods handle too many concerns. Extract mapping logic per element type.
|
|
28
|
+
3. **index_builder.rb** — The single-pass `build_all` is better than before but individual index builders can be further split.
|
|
29
|
+
4. **database.rb** — The `build_lookup_indexes` method builds all indexes at once; split into per-index methods.
|
|
30
|
+
|
|
31
|
+
**Do NOT**: Increase Max thresholds in `.rubocop_todo.yml`. Instead, refactor to reduce actual complexity.
|
|
32
|
+
|
|
33
|
+
## Verification
|
|
34
|
+
|
|
35
|
+
- `bundle exec rubocop --only Metrics` shows reduced offense counts
|
|
36
|
+
- `bundle exec rspec` passes
|
|
37
|
+
- No functional changes — pure refactoring
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 03 — Reduce RSpec/MultipleExpectations (946 offenses)
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
946 test examples have more than 1 expectation. This is the single largest rubocop offense. It makes tests brittle (failures stop at the first failed expectation, masking other issues) and harder to understand what's being verified.
|
|
6
|
+
|
|
7
|
+
## Approach
|
|
8
|
+
|
|
9
|
+
Split multi-expectation examples into focused single-expectation examples:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
# BEFORE:
|
|
13
|
+
it "validates the widget" do
|
|
14
|
+
expect(widget.name).to eq("Test")
|
|
15
|
+
expect(widget.size).to eq(10)
|
|
16
|
+
expect(widget.active).to be true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# AFTER:
|
|
20
|
+
it { expect(widget.name).to eq("Test") }
|
|
21
|
+
it { expect(widget.size).to eq(10) }
|
|
22
|
+
it { expect(widget.active).to be true }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For cases where multiple expectations are genuinely related (e.g., checking a hash structure), use compound matchers:
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
expect(result).to include("name" => "Test", "size" => 10, "active" => true)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or aggregate failures with `aggregate_failures` when the expectations are about the same concern:
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
it "has correct address fields" do
|
|
35
|
+
aggregate_failures do
|
|
36
|
+
expect(address.street).to eq("Main St")
|
|
37
|
+
expect(address.city).to eq("London")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Priority files (highest offense density)
|
|
43
|
+
|
|
44
|
+
Run `bundle exec rubocop --only RSpec/MultipleExpectations` to see the full list. Focus on:
|
|
45
|
+
1. `spec/lutaml/qea/verification/comprehensive_equivalence_spec.rb`
|
|
46
|
+
2. `spec/lutaml/qea/verification/equivalence_integration_spec.rb`
|
|
47
|
+
3. `spec/lutaml/cli/` command specs
|
|
48
|
+
4. `spec/lutaml/uml_repository/` specs
|
|
49
|
+
|
|
50
|
+
## Verification
|
|
51
|
+
|
|
52
|
+
- `bundle exec rubocop --only RSpec/MultipleExpectations` shows reduced count
|
|
53
|
+
- `bundle exec rspec` passes
|
|
54
|
+
- Reduce Max from 26 toward 5 (default)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# 04 — Reduce RSpec/ExampleLength (657 offenses)
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
657 test examples exceed the default 5-line limit (current Max: 108). Long examples are hard to read, hide intent, and often combine setup + action + multiple assertions.
|
|
6
|
+
|
|
7
|
+
## Approach
|
|
8
|
+
|
|
9
|
+
Common patterns to fix:
|
|
10
|
+
|
|
11
|
+
1. **Extract test data into `let`/`let!`** — Move setup out of `it` blocks:
|
|
12
|
+
```ruby
|
|
13
|
+
# BEFORE:
|
|
14
|
+
it "parses correctly" do
|
|
15
|
+
result = described_class.parse(fixture_content)
|
|
16
|
+
expect(result.name).to eq("Test")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# AFTER:
|
|
20
|
+
let(:result) { described_class.parse(fixture_content) }
|
|
21
|
+
it { expect(result.name).to eq("Test") }
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
2. **Extract shared setup into `before` blocks** — If multiple examples repeat the same setup.
|
|
25
|
+
|
|
26
|
+
3. **Use subject with one-liner syntax** — Where the subject is the tested value:
|
|
27
|
+
```ruby
|
|
28
|
+
subject { described_class.new(attrs) }
|
|
29
|
+
it { is_expected.to be_valid }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
4. **Extract helper methods** — Complex assertions that span many lines can become custom matchers or helper methods in `spec/support/`.
|
|
33
|
+
|
|
34
|
+
## Priority
|
|
35
|
+
|
|
36
|
+
Focus on the longest examples first — run `bundle exec rubocop --only RSpec/ExampleLength` and sort by severity. Files with the worst examples:
|
|
37
|
+
- `spec/lutaml/qea/` verification and factory specs
|
|
38
|
+
- `spec/lutaml/uml_repository/` static site specs
|
|
39
|
+
- `spec/lutaml/cli/` command specs
|
|
40
|
+
|
|
41
|
+
## Verification
|
|
42
|
+
|
|
43
|
+
- `bundle exec rubocop --only RSpec/ExampleLength` shows reduced count
|
|
44
|
+
- Reduce Max from 108 toward 10
|
|
45
|
+
- `bundle exec rspec` passes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# 05 — Replace Marshal.load with safe deserialization (4 offenses)
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
`Marshal.load` is flagged by `Security/MarshalLoad` because deserializing untrusted data can lead to remote code execution. The gem uses it in the `.lur` package format (a ZIP file containing serialized Ruby objects).
|
|
6
|
+
|
|
7
|
+
## Affected files
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
# lib/lutaml/uml_repository/package_loader.rb:194
|
|
11
|
+
Marshal.load(entry.get_input_stream.read)
|
|
12
|
+
|
|
13
|
+
# lib/lutaml/uml_repository/package_loader.rb:210
|
|
14
|
+
Marshal.load(entry.get_input_stream.read)
|
|
15
|
+
|
|
16
|
+
# spec/lutaml/uml_repository/package_exporter_spec.rb:141
|
|
17
|
+
expect { Marshal.load(serialized) }.not_to raise_error
|
|
18
|
+
|
|
19
|
+
# spec/lutaml/uml_repository/package_exporter_spec.rb:171
|
|
20
|
+
expect { Marshal.load(serialized) }.not_to raise_error
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Approach
|
|
24
|
+
|
|
25
|
+
**Option A: Switch to JSON serialization** — Replace `Marshal.dump`/`Marshal.load` with `JSON.generate`/`JSON.parse` in `PackageExporter` and `PackageLoader`. This is safe but requires models to be JSON-serializable.
|
|
26
|
+
|
|
27
|
+
**Option B: Use YAML with permitted classes** — `YAML.safe_load` with an explicit allowlist of classes. More flexible but still requires maintaining the class list.
|
|
28
|
+
|
|
29
|
+
**Option C: Keep Marshal but document the trust boundary** — If `.lur` files are only ever created by the gem itself (trusted), the risk is mitigated. Add a clear comment at the load site and suppress the cop with justification.
|
|
30
|
+
|
|
31
|
+
**Recommended**: Option A if feasible (cleanest), Option C as a minimal fix.
|
|
32
|
+
|
|
33
|
+
## Verification
|
|
34
|
+
|
|
35
|
+
- `bundle exec rubocop --only Security/MarshalLoad` shows 0 offenses
|
|
36
|
+
- `.lur` package round-trip (export → load) works correctly
|
|
37
|
+
- `bundle exec rspec` passes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 06 — Replace eval in tests with StringIO redirection (3 Security/Eval + 2 Style/EvalWithLocation + 2 Style/DocumentDynamicEvalDefinition)
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
`spec/lutaml/cli/uml/search_command_spec.rb` uses `eval` to redirect `$stdout`/`$stderr` for capturing output. This triggers 7 rubocop offenses across Security and Style cops.
|
|
6
|
+
|
|
7
|
+
## Affected code
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
# spec/lutaml/cli/uml/search_command_spec.rb:61-65
|
|
11
|
+
old_stream = eval(stream_var.to_s)
|
|
12
|
+
eval("#{stream_var} = StringIO.new")
|
|
13
|
+
# ...
|
|
14
|
+
eval("#{stream_var} = old_stream") if defined?(old_stream) && old_stream
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Fix
|
|
18
|
+
|
|
19
|
+
Replace with a standard output capture pattern:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
# Use RSpec's built-in output matcher:
|
|
23
|
+
expect { command.run }.to output(/expected text/).to_stdout
|
|
24
|
+
|
|
25
|
+
# Or use a capture helper:
|
|
26
|
+
def capture_output
|
|
27
|
+
old_stdout = $stdout
|
|
28
|
+
$stdout = StringIO.new
|
|
29
|
+
yield
|
|
30
|
+
$stdout.string
|
|
31
|
+
ensure
|
|
32
|
+
$stdout = old_stdout
|
|
33
|
+
end
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
No `eval` needed — just use `$stdout` directly instead of dynamically resolving the variable name.
|
|
37
|
+
|
|
38
|
+
## Verification
|
|
39
|
+
|
|
40
|
+
- `bundle exec rubocop --only Security/Eval,Style/EvalWithLocation,Style/DocumentDynamicEvalDefinition` shows 0 offenses
|
|
41
|
+
- `bundle exec rspec spec/lutaml/cli/uml/search_command_spec.rb` passes
|