svg_conform 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c862af872ab16b243d9f6ffaedb7c5a37e8c470a5280915cc96bc33a3572c8e5
4
- data.tar.gz: 3b5fbeebd207eb29ac9685a8913799cc8239704566d9efd8b18fa663bf55a8d0
3
+ metadata.gz: 24fb1d016b5e3ed96b2da518c95884fac16a47b18cd8566e129d81b49791fb32
4
+ data.tar.gz: ad67c207d5f1489855772d6c8931ea4dd8277b041a2a791ceebb6fe2af63ff36
5
5
  SHA512:
6
- metadata.gz: d5808529cca60d31e717f907c5fa9cf11753fb7de4bb65416f7a796f007b4a0157f35c28a7c40f7d58a089eb83738ffc16237e60856b6dd54e475db12132ea91
7
- data.tar.gz: e597d1400a180a30a44ce26437f84bdc4fc8d51d6c7e0e7aa5afdf2adefa8c1c7ad1bd749c613fb9c7635d1fa462993d345866f17775671e5b2b687042778196
6
+ metadata.gz: fa0cdaf7dcd0ed01c23d334ed2d92e1674954a9fce8aed9aad85fd884a2949a6da81cec006607005971d61093384076d2797f72204a7362bad94a8fb882712e2
7
+ data.tar.gz: c6e9af1cba1fb25edbf89ed1ddc77261b4c8a3d068f79d1b56553d5636114f8a493b48dcbaa8a125c99319a043cbfbc5737be77dbe6054f9145a02ddeb94e37a
data/.rubocop_todo.yml CHANGED
@@ -1,214 +1,41 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-11-19 09:35:14 UTC using RuboCop version 1.81.1.
3
+ # on 2025-11-19 10:52:11 UTC using RuboCop version 1.81.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: 19
10
- # This cop supports safe autocorrection (--autocorrect).
11
- # Configuration parameters: EnforcedStyle, IndentationWidth.
12
- # SupportedStyles: with_first_argument, with_fixed_indentation
13
- Layout/ArgumentAlignment:
14
- Exclude:
15
- - 'compare_dom_sax.rb'
16
- - 'lib/svg_conform/requirements/font_family_requirement.rb'
17
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
18
- - 'lib/svg_conform/sax_validation_handler.rb'
19
- - 'spec/support/shared_examples_for_validation_modes.rb'
20
-
21
- # Offense count: 5
22
- # This cop supports safe autocorrection (--autocorrect).
23
- # Configuration parameters: EnforcedStyle, IndentationWidth.
24
- # SupportedStyles: with_first_element, with_fixed_indentation
25
- Layout/ArrayAlignment:
26
- Exclude:
27
- - 'lib/svg_conform/requirements/color_restrictions_requirement.rb'
28
- - 'lib/svg_conform/requirements/id_reference_requirement.rb'
29
- - 'lib/svg_conform/requirements/invalid_id_references_requirement.rb'
30
-
31
- # Offense count: 5
9
+ # Offense count: 1
32
10
  # This cop supports safe autocorrection (--autocorrect).
33
11
  # Configuration parameters: EnforcedStyleAlignWith.
34
12
  # SupportedStylesAlignWith: either, start_of_block, start_of_line
35
13
  Layout/BlockAlignment:
36
14
  Exclude:
37
- - 'benchmark_bsi_samples.rb'
38
- - 'check_position_collisions.rb'
39
- - 'check_unique_positions.rb'
40
- - 'lib/svg_conform/requirements/allowed_elements_requirement.rb'
41
15
  - 'spec/svg_conform/profiles/svg_1_2_rfc_profile_spec.rb'
42
16
 
