voxpupuli / metadata-json-lint

Tool to check the validity of Puppet metadata.json files
Apache License 2.0
30 stars 27 forks source link

Fail cleanly when requirements is not an array #94

Closed rodjek closed 6 years ago

rodjek commented 6 years ago

When the requirements field is (for example) a string, the schema validation picks it up but the problem is never displayed to the user. Before the errors and warnings are displayed, metadata-json-lint attempts to iterate through the requirements which causes an exception to be raised.

Before:

$ metadata-json-lint test.json
/home/tsharpe/code/metadata-json-lint/lib/metadata_json_lint.rb:137: in
'validate_requirements!': undefined method 'each' for "aoeu":String
(NoMethodError)

After:

$ metadata-json-lint test.json
(ERROR) requirements: The property 'requirements' of type string did not
match the following type: array
Errors found in test.json
rodjek commented 6 years ago

@ekohl I can add a test for this.

It looks like rubocop is failing on unrelated code, probably caused by a rubocop update. I'll open a separate PR to fix them up.

alexjfisher commented 6 years ago

@rodjek Thanks!