coradoc 2.0.1 → 2.0.2

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +55 -167
  3. data/coradoc-adoc/lib/coradoc/asciidoc/model/base.rb +4 -3
  4. data/coradoc-adoc/lib/coradoc/asciidoc/model/document.rb +1 -1
  5. data/coradoc-adoc/lib/coradoc/asciidoc/model/include.rb +1 -1
  6. data/coradoc-adoc/lib/coradoc/asciidoc/model/resolver.rb +2 -2
  7. data/coradoc-adoc/lib/coradoc/asciidoc/model/serialization/asciidoc_transform.rb +3 -3
  8. data/coradoc-adoc/lib/coradoc/asciidoc/model/table_row.rb +1 -1
  9. data/coradoc-adoc/lib/coradoc/asciidoc/model/text_element.rb +4 -8
  10. data/coradoc-adoc/lib/coradoc/asciidoc/parse_error.rb +6 -6
  11. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/adoc_serializer.rb +5 -10
  12. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/formatter.rb +4 -3
  13. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/base.rb +8 -20
  14. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/block/core.rb +1 -1
  15. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document.rb +3 -6
  16. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/inline/strikethrough.rb +1 -1
  17. data/coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/list/item.rb +5 -9
  18. data/coradoc-adoc/lib/coradoc/asciidoc/transform/from_core_model.rb +26 -34
  19. data/coradoc-adoc/lib/coradoc/asciidoc/transform/from_core_model_registrations.rb +18 -18
  20. data/coradoc-adoc/lib/coradoc/asciidoc/transform/to_core_model.rb +96 -123
  21. data/coradoc-adoc/lib/coradoc/asciidoc/transform/to_core_model_registrations.rb +10 -6
  22. data/coradoc-adoc/lib/coradoc/asciidoc/transformer/header_rules.rb +5 -5
  23. data/coradoc-adoc/lib/coradoc/asciidoc/transformer/list_rules.rb +2 -2
  24. data/coradoc-adoc/lib/coradoc/asciidoc/transformer/structural_rules.rb +1 -1
  25. data/coradoc-adoc/lib/coradoc/asciidoc/transformer.rb +5 -5
  26. data/coradoc-adoc/lib/coradoc/asciidoc.rb +1 -1
  27. data/coradoc-adoc/lib/coradoc/util/asciidoc.rb +4 -3
  28. data/coradoc-adoc/spec/coradoc/asciidoc/transform/from_core_model_spec.rb +4 -2
  29. data/coradoc-docx/lib/coradoc/docx/transform/rules/run_rule.rb +4 -1
  30. data/coradoc-docx/lib/coradoc/docx/transform/rules/simple_field_rule.rb +5 -1
  31. data/coradoc-docx/lib/coradoc/docx/transform/rules/table_rule.rb +0 -1
  32. data/coradoc-docx/lib/coradoc/docx.rb +6 -4
  33. data/coradoc-docx/spec/coradoc/docx/transform/from_core_model_spec.rb +5 -2
  34. data/coradoc-docx/spec/coradoc/docx/transform/rules/rule_unit_spec.rb +27 -7
  35. data/coradoc-docx/spec/coradoc/docx/transform/to_core_model_spec.rb +6 -2
  36. data/coradoc-html/lib/coradoc/html/converters/base.rb +4 -1
  37. data/coradoc-html/lib/coradoc/html.rb +1 -1
  38. data/coradoc-markdown/lib/coradoc/markdown/transform/from_core_model.rb +2 -2
  39. data/coradoc-markdown/lib/coradoc/markdown.rb +1 -1
  40. data/lib/coradoc/configurable.rb +6 -2
  41. data/lib/coradoc/coradoc.rb +18 -16
  42. data/lib/coradoc/core_model/base.rb +3 -3
  43. data/lib/coradoc/core_model/list_item.rb +3 -3
  44. data/lib/coradoc/core_model/toc_generator.rb +1 -1
  45. data/lib/coradoc/document_manipulator.rb +9 -13
  46. data/lib/coradoc/format_module.rb +16 -4
  47. data/lib/coradoc/input.rb +1 -1
  48. data/lib/coradoc/output.rb +1 -1
  49. data/lib/coradoc/query.rb +38 -186
  50. data/lib/coradoc/registry.rb +5 -7
  51. data/lib/coradoc/serializer/registry.rb +3 -5
  52. data/lib/coradoc/validation.rb +40 -21
  53. data/lib/coradoc/version.rb +1 -1
  54. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 728aadf584ed71846c925bd918143307f1a67c1c50b03e1d088dc232578a92d4