43
- # Offense count: 8
44
- # This cop supports safe autocorrection (--autocorrect).
45
- Layout/BlockEndNewline:
46
- Exclude:
47
- - 'benchmark_bsi_samples.rb'
48
- - 'check_duplicates.rb'
49
- - 'check_position_collisions.rb'
50
- - 'check_unique_positions.rb'
51
- - 'compare_errors.rb'
52
- - 'find_missing_errors.rb'
53
- - 'lib/svg_conform/requirements/allowed_elements_requirement.rb'
54
-
55
- # Offense count: 4
56
- # This cop supports safe autocorrection (--autocorrect).
57
- # Configuration parameters: AllowForAlignment.
58
- Layout/CommentIndentation:
59
- Exclude:
60
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
61
- - 'lib/svg_conform/validation_context.rb'
62
-
63
- # Offense count: 2
64
- # This cop supports safe autocorrection (--autocorrect).
65
- Layout/ElseAlignment:
66
- Exclude:
67
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
68
-
69
- # Offense count: 17
70
- # This cop supports safe autocorrection (--autocorrect).
71
- Layout/EmptyLineAfterGuardClause:
72
- Exclude:
73
- - 'analyze_error_nodes.rb'
74
- - 'check_duplicates.rb'
75
- - 'check_position_collisions.rb'
76
- - 'check_unique_positions.rb'
77
- - 'compare_errors.rb'
78
- - 'debug_object_ids.rb'
79
- - 'debug_utf8.rb'
80
- - 'find_all_elements.rb'
81
- - 'find_missing_errors.rb'
82
- - 'lib/svg_conform/fast_document_analyzer.rb'
83
- - 'lib/svg_conform/node_index_builder.rb'
84
- - 'lib/svg_conform/requirements/id_reference_requirement.rb'
85
- - 'lib/svg_conform/sax_validation_handler.rb'
86
-
87
- # Offense count: 1
88
- # This cop supports safe autocorrection (--autocorrect).
89
- # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
90
- Layout/EmptyLineBetweenDefs:
91
- Exclude:
92
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
93
-
94
- # Offense count: 1
95
- # This cop supports safe autocorrection (--autocorrect).
96
- Layout/EmptyLines:
97
- Exclude:
98
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
99
-
100
17
  # Offense count: 1
101
18
  # This cop supports safe autocorrection (--autocorrect).
102
- Layout/EmptyLinesAroundMethodBody:
103
- Exclude:
104
- - 'lib/svg_conform/fast_document_analyzer.rb'
105
-
106
- # Offense count: 2
107
- # This cop supports safe autocorrection (--autocorrect).
108
- # Configuration parameters: EnforcedStyleAlignWith, Severity.
109
- # SupportedStylesAlignWith: keyword, variable, start_of_line
110
- Layout/EndAlignment:
111
- Exclude:
112
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
113
-
114
- # Offense count: 22
115
- # This cop supports safe autocorrection (--autocorrect).
116
19
  # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
117
20
  Layout/ExtraSpacing:
118
21
  Exclude:
119
- - 'benchmark_bsi_samples.rb'
120
- - 'find_missing_errors.rb'
121
- - 'lib/svg_conform/element_proxy.rb'
122
- - 'lib/svg_conform/requirements/id_reference_requirement.rb'
123
- - 'lib/svg_conform/requirements/invalid_id_references_requirement.rb'
124
- - 'lib/svg_conform/sax_validation_handler.rb'
125
- - 'lib/svg_conform/validation_context.rb'
126
- - 'lib/svg_conform/validator.rb'
127
-
128
- # Offense count: 2
129
- # This cop supports safe autocorrection (--autocorrect).
130
- # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
131
- # SupportedHashRocketStyles: key, separator, table
132
- # SupportedColonStyles: key, separator, table
133
- # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
134
- Layout/HashAlignment:
135
- Exclude:
136
- - 'benchmark_bsi_samples.rb'
137
- - 'final_demo.rb'
138
-
139
- # Offense count: 2
140
- # This cop supports safe autocorrection (--autocorrect).
141
- Layout/HeredocIndentation:
142
- Exclude:
143
- - 'test_sax_basic.rb'
22
+ - 'lib/svg_conform/requirements/no_external_css_requirement.rb'
144
23
 
145
- # Offense count: 8
24
+ # Offense count: 1
146
25
  # This cop supports safe autocorrection (--autocorrect).
147
26
  # Configuration parameters: EnforcedStyle.
148
27
  # SupportedStyles: normal, indented_internal_methods
149
28
  Layout/IndentationConsistency:
150
29
  Exclude:
