Skip to content

Commit 8dcfbb5

Browse files
Merge pull request #1415 from puppetlabs/CAT-2155
(CAT-2155) Remove metadata_syntax_validator parser swap to `JSON::Pure`
2 parents 5efd5e9 + 01ce3e9 commit 8dcfbb5

File tree

4 files changed

+3
-15
lines changed

4 files changed

+3
-15
lines changed

lib/pdk/validate/metadata/metadata_syntax_validator.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ def invoke(report)
2222
JSON.parser = JSON::Ext::Parser if defined?(JSON::Ext::Parser)
2323
end
2424

25-
def before_validation
26-
# The pure ruby JSON parser gives much nicer parse error messages than
27-
# the C extension at the cost of slightly slower parsing. We require it
28-
# here and restore the C extension at the end of the method (if it was
29-
# being used).
30-
require 'json/pure'
31-
JSON.parser = JSON::Pure::Parser
32-
end
33-
3425
def validate_target(report, target)
3526
unless PDK::Util::Filesystem.readable?(target)
3627
report.add_event(
@@ -56,9 +47,7 @@ def validate_target(report, target)
5647
rescue JSON::ParserError => e
5748
# Because the message contains a raw segment of the file, we use
5849
# String#dump here to unescape any escape characters like newlines.
59-
# We then strip out the surrounding quotes and the exclaimation
60-
# point that json_pure likes to put in exception messages.
61-
sane_message = e.message.dump[/\A"(.+?)!?"\Z/, 1]
50+
sane_message = e.message.dump
6251

6352
report.add_event(
6453
file: target,

pdk.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ Gem::Specification.new do |spec|
4747
# Other deps
4848
spec.add_runtime_dependency 'deep_merge', '~> 1.2.2'
4949
spec.add_runtime_dependency 'diff-lcs', '>= 1.5.0'
50-
spec.add_runtime_dependency 'json', '< 2.8.0'
5150
spec.add_runtime_dependency 'pathspec', '~> 1.1'
5251
spec.add_runtime_dependency 'puppet_forge', '~> 5.0'
5352

spec/support/file_based_namespaces.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197

198198
context 'when there is no data stored' do
199199
it 'serializes to an empty JSON object' do
200-
expect(serialized_data).to match(/^\{\n+\}$/)
200+
expect(serialized_data).to match(/^\{\}$/)
201201
end
202202
end
203203

spec/unit/pdk/validate/metadata/metadata_syntax_validator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
source: 'metadata-syntax',
7979
state: :failure,
8080
severity: 'error',
81-
message: a_string_matching(/\Aexpected ':' in object/)
81+
message: a_string_matching(/unexpected token at/)
8282
})
8383
expect(return_value).to eq(1)
8484
end

0 commit comments

Comments
 (0)