4
- data.tar.gz: 8588d96dc42f3710f6103220f150bedd86b6f445ddb9aa142f2af3322b1cb766
3
+ metadata.gz: b2a167bf671c487f25b37d0df4019bee6bd324636fdf9a681b799764f4a14b2d
4
+ data.tar.gz: 89345da1186b5ad1fc3ed0315b536a09e445015b1744094fd3ff187382023818
5
5
  SHA512:
6
- metadata.gz: e88d156f5149cddb4f5f3f70765dfc67e4b0f8f44537034f0ea9bd55ef1553a2092a6edf2aa8ec51e0bca5e9622bc3e18da6680ef0aa7b4610eabdcdccf283c9
7
- data.tar.gz: 500056c39061e779033c830560c16026828e881f55f13ae97ebcf42d7d6acb4ef1a9383cfa628b126bfe5c6ad4357459b102b9fba12a1ce4f8396255861614cf
6
+ metadata.gz: 5a7ead748469ceecbe303de9fd0e65b0081c4765cb8cda371f11cdd76173dcb60372f89ff2c5fc1d30b74fab0bff349fd0149b62ddd65df5b944a350dea14cc9
7
+ data.tar.gz: 41c5de35c416b7bfcc74ba8043bc26771e4bc8a332f59211de6f0c7f6bae7019fa096458ab705bd7e54b0c248c352df70c04467679f156c315e02c00ef4fdf5d
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-04-22 10:56:31 UTC using RuboCop version 1.75.8.
3
+ # on 2026-05-06 19:17:34 UTC using RuboCop version 1.75.8.
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
@@ -15,42 +15,6 @@ Gemspec/RequiredRubyVersion:
15
15
  - 'coradoc-html/coradoc-html.gemspec'
16
16
  - 'coradoc.gemspec'
17
17
 
18
- # Offense count: 1
19
- # This cop supports safe autocorrection (--autocorrect).
20
- # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
21
- # SupportedStyles: case, end
22
- Layout/CaseIndentation:
23
- Exclude:
24
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
25
-
26
- # Offense count: 1
27
- # This cop supports safe autocorrection (--autocorrect).
28
- # Configuration parameters: AllowForAlignment.
29
- Layout/CommentIndentation:
30
- Exclude:
31
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
32
-
33
- # Offense count: 2
34
- # This cop supports safe autocorrection (--autocorrect).
35
- Layout/ElseAlignment:
36
- Exclude:
37
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
38
-
39
- # Offense count: 1
40
- # This cop supports safe autocorrection (--autocorrect).
41
- # Configuration parameters: EnforcedStyleAlignWith, Severity.
42
- # SupportedStylesAlignWith: keyword, variable, start_of_line
43
- Layout/EndAlignment:
44
- Exclude:
45
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
46
-
47
- # Offense count: 4
48
- # This cop supports safe autocorrection (--autocorrect).
49
- # Configuration parameters: Width, AllowedPatterns.
50
- Layout/IndentationWidth:
51
- Exclude:
52
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
53
-
54
18
  # Offense count: 6
55
19
  # This cop supports safe autocorrection (--autocorrect).
56
20
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
@@ -58,33 +22,11 @@ Layout/IndentationWidth:
58
22
  Layout/LineLength:
59
23
  Max: 235
60
24
 
61
- # Offense count: 2
62
- # This cop supports safe autocorrection (--autocorrect).
63
- # Configuration parameters: EnforcedStyle, IndentationWidth.
64
- # SupportedStyles: aligned, indented, indented_relative_to_receiver
65
- Layout/MultilineMethodCallIndentation:
66
- Exclude:
67
- - 'coradoc-html/lib/coradoc/html/input/converters/h.rb'
68
-
69
- # Offense count: 1
70
- # This cop supports safe autocorrection (--autocorrect).
71
- # Configuration parameters: AllowInHeredoc.
72
- Layout/TrailingWhitespace:
73
- Exclude:
74
- - 'lib/coradoc/normalize.rb'
75
-
76
25
  # Offense count: 1
77
26
  Lint/BinaryOperatorWithIdenticalOperands:
78
27
  Exclude:
79
28
  - 'coradoc-html/lib/coradoc/html/converters/attribute_reference.rb'