151
- - 'check_duplicates.rb'
152
- - 'compare_dom_sax.rb'
153
- - 'compare_errors.rb'
154
- - 'find_missing_errors.rb'
155
- - 'lib/svg_conform/validation_context.rb'
156
-
157
- # Offense count: 13
158
- # This cop supports safe autocorrection (--autocorrect).
159
- # Configuration parameters: Width, AllowedPatterns.
160
- Layout/IndentationWidth:
161
- Exclude:
162
- - 'benchmark_bsi_samples.rb'
163
- - 'check_position_collisions.rb'
164
- - 'check_unique_positions.rb'
165
- - 'lib/svg_conform/requirements/allowed_elements_requirement.rb'
166
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
30
+ - 'lib/svg_conform/profile.rb'
167
31
 
168
- # Offense count: 640
32
+ # Offense count: 616
169
33
  # This cop supports safe autocorrection (--autocorrect).
170
34
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
171
35
  # URISchemes: http, https
172
36
  Layout/LineLength:
173
37
  Enabled: false
174
38
 
175
- # Offense count: 3
176
- # This cop supports safe autocorrection (--autocorrect).
177
- Layout/MultilineBlockLayout:
178
- Exclude:
179
- - 'check_duplicates.rb'
180
- - 'compare_errors.rb'
181
- - 'find_missing_errors.rb'
182
-
183
- # Offense count: 28
184
- # This cop supports safe autocorrection (--autocorrect).
185
- # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals.
186
- # SupportedStylesForExponentOperator: space, no_space
187
- # SupportedStylesForRationalLiterals: space, no_space
188
- Layout/SpaceAroundOperators:
189
- Exclude:
190
- - 'benchmark_sax.rb'
191
- - 'benchmark_validation.rb'
192
- - 'check_clippath_font.rb'
193
- - 'check_unique_positions.rb'
194
- - 'count_elements.rb'
195
- - 'final_demo.rb'
196
- - 'test_remediation.rb'
197
-
198
- # Offense count: 1
199
- # This cop supports safe autocorrection (--autocorrect).
200
- # Configuration parameters: EnforcedStyle.
201
- # SupportedStyles: final_newline, final_blank_line
202
- Layout/TrailingEmptyLines:
203
- Exclude:
204
- - 'spec/support/shared_examples_for_validation_modes.rb'
205
-
206
- # Offense count: 67
207
- # This cop supports safe autocorrection (--autocorrect).
208
- # Configuration parameters: AllowInHeredoc.
209
- Layout/TrailingWhitespace:
210
- Enabled: false
211
-
212
39
  # Offense count: 2
213
40
  # Configuration parameters: AllowedMethods.
214
41
  # AllowedMethods: enums
@@ -216,10 +43,11 @@ Lint/ConstantDefinitionInBlock:
216
43
  Exclude:
217
44
  - 'spec/svg_conform/profiles/svg_1_2_rfc_profile_spec.rb'
218
45
 
219
- # Offense count: 19
46
+ # Offense count: 22
220
47
  # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
221
48
  Lint/DuplicateBranch:
222
49
  Exclude:
50
+ - 'lib/svg_conform/profile.rb'
223
51
  - 'lib/svg_conform/remediations/font_embedding_remediation.rb'
224
52
  - 'lib/svg_conform/remediations/image_embedding_remediation.rb'
225
53
  - 'lib/svg_conform/report_comparator.rb'
@@ -239,12 +67,6 @@ Lint/DuplicateMethods:
239
67
  - 'lib/svg_conform/sax_validation_handler.rb'
240
68
  - 'lib/svg_conform/validation_context.rb'
241
69
 
242
- # Offense count: 1
243
- # This cop supports safe autocorrection (--autocorrect).
244
- Lint/IdentityComparison:
245
- Exclude:
246
- - 'lib/svg_conform/fast_document_analyzer.rb'
247
-
248
70
  # Offense count: 4
249
71
  # Configuration parameters: AllowedParentClasses.
250
72
  Lint/MissingSuper:
@@ -253,46 +75,20 @@ Lint/MissingSuper:
253
75
  - 'lib/svg_conform/compatibility/validity_analysis.rb'
254
76
  - 'lib/svg_conform/sax_validation_handler.rb'
255
77
 
256
- # Offense count: 3
257
- # This cop supports unsafe autocorrection (--autocorrect-all).
258
- # Configuration parameters: AllowedMethods, InferNonNilReceiver, AdditionalNilMethods.
259
- # AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
260
- # AdditionalNilMethods: present?, blank?, try, try!
261
- Lint/RedundantSafeNavigation:
262
- Exclude:
263
- - 'count_elements.rb'
264
- - 'lib/svg_conform/fast_document_analyzer.rb'
265
-
266
- # Offense count: 1
267
- # This cop supports safe autocorrection (--autocorrect).
268
- Lint/RedundantStringCoercion:
269
- Exclude:
270
- - 'analyze_error_nodes.rb'
271
-
272
78
  # Offense count: 1
273
79
  Lint/UnreachableCode:
274
80
  Exclude:
275
81
  - 'lib/svg_conform/commands/check.rb'
276
82
 
277
- # Offense count: 4
83
+ # Offense count: 1
278
84
  # This cop supports safe autocorrection (--autocorrect).
279
85
  # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
280
86
  # NotImplementedExceptions: NotImplementedError
281
87
  Lint/UnusedMethodArgument:
282
88
  Exclude:
283
- - 'lib/svg_conform/element_proxy.rb'
284
- - 'lib/svg_conform/requirements/id_reference_requirement.rb'
285
- - 'lib/svg_conform/requirements/invalid_id_references_requirement.rb'
286
- - 'lib/svg_conform/sax_validation_handler.rb'
287
-
288
- # Offense count: 1
289
- # This cop supports safe autocorrection (--autocorrect).
290
- # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
291
- Lint/UselessAccessModifier:
292
- Exclude:
293
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
89
+ - 'lib/svg_conform/requirements/no_external_css_requirement.rb'
294
90
 
295
- # Offense count: 147
91
+ # Offense count: 148
296
92
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
297
93
  Metrics/AbcSize:
298
94
  Enabled: false
@@ -313,7 +109,7 @@ Metrics/BlockNesting:
313
109
  Metrics/CyclomaticComplexity:
314
110
  Enabled: false
315
111
 
316
- # Offense count: 258
112
+ # Offense count: 261
317
113
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
318
114
  Metrics/MethodLength:
319
115
  Max: 154
@@ -342,12 +138,6 @@ Performance/CollectionLiteralInLoop:
342
138
  - 'lib/svg_conform/batch_report.rb'
343
139
  - 'lib/svg_conform/compatibility/pattern_discovery.rb'
344
140
 
345
- # Offense count: 1
346
- # This cop supports unsafe autocorrection (--autocorrect-all).
347
- Performance/UnfreezeString:
348
- Exclude:
349
- - 'lib/svg_conform/element_proxy.rb'
350
-
351
141
  # Offense count: 8
352
142
  # Configuration parameters: IgnoredMetadata.
353
143
  RSpec/DescribeClass:
@@ -390,31 +180,6 @@ Rake/MethodDefinitionInTask:
390
180
  Exclude:
391
181
  - 'lib/tasks/svgcheck.rake'
392
182
 
393
- # Offense count: 9
394
- # This cop supports safe autocorrection (--autocorrect).
395
- # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
396
- # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
397
- # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
398
- # FunctionalMethods: let, let!, subject, watch
399
- # AllowedMethods: lambda, proc, it
400
- Style/BlockDelimiters:
401
- Exclude:
402
- - 'benchmark_bsi_samples.rb'
403
- - 'check_duplicates.rb'
404
- - 'check_position_collisions.rb'
405
- - 'check_unique_positions.rb'
406
- - 'compare_errors.rb'
407
- - 'find_missing_errors.rb'
408
- - 'lib/svg_conform/requirements/allowed_elements_requirement.rb'
409
-
410
- # Offense count: 3
411
- # This cop supports unsafe autocorrection (--autocorrect-all).
412
- Style/CombinableLoops:
413
- Exclude:
414
- - 'check_duplicates.rb'
415
- - 'compare_errors.rb'
416
- - 'find_missing_errors.rb'
417
-
418
183
  # Offense count: 2
419
184
  # This cop supports safe autocorrection (--autocorrect).
420
185
  # Configuration parameters: EnforcedStyle, AllowComments.
@@ -436,42 +201,6 @@ Style/MissingRespondToMissing:
436
201
  Exclude:
437
202
  - 'lib/svg_conform/cli.rb'
438
203
 