80
29
 
81
- # Offense count: 2
82
- # Configuration parameters: AllowedMethods.
83
- # AllowedMethods: enums
84
- Lint/ConstantDefinitionInBlock:
85
- Exclude:
86
- - 'spec/transform/helpers_spec.rb'
87
-
88
30
  # Offense count: 3
89
31
  # This cop supports safe autocorrection (--autocorrect).
90
32
  # Configuration parameters: AutoCorrect, AllowComments.
@@ -100,12 +42,11 @@ Lint/EmptyWhen:
100
42
  Exclude:
101
43
  - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
102
44
 
103
- # Offense count: 7
45
+ # Offense count: 6
104
46
  Lint/IneffectiveAccessModifier:
105
47
  Exclude:
106
48
  - 'coradoc-html/lib/coradoc/html/spa.rb'
107
49
  - 'coradoc-html/lib/coradoc/html/static.rb'
108
- - 'lib/coradoc/configurable.rb'
109
50
 
110
51
  # Offense count: 4
111
52
  # Configuration parameters: AllowedParentClasses.
@@ -134,13 +75,17 @@ Lint/UnderscorePrefixedVariableName:
134
75
  - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/title.rb'
135
76
  - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/video.rb'
136
77
 
137
- # Offense count: 4
78
+ # Offense count: 1
79
+ Lint/UnreachableCode:
80
+ Exclude:
81
+ - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/adoc_serializer.rb'
82
+
83
+ # Offense count: 3
138
84
  # This cop supports safe autocorrection (--autocorrect).
139
85
  # Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
140
86
  # NotImplementedExceptions: NotImplementedError
141
87
  Lint/UnusedMethodArgument:
142
88
  Exclude:
143
- - 'lib/coradoc/performance_regression.rb'
144
89
  - 'lib/coradoc/query.rb'
145
90
  - 'lib/coradoc/serializer/registry.rb'
146
91
 
@@ -151,12 +96,12 @@ Lint/Void:
151
96
  Exclude:
152
97
  - 'coradoc-html/lib/coradoc/html.rb'
153
98
 
154
- # Offense count: 240
99
+ # Offense count: 237
155
100
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
156
101
  Metrics/AbcSize:
157
102
  Max: 178
158
103
 
159
- # Offense count: 14
104
+ # Offense count: 15
160
105
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
161
106
  # AllowedMethods: refine
162
107
  Metrics/BlockLength:
@@ -172,31 +117,31 @@ Metrics/BlockNesting:
172
117
  Metrics/ClassLength:
173
118
  Max: 556
174
119
 
175
- # Offense count: 191
120
+ # Offense count: 186
176
121
  # Configuration parameters: AllowedMethods, AllowedPatterns.
177
122
  Metrics/CyclomaticComplexity:
178
- Max: 33
123
+ Max: 32
179
124
 
180
- # Offense count: 398
125
+ # Offense count: 383
181
126
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
182
127
  Metrics/MethodLength:
183
128
  Max: 246
184
129
 
185
- # Offense count: 22
130
+ # Offense count: 21
186
131
  # Configuration parameters: CountComments, CountAsOne.
187
132
  Metrics/ModuleLength:
188
133
  Max: 2128
189
134
 
190
- # Offense count: 6
135
+ # Offense count: 4
191
136
  # Configuration parameters: CountKeywordArgs.
192
137
  Metrics/ParameterLists:
193
- Max: 8
138
+ Max: 7
194
139
  MaxOptionalParameters: 4
195
140
 
196
- # Offense count: 134
141
+ # Offense count: 125
197
142
  # Configuration parameters: AllowedMethods, AllowedPatterns.
198
143
  Metrics/PerceivedComplexity:
199
- Max: 28
144
+ Max: 27
200
145
 
201
146
  # Offense count: 2
202
147
  Naming/AccessorMethodName:
@@ -219,11 +164,13 @@ Naming/MethodName:
219
164
  Exclude:
220
165
  - 'coradoc-markdown/lib/coradoc/markdown.rb'
221
166
 
222
- # Offense count: 18
167
+ # Offense count: 17
223
168
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
224
169
  # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
225
170
  Naming/MethodParameterName:
226
171
  Exclude:
172
+ - 'coradoc-docx/lib/coradoc/docx/transform/from_core_model.rb'
173
+ - 'coradoc-docx/lib/coradoc/docx/transform/rules/run_rule.rb'
227
174
  - 'coradoc-html/lib/coradoc/html/converters/base.rb'