439
- # Offense count: 3
440
- # This cop supports safe autocorrection (--autocorrect).
441
- Style/MultilineIfModifier:
442
- Exclude:
443
- - 'benchmark_bsi_samples.rb'
444
- - 'lib/svg_conform/sax_validation_handler.rb'
445
-
446
- # Offense count: 1
447
- # This cop supports safe autocorrection (--autocorrect).
448
- Style/MultilineTernaryOperator:
449
- Exclude:
450
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
451
-
452
- # Offense count: 2
453
- # This cop supports unsafe autocorrection (--autocorrect-all).
454
- # Configuration parameters: EnforcedStyle.
455
- # SupportedStyles: literals, strict
456
- Style/MutableConstant:
457
- Exclude:
458
- - 'benchmark_bsi_samples.rb'
459
- - 'test_sax_on_slow_files.rb'
460
-
461
- # Offense count: 8
462
- # This cop supports unsafe autocorrection (--autocorrect-all).
463
- # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
464
- # SupportedStyles: predicate, comparison
465
- Style/NumericPredicate:
466
- Exclude:
467
- - 'spec/**/*'
468
- - 'benchmark_validation.rb'
469
- - 'check_unique_positions.rb'
470
- - 'compare_dom_sax.rb'
471
- - 'lib/svg_conform/validation_context.rb'
472
- - 'test_remediation.rb'
473
- - 'test_sax_basic.rb'
474
-
475
204
  # Offense count: 4
476
205
  # Configuration parameters: AllowedMethods.
477
206
  # AllowedMethods: respond_to_missing?
@@ -479,12 +208,6 @@ Style/OptionalBooleanParameter:
479
208
  Exclude:
480
209
  - 'lib/svg_conform/semantic_comparator.rb'
481
210
 
482
- # Offense count: 1
483
- # This cop supports safe autocorrection (--autocorrect).
484
- Style/RedundantAssignment:
485
- Exclude:
486
- - 'lib/svg_conform/fast_document_analyzer.rb'
487
-
488
211
  # Offense count: 1
489
212
  # This cop supports safe autocorrection (--autocorrect).
490
213
  # Configuration parameters: AllowedMethods.
@@ -493,114 +216,9 @@ Style/RedundantCondition:
493
216
  Exclude:
494
217
  - 'lib/svg_conform/external_checkers/svgcheck/parser.rb'
495
218
 
496
- # Offense count: 1
497
- # This cop supports unsafe autocorrection (--autocorrect-all).
498
- Style/RedundantInterpolation:
499
- Exclude:
500
- - 'analyze_error_nodes.rb'
501
-
502
- # Offense count: 1
503
- # This cop supports safe autocorrection (--autocorrect).
504
- Style/RedundantParentheses:
505
- Exclude:
506
- - 'compare_dom_sax.rb'
507
-
508
- # Offense count: 2
509
- # This cop supports safe autocorrection (--autocorrect).
510
- # Configuration parameters: EnforcedStyle.
511
- # SupportedStyles: implicit, explicit
512
- Style/RescueStandardError:
513
- Exclude:
514
- - 'debug_node_coverage.rb'
515
- - 'test_sax_basic.rb'
516
-
517
219
  # Offense count: 3
518
- # This cop supports unsafe autocorrection (--autocorrect-all).
519
- # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
520
- # AllowedMethods: present?, blank?, presence, try, try!
521
- Style/SafeNavigation:
522
- Exclude:
523
- - 'count_elements.rb'
524
- - 'lib/svg_conform/fast_document_analyzer.rb'
525
-
526
- # Offense count: 7
527
- # This cop supports unsafe autocorrection (--autocorrect-all).
528
- # Configuration parameters: Mode.
529
- Style/StringConcatenation:
530
- Exclude:
531
- - 'benchmark_bsi_samples.rb'
532
- - 'benchmark_sax.rb'
533
- - 'benchmark_validation.rb'
534
- - 'final_demo.rb'
535
- - 'test_remediation.rb'
536
-
537
- # Offense count: 105
538
- # This cop supports safe autocorrection (--autocorrect).
539
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
540
- # SupportedStyles: single_quotes, double_quotes
541
- Style/StringLiterals:
542
- Enabled: false
543
-
544
- # Offense count: 5
545
- # This cop supports safe autocorrection (--autocorrect).
546
- # Configuration parameters: EnforcedStyle.
547
- # SupportedStyles: single_quotes, double_quotes
548
- Style/StringLiteralsInInterpolation:
549
- Exclude:
550
- - 'benchmark_bsi_samples.rb'
551
- - 'benchmark_sax.rb'
552
- - 'benchmark_validation.rb'
553
- - 'final_demo.rb'
554
- - 'test_remediation.rb'
555
-
556
- # Offense count: 34
557
- # This cop supports safe autocorrection (--autocorrect).
558
- # Configuration parameters: EnforcedStyleForMultiline.
559
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
560
- Style/TrailingCommaInArguments:
561
- Exclude:
562
- - 'lib/svg_conform/requirements/allowed_elements_requirement.rb'
563
- - 'lib/svg_conform/requirements/color_restrictions_requirement.rb'
564
- - 'lib/svg_conform/requirements/font_family_requirement.rb'
565
- - 'lib/svg_conform/requirements/forbidden_content_requirement.rb'
566
- - 'lib/svg_conform/requirements/id_reference_requirement.rb'
567
- - 'lib/svg_conform/requirements/invalid_id_references_requirement.rb'
568
- - 'lib/svg_conform/requirements/link_validation_requirement.rb'
569
- - 'lib/svg_conform/requirements/namespace_attributes_requirement.rb'
570
- - 'lib/svg_conform/requirements/namespace_requirement.rb'
571
- - 'lib/svg_conform/requirements/no_external_css_requirement.rb'
572
- - 'lib/svg_conform/requirements/no_external_fonts_requirement.rb'
573
- - 'lib/svg_conform/requirements/no_external_images_requirement.rb'
574
- - 'lib/svg_conform/requirements/viewbox_required_requirement.rb'
575
- - 'lib/svg_conform/sax_validation_handler.rb'
576
- - 'lib/svg_conform/validator.rb'
577
-
578
- # Offense count: 1
579
- # This cop supports safe autocorrection (--autocorrect).
580
- # Configuration parameters: EnforcedStyleForMultiline.
581
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
582
- Style/TrailingCommaInArrayLiteral:
583
- Exclude:
584
- - 'test_sax_on_slow_files.rb'
585
-
586
- # Offense count: 12
587
220
  # This cop supports safe autocorrection (--autocorrect).
588
- # Configuration parameters: EnforcedStyleForMultiline.
589
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
590
- Style/TrailingCommaInHashLiteral:
221
+ # Configuration parameters: AllowMultipleReturnValues.
222
+ Style/RedundantReturn:
591
223
  Exclude:
592
- - 'debug_positions.rb'
593
- - 'lib/svg_conform/requirements/allowed_elements_requirement.rb'
594
- - 'lib/svg_conform/requirements/color_restrictions_requirement.rb'
595
- - 'lib/svg_conform/requirements/namespace_requirement.rb'
596
- - 'lib/svg_conform/requirements/viewbox_required_requirement.rb'
597
- - 'lib/svg_conform/validator.rb'
598
-
599
- # Offense count: 4
600
- # This cop supports unsafe autocorrection (--autocorrect-all).
601
- Style/ZeroLengthPredicate:
602
- Exclude:
603
- - 'benchmark_validation.rb'
604
- - 'lib/svg_conform/validation_context.rb'
605
- - 'test_remediation.rb'
606
- - 'test_sax_basic.rb'
224
+ - 'lib/svg_conform/profile.rb'
@@ -114,19 +114,34 @@ module SvgConform
114
114
  end
115
115
 
116
116
  def validate(document)
117
- context = ValidationContext.new(document, self)
117
+ # Use SAX mode for validation performance
118
+ # Convert document to content string if it's a DOM document
119
+ if document.is_a?(Document)
120
+ content = document.to_xml
121
+ sax_doc = SaxDocument.from_content(content)
122
+ return sax_doc.validate_with_profile(self)
123
+ elsif document.respond_to?(:to_xml)
124
+ # Handle any document-like object
125
+ content = document.to_xml
126
+ sax_doc = SaxDocument.from_content(content)
127
+ return sax_doc.validate_with_profile(self)
128
+ else
129
+ # Fallback to DOM mode for backward compatibility
130
+ context = ValidationContext.new(document, self)
131
+
132
+ # Validate using requirements system
133
+ requirements&.each do |requirement|
134
+ requirement.validate_document(document, context)
135
+ end
118
136
 
119
- # Validate using requirements system
120
- requirements&.each do |requirement|
121
- requirement.validate_document(document, context)
137
+ return ValidationResult.new(document, self, context)
122
138
  end