228
175
  - 'coradoc-markdown/lib/coradoc/markdown/parser/block_parser.rb'
229
176
  - 'coradoc-markdown/lib/coradoc/markdown/parser/inline_parser.rb'
@@ -231,9 +178,8 @@ Naming/MethodParameterName:
231
178
  - 'coradoc-markdown/lib/coradoc/markdown/transform/from_core_model.rb'
232
179
  - 'coradoc-markdown/lib/coradoc/markdown/transform/to_core_model.rb'
233
180
  - 'coradoc-markdown/lib/coradoc/markdown/transformer.rb'
234
- - 'lib/coradoc/lazy.rb'
235
181
 
236
- # Offense count: 13
182
+ # Offense count: 10
237
183
  # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
238
184
  # NamePrefix: is_, has_, have_, does_
239
185
  # ForbiddenPrefixes: is_, has_, have_, does_
@@ -246,8 +192,6 @@ Naming/PredicateName:
246
192
  - 'coradoc-html/lib/coradoc/html/entity.rb'
247
193
  - 'coradoc-markdown/lib/coradoc/markdown/parser/parslet_extras.rb'
248
194
  - 'lib/coradoc/core_model/builder/detection.rb'
249
- - 'lib/coradoc/extensions.rb'
250
- - 'lib/coradoc/streaming.rb'
251
195
  - 'utils/parser_analyzer.rb'
252
196
 
253
197
  # Offense count: 3
@@ -265,48 +209,30 @@ RSpec/BeforeAfterAll:
265
209
  - '**/spec/support/**/*.rb'
266
210
  - 'spec/benchmark/performance_spec.rb'
267
211
 
268
- # Offense count: 14
212
+ # Offense count: 19
269
213
  # Configuration parameters: IgnoredMetadata.
270
214
  RSpec/DescribeClass:
271
- Exclude:
272
- - '**/spec/features/**/*'
273
- - '**/spec/requests/**/*'
274
- - '**/spec/routing/**/*'
275
- - '**/spec/system/**/*'
276
- - '**/spec/views/**/*'
277
- - 'coradoc-adoc/spec/coradoc/asciidoc/list_continuation_spec.rb'
278
- - 'coradoc-adoc/spec/coradoc/asciidoc/parser/parser_spec.rb'
279
- - 'coradoc-docx/spec/integration/docx_to_adoc_spec.rb'
280
- - 'coradoc-html/spec/coradoc/html/converters/paragraph_e2e_spec.rb'
281
- - 'coradoc-html/spec/coradoc/html/output_integration_spec.rb'
282
- - 'coradoc-markdown/spec/kramdown_test_suite_spec.rb'
283
- - 'coradoc-markdown/spec/model/abbreviation_spec.rb'
284
- - 'coradoc-markdown/spec/model/auto_id_spec.rb'
285
- - 'coradoc-markdown/spec/model/definition_list_spec.rb'
286
- - 'coradoc-markdown/spec/model/footnote_spec.rb'
287
- - 'spec/benchmark/performance_spec.rb'
288
- - 'spec/coradoc/document_manipulator_spec.rb'
289
- - 'spec/integration/cross_format_spec.rb'
215
+ Enabled: false
290
216
 
291
- # Offense count: 476
217
+ # Offense count: 485
292
218
  # Configuration parameters: CountAsOne.
293
219
  RSpec/ExampleLength:
294
- Max: 34
220
+ Max: 36
295
221
 
296
- # Offense count: 8
222
+ # Offense count: 3
297
223
  # This cop supports safe autocorrection (--autocorrect).
298
224
  RSpec/ExpectActual:
299
225
  Exclude:
300
226
  - '**/spec/routing/**/*'
301
227
  - 'coradoc-markdown/spec/model/abbreviation_spec.rb'
302
- - 'spec/plugin_discovery_spec.rb'
228
+ - 'spec/coradoc/api_spec.rb'
303
229
 
304
230
  # Offense count: 1
305
231
  RSpec/IdenticalEqualityAssertion:
306
232
  Exclude:
307
233
  - 'spec/registry_spec.rb'
308
234
 
309
- # Offense count: 38
235
+ # Offense count: 36
310
236
  # Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
311
237
  RSpec/IndexedLet:
312
238
  Exclude:
@@ -319,27 +245,17 @@ RSpec/IndexedLet:
319
245
  - 'spec/core_model/structural_element_spec.rb'
320
246
  - 'spec/core_model/table_spec.rb'
321
247
  - 'spec/core_model/term_spec.rb'
322
- - 'spec/lazy_spec.rb'
323
248
 
324
- # Offense count: 14
249
+ # Offense count: 30
325
250
  # Configuration parameters: AssignmentOnly.
326
251
  RSpec/InstanceVariable:
327
252
  Exclude:
253
+ - 'coradoc-docx/spec/coradoc/docx/transform/from_core_model_spec.rb'
254
+ - 'coradoc-docx/spec/integration/builder_fixture_spec.rb'
328
255
  - 'spec/input_spec.rb'
329
256
  - 'spec/output_spec.rb'
330
257
 
331
- # Offense count: 1
332
- # This cop supports safe autocorrection (--autocorrect).
333
- RSpec/IteratedExpectation:
334
- Exclude:
335
- - 'spec/plugin_discovery_spec.rb'
336
-
337
- # Offense count: 5
338
- RSpec/LeakyConstantDeclaration:
339
- Exclude:
340
- - 'spec/transform/helpers_spec.rb'
341
-
342
- # Offense count: 8
258
+ # Offense count: 9
343
259
  # Configuration parameters: .
344
260
  # SupportedStyles: have_received, receive
345
261
  RSpec/MessageSpies:
@@ -349,7 +265,7 @@ RSpec/MessageSpies:
349
265
  RSpec/MultipleDescribes:
350
266
  Enabled: false
351
267
 
352
- # Offense count: 599
268
+ # Offense count: 613
353
269
  RSpec/MultipleExpectations:
354
270
  Max: 12
355
271
 
@@ -371,19 +287,13 @@ RSpec/NamedSubject:
371
287
  - 'coradoc-markdown/spec/parser/markdown_spec.rb'
372
288
  - 'spec/visitor_spec.rb'
373
289
 
374
- # Offense count: 1
375
- # Configuration parameters: AllowedGroups.
376
- RSpec/NestedGroups:
377
- Max: 4
378
-
379
- # Offense count: 4
290
+ # Offense count: 3
380
291
  # Configuration parameters: AllowedPatterns.
381
292
  # AllowedPatterns: ^expect_, ^assert_
382
293
  RSpec/NoExpectationExample:
383
294
  Exclude:
384
295
  - 'coradoc-html/spec/coradoc/html/converters/paragraph_e2e_spec.rb'
385
296
  - 'coradoc-markdown/spec/parser/markdown_spec.rb'
386
- - 'spec/streaming_spec.rb'
387
297
 
388
298
  # Offense count: 2
389
299
  RSpec/RepeatedDescription:
@@ -395,34 +305,31 @@ RSpec/RepeatedExample:
395
305
  Exclude:
396
306
  - 'coradoc-html/spec/coradoc/html/converters/paragraph_e2e_spec.rb'
397
307
 
308
+ # Offense count: 2
309
+ RSpec/RepeatedExampleGroupBody:
310
+ Exclude:
311
+ - 'spec/coradoc/api_spec.rb'
312
+
398
313
  # Offense count: 2
399
314
  RSpec/RepeatedExampleGroupDescription:
400
315
  Exclude:
401
316
  - 'spec/coradoc/cli/cli_spec.rb'
402
317
 
403
- # Offense count: 73
318
+ # Offense count: 69
404
319
  # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
405
320
  # Include: **/*_spec.rb
406
321
  RSpec/SpecFilePathFormat:
407
322
  Enabled: false
408
323
 
409
- # Offense count: 58
324
+ # Offense count: 32
410
325
  # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
411
326
  RSpec/VerifiedDoubles:
412
327
  Exclude:
413
328
  - 'coradoc-adoc/spec/coradoc/asciidoc/parse_error_spec.rb'
414
329
  - 'spec/core_model/base_spec.rb'
415
- - 'spec/lazy_spec.rb'
416
330
  - 'spec/query_spec.rb'
417
- - 'spec/streaming_spec.rb'
418
- - 'spec/transform/helpers_spec.rb'
419
331
  - 'spec/validation_spec.rb'
420
332
 
421
- # Offense count: 1
422
- Security/MarshalLoad:
423
- Exclude:
424
- - 'lib/coradoc/transformation_cache.rb'
425
-
426
333
  # Offense count: 4
427
334
  # This cop supports safe autocorrection (--autocorrect).
428
335
  # Configuration parameters: AllowOnConstant, AllowOnSelfClass.
@@ -437,15 +344,7 @@ Style/ClassVars:
437
344
  - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/element_registry.rb'
438
345
  - 'coradoc-html/lib/coradoc/html/input/converters.rb'
439
346
 
440
- # Offense count: 1
441
- # This cop supports safe autocorrection (--autocorrect).
442
- # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
443
- # SupportedStyles: assign_to_condition, assign_inside_condition
444
- Style/ConditionalAssignment:
445
- Exclude:
446
- - 'coradoc-markdown/lib/coradoc/markdown/parser/ast_processor.rb'
447
-
448
- # Offense count: 289
347
+ # Offense count: 291
449
348
  # Configuration parameters: AllowedConstants.
450
349
  Style/Documentation:
451
350
  Enabled: false
@@ -460,14 +359,12 @@ Style/EmptyElse:
460
359
  - 'coradoc-html/lib/coradoc/html/input/converters/text.rb'
461
360
  - 'lib/coradoc/core_model/toc_generator.rb'
462
361
 
463
- # Offense count: 13
362
+ # Offense count: 3
464
363
  # This cop supports safe autocorrection (--autocorrect).
465
- # Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
364
+ # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
466
365
  # SupportedStyles: annotated, template, unannotated
467
366
  Style/FormatStringToken:
468
- Exclude:
469
- - 'coradoc-html/lib/coradoc/html/theme/modern/tailwind_config_builder.rb'
470
- - 'lib/coradoc/performance_regression.rb'
367
+ EnforcedStyle: unannotated
471
368
 
472
369
  # Offense count: 8
473
370
  # Configuration parameters: AllowedVariables.
@@ -483,6 +380,14 @@ Style/HashLikeCase:
483
380
  - 'coradoc-html/lib/coradoc/html/input/converters/table.rb'
484
381
  - 'coradoc-html/lib/coradoc/html/input/converters/td.rb'
485
382
 
383
+ # Offense count: 1
384
+ # This cop supports unsafe autocorrection (--autocorrect-all).
385
+ # Configuration parameters: EnforcedStyle.
386
+ # SupportedStyles: literals, strict
387
+ Style/MutableConstant:
388
+ Exclude:
389
+ - 'lib/coradoc/visitor.rb'
390
+
486
391
  # Offense count: 1
487
392
  # Configuration parameters: AllowedMethods.
488
393
  # AllowedMethods: respond_to_missing?
@@ -490,12 +395,6 @@ Style/OptionalBooleanParameter:
490
395
  Exclude:
491
396
  - 'coradoc-adoc/lib/coradoc/asciidoc/parser/content.rb'
492
397
 
493
- # Offense count: 1
494
- # This cop supports safe autocorrection (--autocorrect).
495
- Style/RedundantAssignment:
496
- Exclude:
497
- - 'lib/coradoc/normalize.rb'
498
-
499
398
  # Offense count: 1
500
399
  # This cop supports unsafe autocorrection (--autocorrect-all).
501
400
  # Configuration parameters: Mode.
@@ -503,18 +402,7 @@ Style/StringConcatenation:
503
402
  Exclude:
504
403
  - 'coradoc-adoc/lib/coradoc/asciidoc/serializer/serializers/document_attributes.rb'
505
404
 
506
- # Offense count: 4
507
- # This cop supports safe autocorrection (--autocorrect).
508
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
509
- # SupportedStyles: single_quotes, double_quotes
510
- Style/StringLiterals:
511
- Exclude:
512
- - 'lib/coradoc/core_model/block.rb'
513
- - 'lib/coradoc/core_model/inline_element.rb'
514
- - 'lib/coradoc/core_model/list_item.rb'
515
- - 'lib/coradoc/core_model/table.rb'
516
-
517
- # Offense count: 29
405
+ # Offense count: 44
518
406
  # This cop supports safe autocorrection (--autocorrect).
519
407
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
520
408
  # URISchemes: http, https
@@ -51,12 +51,13 @@ module Coradoc
51
51
  return element if element.nil?
52
52
 
53
53
  element = yield element, :pre
54
- element = if element.respond_to?(:visit)
54
+ element = case element
55
+ when Coradoc::AsciiDoc::Model::Base
55
56
  element.visit(&block)
56
- elsif element.is_a?(Array)
57
+ when Array
57
58
  element.map { |child| visit(child, &block) }
58
59
  .flatten.compact
59
- elsif element.is_a?(Hash)
60
+ when Hash
60
61
  result = {}
61
62
  element.each do |k, v|
62
63
  result[k] = visit(v, &block)
@@ -176,7 +176,7 @@ module Coradoc
176
176
  end
177
177
 
178
178
  # Merge the line break into the previous element if it has a line_break attribute
179
- if prev.respond_to?(:line_break=)
179
+ if prev.is_a?(Coradoc::AsciiDoc::Model::Base) && prev.class.attributes.key?(:line_break)
180
180
  prev.line_break = prev.line_break.to_s + line_break.line_break.to_s
181
181
  sections.delete_at(i)
182
182
  # Don't increment i since we deleted an element
@@ -46,7 +46,7 @@ module Coradoc
46
46
  # @return [Hash] include options (leveloffset, lines, tags, etc.)
47
47
  def reference_options
48
48
  options = {}
49
- if attributes.respond_to?(:named)
49
+ if attributes.is_a?(Coradoc::AsciiDoc::Model::AttributeList)
50
50
  attributes.named.each do |attr|
51
51
  case attr.name.to_s
52
52
  when 'leveloffset'
@@ -142,7 +142,7 @@ module Coradoc
142
142
  return resolved.map { |n| resolve_node_recursive(n, base_dir, depth) }.flatten if resolved.is_a?(Array)
143
143
 
144
144
  # Handle nodes with nested content
145
- if resolved.respond_to?(:contents) && resolved.contents
145
+ if resolved.is_a?(Coradoc::AsciiDoc::Model::Base) && resolved.class.attributes.key?(:contents) && resolved.contents
146
146
  resolved = deep_copy_node(resolved)
147
147
  resolved.contents = resolved.contents.map do |child|
148
148
  resolve_node_recursive(child, base_dir, depth + 1)
@@ -150,7 +150,7 @@ module Coradoc
150
150
  end
151
151
 
152
152
  # Handle sections with nested content
153
- if resolved.respond_to?(:sections) && resolved.sections && !resolved.is_a?(Document)
153
+ if resolved.is_a?(Coradoc::AsciiDoc::Model::Base) && resolved.class.attributes.key?(:sections) && resolved.sections && !resolved.is_a?(Document)
154
154
  resolved = deep_copy_node(resolved)
155
155
  resolved.sections = resolved.sections.map do |child|
156
156
  resolve_node_recursive(child, base_dir, depth + 1)
@@ -76,7 +76,7 @@ module Coradoc
76
76
  end
77
77
 
78
78
  # Apply value map if present
79
- value = apply_value_map(value, rule.value_map(:from, options), attr) if rule.respond_to?(:value_map)
79
+ value = apply_value_map(value, rule.value_map(:from, options), attr)
80
80
 
81
81
  # Set the value
82
82
  instance.public_send(:"#{rule.to}=", value) if value
@@ -123,7 +123,7 @@ module Coradoc
123
123
 
124
124
  # Set on target instance
125
125
  target_attr = rule.name || rule.to
126
- instance.public_send(:"#{target_attr}=", value) if instance.respond_to?("#{target_attr}=")
126
+ instance.public_send(:"#{target_attr}=", value)
127
127
  end
128
128
 
129
129
  instance
@@ -154,7 +154,7 @@ module Coradoc
154
154
  when Coradoc::Element::Base
155
155
  # Already a Coradoc element, may need conversion
156
156
  if attr&.type&.<(Lutaml::Model::Type::Value)
157
- value.respond_to?(:content) ? value.content : value.to_s
157
+ value.is_a?(Coradoc::AsciiDoc::Model::Base) && value.class.attributes.key?(:content) ? value.content : value.to_s
158
158
  else
159
159
  value
160
160
  end
@@ -12,7 +12,7 @@ module Coradoc
12
12
  end
13
13
 
14
14
  def asciidoc?
15
- columns&.any? { |c| c.respond_to?(:asciidoc?) && c.asciidoc? } || false
15
+ columns&.any? { |c| c.is_a?(Coradoc::AsciiDoc::Model::TableCell) && c.asciidoc? } || false
16
16
  end
17
17
 
18
18
  # NOTE: underline_for provides trailing newline for table row serialization.
@@ -34,13 +34,10 @@ module Coradoc
34
34
  content
35
35
  when Array
36
36
  content.map(&:to_s).join
37
+ when Coradoc::AsciiDoc::Model::Base
38
+ content.to_adoc
37
39
  when Lutaml::Model::Serializable
38
- # Handle Lutaml models - try to extract text properly
39
- if content.respond_to?(:to_adoc)
40
- content.to_adoc
41
- elsif content.respond_to?(:text)
42
- content.text.to_s
43
- elsif content.respond_to?(:content)
40
+ if content.class.attributes.key?(:content)
44
41
  content.content.to_s
45
42
  else
46
43
  ''
@@ -48,8 +45,7 @@ module Coradoc
48
45
  when nil
49
46
  ''
50
47
  else
51
- # Only use to_s for simple types that respond to to_str
52
- content.respond_to?(:to_str) ? content.to_s : ''
48
+ content.is_a?(String) ? content.to_s : ''
53
49
  end
54
50
  end
55
51
 
@@ -112,14 +112,14 @@ module Coradoc
112
112
  # @param exception [Parslet::ParseFailed] The Parslet exception
113
113
  # @return [Array<Integer, Integer>] Line and column numbers
114
114
  def self.extract_location(exception)
115
- return [nil, nil] unless exception.respond_to?(:cause)
115
+ return [nil, nil] unless exception.is_a?(Parslet::ParseFailed)
116
116
 
117
117
  cause = exception.cause
118
- if cause.respond_to?(:source_line) && cause.respond_to?(:source_column)
119
- [cause.source_line, cause.source_column]
120
- else
121
- [nil, nil]
122
- end
118
+ return [nil, nil] unless cause
119
+
120
+ [cause.source_line, cause.source_column]
121
+ rescue NoMethodError
122
+ [nil, nil]
123
123
  end
124
124
 
125
125
  # Extract the relevant source line
@@ -28,14 +28,9 @@ module Coradoc
28
28
  when Coradoc::AsciiDoc::Model::Base
29
29
  serialize_model(model, options)
30
30
  when Lutaml::Model::Serializable
31
- # Handle Lutaml::Model objects that have to_adoc method
32
- if model.respond_to?(:to_adoc)
33
- model.to_adoc
34
- else
35
- raise ArgumentError,
36
- "Cannot serialize #{model.class.name} to AsciiDoc. " \
37
- 'Expected a model with #to_adoc or a registered serializer.'
38
- end
31
+ raise ArgumentError,
32
+ "Cannot serialize #{model.class.name} to AsciiDoc. " \
33
+ 'Expected a Coradoc::AsciiDoc::Model::Base with a registered serializer.'
39
34
  else
40
35
  raise ArgumentError,
41
36
  "Unknown element type for AsciiDoc serialization: #{model.class}. " \
@@ -53,8 +48,8 @@ module Coradoc
53
48
  return serializer_class.new
54
49
  end
55
50
 
56
- # Fallback: if model has to_adoc method, use it directly
57
- return FallbackSerializer.new if model.respond_to?(:to_adoc)
51
+ # Fallback: use FallbackSerializer which raises a clear error
52
+ return FallbackSerializer.new
58
53
 
59
54
  raise ArgumentError, "No serializer registered for #{model.class.name} and model doesn't respond to to_adoc"
60
55
  end
@@ -12,15 +12,16 @@ module Coradoc
12
12
  def attribute_list(attrs)
13
13
  return '' if attrs.nil?
14
14
 
15
- # Delegate to the attribute list's serialization
16
- attrs.respond_to?(:to_s) ? attrs.to_s : ''
15
+ attrs.to_s
17
16
  end
18
17
 
19
18
  # Format block attributes (anchor, role, options, etc.)
20
19
  # @param attrs [Hash, Coradoc::AsciiDoc::Model::AttributeList] Block attributes
21
20
  # @return [String] Formatted block attributes
22
21
  def block_attributes(attrs)
23
- return '' if attrs.nil? || (attrs.respond_to?(:empty?) && attrs.empty?)
22
+ return '' if attrs.nil?
23
+ return '' if attrs.is_a?(String) && attrs.empty?
24
+ return '' if attrs.is_a?(Hash) && attrs.empty?
24
25
 
25
26
  # If it's an AttributeList model, use its serialization
26
27
  return attribute_list(attrs) if attrs.is_a?(Coradoc::AsciiDoc::Model::AttributeList)