123
-
124
- ValidationResult.new(document, self, context)
125
139
  end
126
140
 
127
141
  def validate_file(file_path)
128
- document = Document.from_file(file_path)
129
- validate(document)
142
+ # Use SAX mode directly
143
+ sax_doc = SaxDocument.from_file(file_path)
144
+ sax_doc.validate_with_profile(self)
130
145
  end
131
146
 
132
147
  # Apply remediations to a document after validation
@@ -22,6 +22,11 @@ module SvgConform
22
22
  map "allowed_protocols", to: :allowed_protocols
23
23
  end
24
24
 
25
+ def initialize(*args)
26
+ super
27
+ @collected_style_elements = []
28
+ end
29
+
25
30
  def check(node, context)
26
31
  return unless element?(node)
27
32
 
@@ -35,6 +40,27 @@ module SvgConform
35
40
  end
36
41
  end
37
42
 
43
+ def needs_deferred_validation?
44
+ check_style_elements # Only deferred if checking style elements
45
+ end
46
+
47
+ def collect_sax_data(element, context)
48
+ # Collect style elements for deferred validation (text content needs to be complete)
49
+ if check_style_elements && element.name == "style"
50
+ @collected_style_elements << element
51
+ end
52
+ end
53
+
54
+ def validate_sax_complete(context)
55
+ # Validate collected style elements
56
+ @collected_style_elements.each do |element|
57
+ check_style_element_sax(element, context)
58
+ end
59
+
60
+ # Reset for next validation
61
+ @collected_style_elements = []
62
+ end
63
+
38
64
  def should_check_node?(node, context = nil)
39
65
  return false unless element?(node)
40
66
  return false if context&.node_structurally_invalid?(node)
@@ -47,7 +73,8 @@ module SvgConform
47
73
  def validate_sax_element(element, context)
48
74
  case element.name
49
75
  when "style"
50
- check_style_element_sax(element, context) if check_style_elements
76
+ # Style elements handled in deferred validation (need text content)
77
+ # Already collected in collect_sax_data
51
78
  when "link"
52
79
  check_link_element_sax(element, context) if check_link_elements
53
80
  else
@@ -34,13 +34,21 @@ module SvgConform
34
34
  # Validate SVG content string
35
35
  def validate(svg_content, profile: :svg_1_2_rfc, **options)
36
36
  merged_options = @options.merge(options)
37
- mode = merged_options[:mode] == :sax ? :sax : :dom
37
+ mode = merged_options[:mode]
38
+
39
+ # Default to SAX if not specified
40
+ mode = :sax if mode.nil?
38
41
 
39
42
  case mode
40
43
  when :sax
41
44
  validate_content_sax(svg_content, profile: profile, **merged_options)
42
45
  when :dom
43
46
  validate_content_dom(svg_content, profile: profile, **merged_options)
47
+ when :auto
48
+ # For content, we can't check file size, so default to SAX
49
+ validate_content_sax(svg_content, profile: profile, **merged_options)
50
+ else
51
+ validate_content_sax(svg_content, profile: profile, **merged_options)
44
52
  end
45
53
  end
46
54
 
@@ -99,10 +107,21 @@ module SvgConform
99
107
  sax_doc = SvgConform::SaxDocument.from_file(file_path)
100
108
  result = sax_doc.validate_with_profile(profile_obj)
101
109
 
102
- # If fixing is requested, convert to DOM and apply fixes
110
+ # If fixing is requested, load DOM and apply remediations directly
111
+ # Skip re-validation to avoid DOM performance penalty
103
112
  if options[:fix] && result.has_errors?
104
113
  dom_doc = SvgConform::Document.from_file(file_path)
105
- result = validate_document(dom_doc, profile: profile_obj, **options)
114
+
115
+ # Apply remediations directly without re-validating
116
+ changes = profile_obj.apply_remediations(dom_doc)
117
+
118
+ # Write fixed output if specified
119
+ if options[:fix_output] && changes.any?
120
+ File.write(options[:fix_output], dom_doc.to_xml)
121
+ end
122
+
123
+ # Return original SAX validation result (errors already detected)
124
+ # Note: We don't re-validate to avoid DOM performance cost
106
125
  end
107
126
 
108
127
  result
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SvgConform
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svg_conform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose