pax_global_header00006660000000000000000000000064150466441240014520gustar00rootroot0000000000000052 comment=f803deb06fb41e9f52e78ef4a1d0907d81519490 metadata-json-lint-5.0.0/000077500000000000000000000000001504664412400152155ustar00rootroot00000000000000metadata-json-lint-5.0.0/.github/000077500000000000000000000000001504664412400165555ustar00rootroot00000000000000metadata-json-lint-5.0.0/.github/dependabot.yml000066400000000000000000000005411504664412400214050ustar00rootroot00000000000000version: 2 updates: # raise PRs for gem updates - package-ecosystem: bundler directory: "/" schedule: interval: daily time: "13:00" open-pull-requests-limit: 10 # Maintain dependencies for GitHub Actions - package-ecosystem: github-actions directory: "/" schedule: interval: daily time: "13:00" open-pull-requests-limit: 10 metadata-json-lint-5.0.0/.github/release.yml000066400000000000000000000013731504664412400207240ustar00rootroot00000000000000--- # https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes changelog: exclude: labels: - duplicate - invalid - modulesync - question - skip-changelog - wont-fix - wontfix - github_actions categories: - title: Breaking Changes 🛠 labels: - backwards-incompatible - title: New Features 🎉 labels: - enhancement - title: Bug Fixes 🐛 labels: - bug - bugfix - title: Documentation Updates 📚 labels: - documentation - docs - title: Dependency Updates ⬆️ labels: - dependencies - title: Other Changes labels: - "*" metadata-json-lint-5.0.0/.github/workflows/000077500000000000000000000000001504664412400206125ustar00rootroot00000000000000metadata-json-lint-5.0.0/.github/workflows/release.yml000066400000000000000000000055761504664412400227720ustar00rootroot00000000000000--- name: Gem Release on: push: tags: - '*' permissions: {} jobs: build-release: # Prevent releases from forked repositories if: github.repository_owner == 'voxpupuli' name: Build the gem runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v5 - name: Install Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 'ruby' - name: Build gem shell: bash run: gem build --verbose *.gemspec - name: Upload gem to GitHub cache uses: actions/upload-artifact@v4 with: name: gem-artifact path: '*.gem' retention-days: 1 compression-level: 0 create-github-release: needs: build-release name: Create GitHub release runs-on: ubuntu-24.04 permissions: contents: write # clone repo and create release steps: - name: Download gem from GitHub cache uses: actions/download-artifact@v5 with: name: gem-artifact - name: Create Release shell: bash env: GH_TOKEN: ${{ github.token }} run: gh release create --repo ${{ github.repository }} ${{ github.ref_name }} --generate-notes *.gem release-to-github: needs: build-release name: Release to GitHub runs-on: ubuntu-24.04 permissions: packages: write # publish to rubygems.pkg.github.com steps: - name: Download gem from GitHub cache uses: actions/download-artifact@v5 with: name: gem-artifact - name: Publish gem to GitHub packages run: gem push --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem env: GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }} release-to-rubygems: needs: build-release name: Release gem to rubygems.org runs-on: ubuntu-24.04 environment: release # recommended by rubygems.org permissions: id-token: write # rubygems.org authentication steps: - name: Download gem from GitHub cache uses: actions/download-artifact@v5 with: name: gem-artifact - uses: rubygems/configure-rubygems-credentials@v1.0.0 - name: Publish gem to rubygems.org shell: bash run: gem push *.gem release-verification: name: Check that all releases are done runs-on: ubuntu-24.04 permissions: contents: read # minimal permissions that we have to grant needs: - create-github-release - release-to-github - release-to-rubygems steps: - name: Download gem from GitHub cache uses: actions/download-artifact@v5 with: name: gem-artifact - name: Install Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 'ruby' - name: Wait for release to propagate shell: bash run: | gem install rubygems-await gem await *.gem metadata-json-lint-5.0.0/.github/workflows/test.yml000066400000000000000000000025051504664412400223160ustar00rootroot00000000000000--- name: Test on: pull_request: {} push: branches: - master permissions: contents: read jobs: rubocop_and_matrix: runs-on: ubuntu-latest outputs: ruby: ${{ steps.ruby.outputs.versions }} steps: - uses: actions/checkout@v5 - name: Install Ruby 3.4 uses: ruby/setup-ruby@v1 with: ruby-version: '3.4' bundler-cache: true - name: Run RuboCop run: bundle exec rake rubocop - id: ruby uses: voxpupuli/ruby-version@v1 test: name: "Ruby ${{ matrix.ruby }}" runs-on: ubuntu-latest needs: rubocop_and_matrix strategy: fail-fast: false matrix: ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }} steps: - uses: actions/checkout@v5 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - name: Run tests run: bundle exec rake test - name: Build the gem run: gem build --strict --verbose *.gemspec tests: if: always() needs: - test runs-on: ubuntu-24.04 name: Test suite steps: - name: Decide whether the needed jobs succeeded or failed uses: re-actors/alls-green@release/v1 with: jobs: ${{ toJSON(needs) }} metadata-json-lint-5.0.0/.gitignore000066400000000000000000000001171504664412400172040ustar00rootroot00000000000000*.sw? *.gem Gemfile.lock /.bundle /vendor tests/*/last_*output .idea/ .vendor/ metadata-json-lint-5.0.0/.rspec000066400000000000000000000000261504664412400163300ustar00rootroot00000000000000--require spec_helper metadata-json-lint-5.0.0/.rubocop.yml000066400000000000000000000001661504664412400174720ustar00rootroot00000000000000--- inherit_from: .rubocop_todo.yml inherit_gem: voxpupuli-rubocop: rubocop.yml AllCops: TargetRubyVersion: 3.2 metadata-json-lint-5.0.0/.rubocop_todo.yml000066400000000000000000000042221504664412400205140ustar00rootroot00000000000000# This configuration was generated by # `rubocop --auto-gen-config --no-auto-gen-timestamp` # using RuboCop version 1.79.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 2 Lint/RescueException: Exclude: - 'lib/metadata_json_lint.rb' # Offense count: 1 # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates. # AllowedMethods: call # WaywardPredicates: nonzero? Naming/PredicateMethod: Exclude: - 'lib/metadata_json_lint.rb' # Offense count: 1 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: - 'spec/metadata_json_lint_spec.rb' # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit RSpec/DescribedClass: Exclude: - 'spec/metadata_json_lint/version_requirement_spec.rb' # Offense count: 2 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: EnforcedStyle: receive # Offense count: 7 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - 'spec/metadata_json_lint/schema_spec.rb' # Offense count: 1 # Configuration parameters: AllowedConstants. Style/Documentation: Exclude: - 'spec/**/*' - 'test/**/*' - 'lib/metadata_json_lint.rb' # Offense count: 38 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Enabled: false # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. # URISchemes: http, https Layout/LineLength: Max: 153 metadata-json-lint-5.0.0/CHANGELOG.md000066400000000000000000000250641504664412400170350ustar00rootroot00000000000000# Changelog ## [5.0.0](https://github.com/voxpupuli/metadata-json-lint/tree/5.0.0) (2025-08-12) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.3.0...5.0.0) **Breaking changes:** - Require Ruby 3.2 or newer [\#167](https://github.com/voxpupuli/metadata-json-lint/pull/167) ([bastelfreak](https://github.com/bastelfreak)) ## [4.3.0](https://github.com/voxpupuli/metadata-json-lint/tree/4.3.0) (2025-08-12) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.2.1...4.3.0) **Implemented enhancements:** - json-schema: Allow 6.x [\#164](https://github.com/voxpupuli/metadata-json-lint/pull/164) ([bastelfreak](https://github.com/bastelfreak)) ## [4.2.1](https://github.com/voxpupuli/metadata-json-lint/tree/4.2.1) (2025-02-23) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.2.0...4.2.1) **Fixed bugs:** - Update test for new json 2.10.0 release [\#159](https://github.com/voxpupuli/metadata-json-lint/pull/159) ([bastelfreak](https://github.com/bastelfreak)) **Merged pull requests:** - Add test for openvox requirement [\#148](https://github.com/voxpupuli/metadata-json-lint/pull/148) ([bastelfreak](https://github.com/bastelfreak)) ## [4.2.0](https://github.com/voxpupuli/metadata-json-lint/tree/4.2.0) (2025-01-24) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.1.0...4.2.0) **Implemented enhancements:** - Fail if metadata.json has no proper newline [\#154](https://github.com/voxpupuli/metadata-json-lint/pull/154) ([bastelfreak](https://github.com/bastelfreak)) - Fail on escape sequences in metadata.json [\#152](https://github.com/voxpupuli/metadata-json-lint/pull/152) ([bastelfreak](https://github.com/bastelfreak)) - Rake: Use RuboCop tasks from voxpupuli-rubocop [\#150](https://github.com/voxpupuli/metadata-json-lint/pull/150) ([bastelfreak](https://github.com/bastelfreak)) - Add Ruby 3.4 to CI [\#149](https://github.com/voxpupuli/metadata-json-lint/pull/149) ([bastelfreak](https://github.com/bastelfreak)) **Merged pull requests:** - CI: Switch to voxpupuli/ruby-version [\#156](https://github.com/voxpupuli/metadata-json-lint/pull/156) ([bastelfreak](https://github.com/bastelfreak)) - Drop code coverage in testing [\#153](https://github.com/voxpupuli/metadata-json-lint/pull/153) ([ekohl](https://github.com/ekohl)) ## [4.1.0](https://github.com/voxpupuli/metadata-json-lint/tree/4.1.0) (2024-08-19) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.0.0...4.1.0) **Implemented enhancements:** - json-schema: Allow 5.x [\#145](https://github.com/voxpupuli/metadata-json-lint/pull/145) ([bastelfreak](https://github.com/bastelfreak)) - Add Ruby 3.3 to CI [\#142](https://github.com/voxpupuli/metadata-json-lint/pull/142) ([bastelfreak](https://github.com/bastelfreak)) ## [4.0.0](https://github.com/voxpupuli/metadata-json-lint/tree/4.0.0) (2023-09-15) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/3.0.3...4.0.0) **Breaking changes:** - Drop Ruby 2.5/2.6 & switch to voxpupuli-rubocop [\#137](https://github.com/voxpupuli/metadata-json-lint/pull/137) ([bastelfreak](https://github.com/bastelfreak)) - Drop Ruby =\< 2.4 support [\#125](https://github.com/voxpupuli/metadata-json-lint/pull/125) ([bastelfreak](https://github.com/bastelfreak)) **Implemented enhancements:** - CI: Build gems with strictness and verbosity & Add upper version limits to gemspec [\#135](https://github.com/voxpupuli/metadata-json-lint/pull/135) ([bastelfreak](https://github.com/bastelfreak)) - Add Ruby 3.1/3.2 support [\#133](https://github.com/voxpupuli/metadata-json-lint/pull/133) ([bastelfreak](https://github.com/bastelfreak)) **Merged pull requests:** - Make semantic\_puppet a hard dependency [\#136](https://github.com/voxpupuli/metadata-json-lint/pull/136) ([bastelfreak](https://github.com/bastelfreak)) - Drop pry development dependency [\#134](https://github.com/voxpupuli/metadata-json-lint/pull/134) ([bastelfreak](https://github.com/bastelfreak)) - GCG: Add faraday-retry dep [\#132](https://github.com/voxpupuli/metadata-json-lint/pull/132) ([bastelfreak](https://github.com/bastelfreak)) - Add dummy CI job we can depend on [\#131](https://github.com/voxpupuli/metadata-json-lint/pull/131) ([bastelfreak](https://github.com/bastelfreak)) ## [3.0.3](https://github.com/voxpupuli/metadata-json-lint/tree/3.0.3) (2023-04-24) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/3.0.2...3.0.3) **Fixed bugs:** - gemspec: drop deprecated `date` attribute [\#129](https://github.com/voxpupuli/metadata-json-lint/pull/129) ([bastelfreak](https://github.com/bastelfreak)) **Merged pull requests:** - Allow json-schema 4.x [\#128](https://github.com/voxpupuli/metadata-json-lint/pull/128) ([chelnak](https://github.com/chelnak)) ## [3.0.2](https://github.com/voxpupuli/metadata-json-lint/tree/3.0.2) (2022-05-03) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/3.0.1...3.0.2) ## [3.0.1](https://github.com/voxpupuli/metadata-json-lint/tree/3.0.1) (2021-08-13) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/3.0.0...3.0.1) **Closed issues:** - For the license: missing a file and license headers in source files [\#115](https://github.com/voxpupuli/metadata-json-lint/issues/115) - one test fails against ruby 2.7 when semantic\_puppet is not present [\#114](https://github.com/voxpupuli/metadata-json-lint/issues/114) - Missing possibility to set options via spec\_helper.rb like rspec [\#18](https://github.com/voxpupuli/metadata-json-lint/issues/18) **Merged pull requests:** - Add GitHub actions + badges [\#116](https://github.com/voxpupuli/metadata-json-lint/pull/116) ([bastelfreak](https://github.com/bastelfreak)) ## [3.0.0](https://github.com/voxpupuli/metadata-json-lint/tree/3.0.0) (2020-11-24) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/2.4.0...3.0.0) **Merged pull requests:** - Require Ruby 2.1 and drop post\_install\_message [\#112](https://github.com/voxpupuli/metadata-json-lint/pull/112) ([ekohl](https://github.com/ekohl)) ## [2.4.0](https://github.com/voxpupuli/metadata-json-lint/tree/2.4.0) (2020-06-12) [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/2.3.0...2.4.0) **Merged pull requests:** - Add ruby 2.7 to test matrix [\#110](https://github.com/voxpupuli/metadata-json-lint/pull/110) ([DavidS](https://github.com/DavidS)) - Publish gem only on one rvm job [\#109](https://github.com/voxpupuli/metadata-json-lint/pull/109) ([bastelfreak](https://github.com/bastelfreak)) ## 2.3.0 * Add duplicate testing in requirements list * Fix wrong license file content so GitHub can properly detect it * Fix a typo in the README.md ## 2.2.0 * Validate Puppet version_requirement [#99](https://github.com/voxpupuli/metadata-json-lint/issues/99) * Add optional check `--strict-puppet-version` to validate the Puppet Agent Version is not EOL or open ended [#100](https://github.com/voxpupuli/metadata-json-lint/pull/100) ## 2.1.0 ### Changes * Improve rendering of post\_install message by trimming unnecessary leading spaces [#89](https://github.com/voxpupuli/metadata-json-lint/pull/89) * Fail when checking version requirements if the version range is empty [#91](https://github.com/voxpupuli/metadata-json-lint/pull/91) * Pin `public_suffix` gem to < 3 for Ruby <= 2.0 [#93](https://github.com/voxpupuli/metadata-json-lint/pull/93) ### Fixed * Prevent metadata-json-lint from crashing when the `requirements` field does not contain an array [#94](https://github.com/voxpupuli/metadata-json-lint/pull/94) * Fix loading of `semantic_puppet` so that it supports using version vendored in Puppet (if available) [#96](https://github.com/voxpupuli/metadata-json-lint/pull/96) ## 2.0.2 ### Changes * Make SemanticPuppet completely optional and remove dependency on Puppet [#86](https://github.com/voxpupuli/metadata-json-lint/pull/86) * Only log open dependency warning with --strict-dependencies [#78](https://github.com/voxpupuli/metadata-json-lint/pull/78) ### Fixed * Fix readme for gemfile usage [#84](https://github.com/voxpupuli/metadata-json-lint/pull/84) ## 2.0.1 ### Changes * Puppet 4.9.0 and newer uses the vendored `semantic_puppet` packaged with Puppet. * If using Puppet 4.8.x and earlier, adding `semantic_puppet` to your Gemfile is required as the vendored `semantic_puppet` was not packaged with Puppet prior to `4.9.0` * Add test environment for Ruby 2.4.1 ## 2.0.0 ### Changes * The `semantic_puppet` gem is no longer included as a runtime dependency due to conflicts with Puppet 5.x libraries that break the `puppet module` command. As such, `semantic_puppet` must be added to a user's Gemfile in Puppet <= 4.x. See [Installation](https://github.com/voxpupuli/metadata-json-lint#installation) docs for more info * `metadata-json-lint` now officially only supports Ruby >= 2.0.0 ### Fixed * Fix puppet 5.x `semantic_puppet` conflicts ([#79](https://github.com/voxpupuli/metadata-json-lint/issues/79)) * Clarify Ruby >= 2.x only support ([#74](https://github.com/voxpupuli/metadata-json-lint/issues/74)) ## 1.2.2 ### Fixed * Fix `metadata_lint` rake task exiting on success, not continuing ([#70](https://github.com/voxpupuli/metadata-json-lint/issues/70)) * Fix failure on incorrect license warning when `--no-strict-license` used ([#69](https://github.com/voxpupuli/metadata-json-lint/issues/69)) ## 1.2.1 ### Fixed * Fix missing lib/ files in published gem ## 1.2.0 ### Added * Add `--format`/`-f` option to support a JSON output format * Add warning for mixed version range syntax, supported only in Puppet 5 ### Changed * The default text format mode now outputs more structured messages * README has been edited and clarity improved ### Fixed * Fix non-zero exit code caused by some checks ## 1.1.0 ### Added * Ensure module `tags` are correctly specified as an array ([#44](https://github.com/voxpupuli/metadata-json-lint/issues/44)) * Ensure `requirements` doesn't list the deprecated `pe` key ([#46](https://github.com/voxpupuli/metadata-json-lint/issues/46)) * Ensure `dependencies` aren't listed with `version_range` keys ([#47](https://github.com/voxpupuli/metadata-json-lint/issues/47)) * Support strictness configuration via Ruby API, for use in rake tasks definitions * Show default strictness option values in `--help` output ### Fixed * Fix unclear error message when metadata.json does not exist * Fix gem publishing date * Various test improvements, ensuring failures are caught accurately and precisely \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* metadata-json-lint-5.0.0/Gemfile000066400000000000000000000002761504664412400165150ustar00rootroot00000000000000source 'https://rubygems.org' gemspec group :release, optional: true do gem 'faraday-retry', '~> 2.1', require: false gem 'github_changelog_generator', '~> 1.16.4', require: false end metadata-json-lint-5.0.0/HISTORY.md000066400000000000000000000076501504664412400167100ustar00rootroot00000000000000## 2.3.0 * Add duplicate testing in requirements list * Fix wrong license file content so GitHub can properly detect it * Fix a typo in the README.md ## 2.2.0 * Validate Puppet version_requirement [#99](https://github.com/voxpupuli/metadata-json-lint/issues/99) * Add optional check `--strict-puppet-version` to validate the Puppet Agent Version is not EOL or open ended [#100](https://github.com/voxpupuli/metadata-json-lint/pull/100) ## 2.1.0 ### Changes * Improve rendering of post\_install message by trimming unnecessary leading spaces [#89](https://github.com/voxpupuli/metadata-json-lint/pull/89) * Fail when checking version requirements if the version range is empty [#91](https://github.com/voxpupuli/metadata-json-lint/pull/91) * Pin `public_suffix` gem to < 3 for Ruby <= 2.0 [#93](https://github.com/voxpupuli/metadata-json-lint/pull/93) ### Fixed * Prevent metadata-json-lint from crashing when the `requirements` field does not contain an array [#94](https://github.com/voxpupuli/metadata-json-lint/pull/94) * Fix loading of `semantic_puppet` so that it supports using version vendored in Puppet (if available) [#96](https://github.com/voxpupuli/metadata-json-lint/pull/96) ## 2.0.2 ### Changes * Make SemanticPuppet completely optional and remove dependency on Puppet [#86](https://github.com/voxpupuli/metadata-json-lint/pull/86) * Only log open dependency warning with --strict-dependencies [#78](https://github.com/voxpupuli/metadata-json-lint/pull/78) ### Fixed * Fix readme for gemfile usage [#84](https://github.com/voxpupuli/metadata-json-lint/pull/84) ## 2.0.1 ### Changes * Puppet 4.9.0 and newer uses the vendored `semantic_puppet` packaged with Puppet. * If using Puppet 4.8.x and earlier, adding `semantic_puppet` to your Gemfile is required as the vendored `semantic_puppet` was not packaged with Puppet prior to `4.9.0` * Add test environment for Ruby 2.4.1 ## 2.0.0 ### Changes * The `semantic_puppet` gem is no longer included as a runtime dependency due to conflicts with Puppet 5.x libraries that break the `puppet module` command. As such, `semantic_puppet` must be added to a user's Gemfile in Puppet <= 4.x. See [Installation](https://github.com/voxpupuli/metadata-json-lint#installation) docs for more info * `metadata-json-lint` now officially only supports Ruby >= 2.0.0 ### Fixed * Fix puppet 5.x `semantic_puppet` conflicts ([#79](https://github.com/voxpupuli/metadata-json-lint/issues/79)) * Clarify Ruby >= 2.x only support ([#74](https://github.com/voxpupuli/metadata-json-lint/issues/74)) ## 1.2.2 ### Fixed * Fix `metadata_lint` rake task exiting on success, not continuing ([#70](https://github.com/voxpupuli/metadata-json-lint/issues/70)) * Fix failure on incorrect license warning when `--no-strict-license` used ([#69](https://github.com/voxpupuli/metadata-json-lint/issues/69)) ## 1.2.1 ### Fixed * Fix missing lib/ files in published gem ## 1.2.0 ### Added * Add `--format`/`-f` option to support a JSON output format * Add warning for mixed version range syntax, supported only in Puppet 5 ### Changed * The default text format mode now outputs more structured messages * README has been edited and clarity improved ### Fixed * Fix non-zero exit code caused by some checks ## 1.1.0 ### Added * Ensure module `tags` are correctly specified as an array ([#44](https://github.com/voxpupuli/metadata-json-lint/issues/44)) * Ensure `requirements` doesn't list the deprecated `pe` key ([#46](https://github.com/voxpupuli/metadata-json-lint/issues/46)) * Ensure `dependencies` aren't listed with `version_range` keys ([#47](https://github.com/voxpupuli/metadata-json-lint/issues/47)) * Support strictness configuration via Ruby API, for use in rake tasks definitions * Show default strictness option values in `--help` output ### Fixed * Fix unclear error message when metadata.json does not exist * Fix gem publishing date * Various test improvements, ensuring failures are caught accurately and precisely metadata-json-lint-5.0.0/LICENSE000066400000000000000000000237551504664412400162360ustar00rootroot00000000000000Copyright 2014 HP Development Corporation L.P. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS metadata-json-lint-5.0.0/README.md000066400000000000000000000110151504664412400164720ustar00rootroot00000000000000# metadata-json-lint [![License](https://img.shields.io/github/license/voxpupuli/metadata-json-lint.svg)](https://github.com/voxpupuli/metadata-json-lint/blob/master/LICENSE) [![Test](https://github.com/voxpupuli/metadata-json-lint/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/metadata-json-lint/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/voxpupuli/metadata-json-lint/branch/master/graph/badge.svg)](https://codecov.io/gh/voxpupuli/metadata-json-lint) [![Release](https://github.com/voxpupuli/metadata-json-lint/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/metadata-json-lint/actions/workflows/release.yml) [![RubyGem Version](https://img.shields.io/gem/v/metadata-json-lint.svg)](https://rubygems.org/gems/metadata-json-lint) [![RubyGem Downloads](https://img.shields.io/gem/dt/metadata-json-lint.svg)](https://rubygems.org/gems/metadata-json-lint) The metadata-json-lint tool validates and lints `metadata.json` files in Puppet modules against style guidelines from the [Puppet Forge module metadata](https://docs.puppet.com/puppet/latest/modules_publishing.html#write-a-metadatajson-file) recommendations. ## Compatibility metadata-json-lint is tested on Ruby 2.7 to 3.3. The the authoritative source, check the `required_ruby_version` attribute in the gemspec file. ## Installation via `gem` command: ``` shell gem install metadata-json-lint ``` via Gemfile: ``` ruby gem 'metadata-json-lint' ``` ## Usage ### Testing with metadata-json-lint On the command line, run `metadata-json-lint` with the path of your `metadata.json` file: ```shell metadata-json-lint /path/to/metadata.json ``` ### Testing with metadata-json-lint as a Rake task If you are already using `puppet_spec_helper`, the 'validate' task already includes `metadata-json-lint`. You can also integrate `metadata-json-lint` checks into your tests using the Rake task. Add `require 'metadata-json-lint/rake_task'` to your `Rakefile`, and then run: ```ruby rake metadata_lint ``` To set options for the Rake task, include them when you define the task: ```ruby require 'metadata_json_lint' task :metadata_lint do MetadataJsonLint.parse('metadata.json') do |options| options.strict_license = false end end ``` Alternatively, set the option after requiring the Rake task: ```ruby require 'metadata-json-lint/rake_task' MetadataJsonLint.options.strict_license = false ``` ### Options * `--[no-]strict-dependencies`: Whether to fail if module version dependencies are open-ended. Defaults to `false`. * `--[no-]strict-license`: Whether to fail on strict license check. Defaults to `true`. * `--[no-]fail-on-warnings`: Whether to fail on warnings. Defaults to `true`. * `--[no-]strict-puppet-version`: Whether to fail if Puppet version requirements are open-ended or no longer supported. Defaults to `false`. ## Contributors A big thank you to the [contributors](https://github.com/voxpupuli/metadata-json-lint/graphs/contributors). ## Making a new release How to make a new release? * update the gemspec file with the desired version ```console $ git diff diff --git a/metadata-json-lint.gemspec b/metadata-json-lint.gemspec index c86668e..6a3ad38 100644 --- a/metadata-json-lint.gemspec +++ b/metadata-json-lint.gemspec @@ -2,7 +2,7 @@ require 'date' Gem::Specification.new do |s| s.name = 'metadata-json-lint' - s.version = '2.4.0' + s.version = '2.5.0' s.date = Date.today.to_s s.summary = 'metadata-json-lint /path/to/metadata.json' s.description = 'Utility to verify Puppet metadata.json files' ``` * export a GitHub access token as environment variable: ```console export CHANGELOG_GITHUB_TOKEN=*token* ``` * Install deps and generate the changelog ```console $ bundle install --path .vendor/ --jobs=$(nproc) --with release $ bundle exec rake changelog Found 25 tags Fetching tags dates: 25/25 Sorting tags... Received issues: 103 Pull Request count: 77 Filtered pull requests: 72 Filtered issues: 26 Fetching events for issues and PR: 98 Fetching closed dates for issues: 98/98 Fetching SHAs for tags: 25 Associating PRs with tags: 72/72 Generating entry... Done! Generated log placed in ~/metadata-json-lint/CHANGELOG.md ``` * Check the diff for `CHANGELOG.md`. Does it contain a breaking change but the new version is only a minor bump? Does the new release only contains bug fixes? Adjust the version properly while honouring semantic versioning. If required, regenerate the `CHANGELOG.md`. Afterwards submit it as a PR. * If it gets approved, merge the PR, create a git tag on that and push it. metadata-json-lint-5.0.0/Rakefile000066400000000000000000000016741504664412400166720ustar00rootroot00000000000000desc 'Run all tests' task test: %i[spec test:acceptance] begin require 'voxpupuli/rubocop/rake' rescue LoadError # the voxpupuli-rubocop gem is optional end namespace :test do desc 'Acceptance suite under test/ which runs metadata-json-lint against sample files with expected output' task :acceptance do sh 'tests/test.sh' end end require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) begin require 'rubygems' require 'github_changelog_generator/task' rescue LoadError # github_changelog_generator is in the optional `release` group else GitHubChangelogGenerator::RakeTask.new :changelog do |config| config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog github_actions dependencies] config.user = 'voxpupuli' config.project = 'metadata-json-lint' gem_version = Gem::Specification.load("#{config.project}.gemspec").version config.future_release = gem_version end end metadata-json-lint-5.0.0/bin/000077500000000000000000000000001504664412400157655ustar00rootroot00000000000000metadata-json-lint-5.0.0/bin/metadata-json-lint000077500000000000000000000002531504664412400214060ustar00rootroot00000000000000#!/usr/bin/env ruby lib = File.expand_path('../lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'metadata_json_lint' MetadataJsonLint.run metadata-json-lint-5.0.0/lib/000077500000000000000000000000001504664412400157635ustar00rootroot00000000000000metadata-json-lint-5.0.0/lib/metadata-json-lint/000077500000000000000000000000001504664412400214565ustar00rootroot00000000000000metadata-json-lint-5.0.0/lib/metadata-json-lint/rake_task.rb000066400000000000000000000003401504664412400237440ustar00rootroot00000000000000require 'rake' require 'rake/tasklib' require 'metadata_json_lint' require 'json' desc 'Run metadata-json-lint' task :metadata_lint do abort if File.exist?('metadata.json') && !MetadataJsonLint.parse('metadata.json') end metadata-json-lint-5.0.0/lib/metadata-json-lint/schema.rb000066400000000000000000000116441504664412400232510ustar00rootroot00000000000000require 'json-schema' module MetadataJsonLint # Provides validation of metadata.json against a JSON schema document # maintained in this class. Provides a good first pass over the metadata with # type checking and basic format/length validations. ## schema data structure is quite large class Schema # Based on https://docs.puppet.com/puppet/latest/modules_metadata.html # def schema { '$schema' => 'http://json-schema.org/draft-04/schema#', 'properties' => { 'author' => { 'type' => 'string', }, 'data_provider' => { 'type' => %w[null string], }, 'dependencies' => { 'type' => 'array', 'items' => { 'properties' => { 'name' => { 'type' => 'string', 'pattern' => '^\w+[/-][a-z][a-z0-9_]*$', }, 'version_requirement' => { 'type' => 'string', }, }, 'required' => %w[ name ], }, }, 'description' => { 'type' => 'string', }, 'issues_url' => { 'type' => 'string', 'format' => 'uri', }, 'license' => { 'type' => 'string', }, 'operatingsystem_support' => { 'type' => 'array', 'items' => { 'properties' => { 'operatingsystem' => { 'type' => 'string', }, 'operatingsystemrelease' => { 'type' => 'array', 'items' => { 'type' => 'string', }, }, }, 'required' => %w[ operatingsystem ], }, }, 'name' => { 'type' => 'string', 'pattern' => '^\w+-[a-z][a-z0-9_]*$', }, 'project_page' => { 'type' => 'string', 'format' => 'uri', }, # Undocumented but in use: https://tickets.puppetlabs.com/browse/DOCUMENT-387 'requirements' => { 'type' => 'array', 'items' => { 'properties' => { 'name' => { 'type' => 'string', }, 'version_requirement' => { 'type' => 'string', }, }, 'required' => %w[ name ], }, }, 'source' => { 'type' => 'string', }, 'summary' => { 'type' => 'string', 'maxLength' => 144, }, 'tags' => { 'type' => 'array', 'items' => { 'type' => 'string', }, }, 'version' => { 'type' => 'string', 'format' => 'semver', }, }, # from https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file 'required' => %w[ author dependencies license name source summary version ], } end def validate(data, options = {}) JSON::Validator.register_format_validator('semver', method(:semver_validator)) JSON::Validator.fully_validate(schema, data, options.merge(errors_as_objects: true)).map do |error| field = error[:fragment].split('/')[1] field = 'root' if field.nil? || field.empty? message = error[:message] .sub(/ in schema [\w-]+/, '') # remove schema UUID, not needed in output .sub(%r{'#/}, "'") # remove root #/ prefix from document paths .sub("property ''", 'file') # call the root #/ node the file { field: field, message: message } end end private def semver_full_regex @semver_full_regex ||= begin # Version string matching regexes numeric = '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)' # Major . Minor . Patch pre = '(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?' # Prerelease build = '(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?' # Build full = numeric + pre + build /\A#{full}\Z/ end end def semver_validator(value) if defined?(SemanticPuppet::Version) begin SemanticPuppet::Version.parse(value) rescue SemanticPuppet::Version::ValidationFailure => e raise JSON::Schema::CustomFormatError, "must be a valid semantic version: #{e.message}" end elsif value.match(semver_full_regex).nil? raise JSON::Schema::CustomFormatError, "must be a valid semantic version: Unable to parse '#{value}' as a semantic version identifier" end end end end metadata-json-lint-5.0.0/lib/metadata-json-lint/version_requirement.rb000066400000000000000000000037201504664412400261120ustar00rootroot00000000000000module MetadataJsonLint # Parses a string module version requirement with semantic_puppet and # provides methods to analyse it for lint warnings class VersionRequirement def initialize(requirement) @requirement = requirement if defined?(SemanticPuppet::VersionRange) @range = SemanticPuppet::VersionRange.parse(requirement) if @range == SemanticPuppet::VersionRange::EMPTY_RANGE raise ArgumentError, "Range matches no versions: \"#{requirement}\"" end elsif requirement.match(/\A[a-z0-9*.\-^~><=|\t ]*\Z/i).nil? raise ArgumentError, "Unparsable version range: \"#{requirement}\"" end end # Whether the range uses a comparison operator (e.g. >=) with a wildcard # syntax, such as ">= 1.x" or "< 2.0.x" def mixed_syntax? !/ [><=^~]{1,2} # comparison operators \s* \d\. # MAJOR (?: (?:x|\*) # MINOR is wildcard | \d\.(?:x|\*) # MINOR is digit and PATCH is wildcard ) /x.match(requirement).nil? end def open_ended? if range range.end == SemanticPuppet::Version::MAX else # Empty requirement strings are open-ended. return true if requirement.strip.empty? # Strip superfluous whitespace. range_set = requirement.gsub(/([><=~^])(?:\s+|\s*v)/, '\1') # Split on logical OR ranges = range_set.split(/\s*\|\|\s*/) # Returns true if any range includes a '>' but not a corresponding '<' # which should be the only way to declare an open-ended range. ranges.select { |r| r.include?('>') }.any? { |r| !r.include?('<') } end end def puppet_eol? true if range.begin < SemanticPuppet::Version.parse(MIN_PUPPET_VER) end def ver_range range end def min range.begin end def max range.end end private attr_reader :range, :requirement end end metadata-json-lint-5.0.0/lib/metadata_json_lint.rb000066400000000000000000000223261504664412400221540ustar00rootroot00000000000000require 'json' require 'spdx-licenses' require 'optparse' require 'semantic_puppet' require 'metadata-json-lint/schema' require 'metadata-json-lint/version_requirement' module MetadataJsonLint MIN_PUPPET_VER = '4.10.0'.freeze # Regex looks for: # 1. Invalid escape sequences (\x or incomplete \u) INVALID_ESCAPE_REGEX = %r{\\[^"/bfnrtu]|\\u(?![0-9a-fA-F]{4})} def options @options ||= Struct.new( :fail_on_warnings, :strict_license, :strict_dependencies, :strict_puppet_version, :format, ).new( true, # fail_on_warnings true, # strict_license false, # strict_dependencies false, # strict_puppet_version 'text', # format ) end module_function :options def run OptionParser.new do |opts| opts.banner = 'Usage: metadata-json-lint [options] [metadata.json]' opts.on('--[no-]strict-dependencies', "Fail on open-ended module version dependencies. Defaults to '#{options[:strict_dependencies]}'.") do |v| options[:strict_dependencies] = v end opts.on('--[no-]strict-license', "Don't fail on strict license check. Defaults to '#{options[:strict_license]}'.") do |v| options[:strict_license] = v end opts.on('--[no-]fail-on-warnings', "Fail on any warnings. Defaults to '#{options[:fail_on_warnings]}'.") do |v| options[:fail_on_warnings] = v end opts.on('--[no-]strict-puppet-version', "Fail on strict Puppet Version check based on current supported Puppet versions. Defaults to '#{options[:strict_puppet_version]}'.") do |v| options[:strict_puppet_version] = v end opts.on('-f', '--format FORMAT', %i[text json], 'The format in which results will be output (text, json)') do |format| options[:format] = format end end.parse! mj = if ARGV[0].nil? if File.readable?('metadata.json') 'metadata.json' else abort('Error: metadata.json is not readable or does not exist.') end else ARGV[0] end exit(MetadataJsonLint.parse(mj) ? 0 : 1) end module_function :run def contains_invalid_escape?(content) content.match?(INVALID_ESCAPE_REGEX) end module_function :contains_invalid_escape? def misses_newline_at_end?(content) content[-1] != "\n" end module_function :misses_newline_at_end? def parse(metadata) @errors = [] @warnings = [] # Small hack to use the module settings as defaults but allow overriding for different rake tasks options = options().clone # Configuration from rake tasks yield options if block_given? begin f = File.read(metadata) rescue Exception => e abort("Error: Unable to read metadata file: #{e.exception}") end abort('Error: metadata.json does not have a valid newline at the end') if misses_newline_at_end?(f) abort('Error: Unable to parse metadata.json: Invalid escape character in string') if contains_invalid_escape?(f) begin parsed = JSON.parse(f) rescue Exception => e abort("Error: Unable to parse metadata.json: #{e.exception}") end # Validate basic structure against JSON schema schema_errors = Schema.new.validate(parsed) schema_errors.each do |err| error ((err[:field] == 'root') ? :required_fields : err[:field]), err[:message] end validate_dependencies!(parsed['dependencies']) if parsed['dependencies'] # Deprecated fields # From: https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file deprecated_fields = %w[types checksum] deprecated_fields.each do |field| error :deprecated_fields, "Deprecated field '#{field}' found in metadata.json." unless parsed[field].nil? end # The nested 'requirements' name of 'pe' is deprecated as well. # https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/puppet-users/nkRPvG4q0Oo/GmXa109aJQAJ validate_requirements!(parsed['requirements']) if parsed['requirements'] # Shoulds/recommendations # From: https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file # if options[:strict_license] && !parsed['license'].nil? && !SpdxLicenses.exist?(parsed['license']) && parsed['license'] != 'proprietary' msg = "License identifier #{parsed['license']} is not in the SPDX list: http://spdx.org/licenses/" warn(:license, msg) end if !@errors.empty? || !@warnings.empty? result = @errors.empty? ? "Warnings found in #{metadata}" : "Errors found in #{metadata}" case options[:format] when :json puts JSON.fast_generate(result: result, warnings: @warnings, errors: @errors) else @warnings.each { |warn| puts "(WARN) #{warn}" } @errors.each { |err| puts "(ERROR) #{err}" } puts result end return false if !@errors.empty? || (!@warnings.empty? && (options[:fail_on_warnings] == true)) end true end module_function :parse def validate_requirements_unique(requirements) names = requirements.map { |x| x['name'] } counts = Hash.new(0) names.each { |name| counts[name.downcase] += 1 } counts.each do |k, v| error :requirements, "Duplicate entries in the 'requirements' list with the name '#{k}'" if v > 1 end end module_function :validate_requirements_unique def validate_requirements!(requirements) return unless requirements.is_a?(Array) requirements.each do |requirement| warn :requirements, "The 'pe' requirement is no longer supported by the Forge." if requirement['name'] == 'pe' begin puppet_req = VersionRequirement.new(requirement.fetch('version_requirement', '')) rescue ArgumentError => e # Raised when the version_requirement provided could not be parsed error :requirements, "Invalid 'version_requirement' field in metadata.json: #{e}" end validate_puppet_ver!(puppet_req) unless puppet_req.instance_variable_get(:@requirement).nil? end validate_requirements_unique(requirements) end module_function :validate_requirements! def validate_puppet_ver!(requirement) if options[:strict_puppet_version] && requirement.open_ended? warn(:requirement, "Puppet has an open ended version requirement #{requirement.ver_range}") end if options[:strict_puppet_version] && requirement.puppet_eol? warn(:requirement, "#{requirement.min} is no longer supported. Minimum supported version is #{MIN_PUPPET_VER}") end return unless requirement.mixed_syntax? warn(:requirement, 'Mixing "x" or "*" version syntax with operators is not recommended in ' \ "metadata.json, use one style in the puppet version: #{requirement.instance_variable_get(:@requirement)}") end module_function :validate_puppet_ver! def validate_dependencies!(deps) dep_names = [] deps.each do |dep| warn :dependencies, "Duplicate dependencies on #{dep['name']}" if dep_names.include?(dep['name']) dep_names << dep['name'] begin requirement = VersionRequirement.new(dep.fetch('version_requirement', '')) rescue ArgumentError => e # Raised when the version_requirement provided could not be parsed error :dependencies, "Invalid 'version_requirement' field in metadata.json: #{e}" # Skip to the next dependency next end validate_version_requirement!(dep, requirement) # 'version_range' is no longer used by the forge # See https://tickets.puppetlabs.com/browse/PUP-2781 if dep.key?('version_range') warn :dependencies, "Dependency #{dep['name']} has a 'version_range' attribute " \ 'which is no longer used by the forge.' end end end module_function :validate_dependencies! def validate_version_requirement!(dep, requirement) # Open ended dependency # From: https://docs.puppet.com/puppet/latest/reference/modules_metadata.html#best-practice-set-an-upper-bound-for-dependencies if options[:strict_dependencies] && requirement.open_ended? msg = "Dependency #{dep['name']} has an open " \ "ended dependency version requirement #{dep['version_requirement']}" warn(:dependencies, msg) end # Mixing operator and wildcard version syntax # From: https://docs.puppet.com/puppet/latest/modules_metadata.html#version-specifiers # Supported in Puppet 5 and higher, but the syntax is unclear and incompatible with older versions return unless requirement.mixed_syntax? warn(:dependencies, 'Mixing "x" or "*" version syntax with operators is not recommended in ' \ "metadata.json, use one style in the #{dep['name']} dependency: #{dep['version_requirement']}") end module_function :validate_version_requirement! def format_error(check, msg) case options[:format] when :json { check: check, msg: msg } else "#{check}: #{msg}" end end module_function :format_error def warn(check, msg) @warnings ||= [] @warnings << format_error(check, msg) end module_function :warn def error(check, msg) @errors ||= [] @errors << format_error(check, msg) end module_function :error end metadata-json-lint-5.0.0/metadata-json-lint.gemspec000066400000000000000000000015541504664412400222620ustar00rootroot00000000000000Gem::Specification.new do |s| s.name = 'metadata-json-lint' s.version = '5.0.0' s.summary = 'metadata-json-lint /path/to/metadata.json' s.description = 'Utility to verify Puppet metadata.json files' s.authors = ['Vox Pupuli'] s.email = 'voxpupuli@groups.io' s.files = `git ls-files -z`.split("\x0") s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } s.homepage = 'https://github.com/voxpupuli/metadata-json-lint' s.license = 'Apache-2.0' s.required_ruby_version = '>= 3.2.0' s.add_dependency 'json-schema', '>= 2.8', '< 7.0' s.add_dependency 'semantic_puppet', '~> 1.0' s.add_dependency 'spdx-licenses', '~> 1.0' s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' s.add_development_dependency 'rspec', '~> 3.12' s.add_development_dependency 'voxpupuli-rubocop', '~> 4.2.0' end metadata-json-lint-5.0.0/spec/000077500000000000000000000000001504664412400161475ustar00rootroot00000000000000metadata-json-lint-5.0.0/spec/metadata_json_lint/000077500000000000000000000000001504664412400220065ustar00rootroot00000000000000metadata-json-lint-5.0.0/spec/metadata_json_lint/schema_spec.rb000066400000000000000000000034721504664412400246130ustar00rootroot00000000000000describe MetadataJsonLint::Schema do describe '#schema' do it { expect(subject.schema).to be_a(Hash) } end describe '#validate' do let(:minimal) do { author: '', dependencies: [], license: 'A', name: 'a-a', source: '', summary: '', version: '1.0.0' } end context 'with empty hash' do subject { described_class.new.validate({}) } it { is_expected.to be_a(Array) } it { expect(subject.size).to eq(7) } it { is_expected.to include(field: 'root', message: "The file did not contain a required property of 'author'") } end context 'with minimal entries' do subject { described_class.new.validate(minimal) } it { is_expected.to eq([]) } end context 'with validation error on entry' do subject { described_class.new.validate(minimal.merge(summary: 'A' * 145)) } it { expect(subject).to eq([{ field: 'summary', message: "The property 'summary' was not of a maximum string length of 144", }]) } end context 'with validation error on nested entry' do subject { described_class.new.validate(minimal.merge(dependencies: [{ name: 'in###id' }])) } it { expect(subject.size).to eq(1) } it { expect(subject).to include(field: 'dependencies', message: a_string_matching(%r{The property 'dependencies/0/name' value "in###id" did not match the regex})) } end context 'with semver validation failure' do subject { described_class.new.validate(minimal.merge(version: 'a')) } it { expect(subject.size).to eq(1) } it { expect(subject).to include(field: 'version', message: a_string_matching(/The property 'version' must be a valid semantic version/)) } end end end metadata-json-lint-5.0.0/spec/metadata_json_lint/version_requirement_spec.rb000066400000000000000000000027041504664412400274550ustar00rootroot00000000000000describe MetadataJsonLint::VersionRequirement do describe '.new' do it { expect(described_class.new('')).to be_a(MetadataJsonLint::VersionRequirement) } it { expect(described_class.new('>= 1.0')).to be_a(MetadataJsonLint::VersionRequirement) } it { expect { described_class.new('## 1.0') }.to raise_error(ArgumentError) } end describe '#mixed_syntax?' do it { expect(described_class.new('>= 1.0.0').mixed_syntax?).to be false } it { expect(described_class.new('1.0.x').mixed_syntax?).to be false } it { expect(described_class.new('>= 1.0.0 < 2.0').mixed_syntax?).to be false } it { expect(described_class.new('< 2.0').mixed_syntax?).to be false } it { expect(described_class.new('>= 1.0.x').mixed_syntax?).to be true } it { expect(described_class.new('>= 1.0.*').mixed_syntax?).to be true } it { expect(described_class.new('>= 1.x').mixed_syntax?).to be true } it { expect(described_class.new('>= 1.x.x').mixed_syntax?).to be true } it { expect(described_class.new('>= 1.*').mixed_syntax?).to be true } it { expect(described_class.new('>= 1.0.0 < 2.x').mixed_syntax?).to be true } it { expect(described_class.new('<2.x').mixed_syntax?).to be true } end describe '#open_ended?' do it { expect(described_class.new('>= 1.0 < 2.0').open_ended?).to be false } it { expect(described_class.new('>= 1.0').open_ended?).to be true } it { expect(described_class.new('').open_ended?).to be true } end end metadata-json-lint-5.0.0/spec/metadata_json_lint_spec.rb000066400000000000000000000034471504664412400233550ustar00rootroot00000000000000describe MetadataJsonLint do describe '.validate_requirements!' do context 'empty requirements' do let :requirements do [] end it { expect { described_class.validate_requirements!(requirements) }.not_to raise_error } end context 'with openvox' do let :requirements do [ { 'name' => 'openvox', 'version_requirement' => '>= 7.0.0 < 9.0.0' }, ] end it { expect { described_class.validate_requirements!(requirements) }.not_to raise_error } end context 'with openvox and puppet' do let :requirements do [ { 'name' => 'puppet', 'version_requirement' => '>= 6.0.0 < 8.0.0' }, { 'name' => 'openvox', 'version_requirement' => '>= 7.0.0 < 9.0.0' }, ] end it { expect { described_class.validate_requirements!(requirements) }.not_to raise_error } end context 'with pe' do let :requirements do [ { 'name' => 'pe' }, ] end it do expect(described_class).to receive('warn').with(:requirements, "The 'pe' requirement is no longer supported by the Forge.") expect { described_class.validate_requirements!(requirements) }.not_to raise_error end end context 'with invalid requirement' do let :requirements do [ { 'name' => 'puppet', 'version_requirement' => 'a' }, ] end it do expect(described_class).to receive('error').with(:requirements, "Invalid 'version_requirement' field in metadata.json: Unparsable version range: \"a\"") expect { described_class.validate_requirements!(requirements) }.not_to raise_error end end end end metadata-json-lint-5.0.0/spec/spec_helper.rb000066400000000000000000000032271504664412400207710ustar00rootroot00000000000000require 'metadata_json_lint' # This file was generated by the `rspec --init` command # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer. config.expect_with :rspec do |expectations| # This option will default to `true` in RSpec 4. It makes the `description` # and `failure_message` of custom matchers include text for helper methods # defined using `chain`, e.g.: # be_bigger_than(2).and_smaller_than(4).description # # => "be bigger than 2 and smaller than 4" # ...rather than: # # => "be bigger than 2" expectations.include_chain_clauses_in_custom_matcher_descriptions = true end # rspec-mocks config goes here. You can use an alternate test double # library (such as bogus or mocha) by changing the `mock_with` option here. config.mock_with :rspec do |mocks| # Prevents you from mocking or stubbing a method that does not exist on # a real object. This is generally recommended, and will default to # `true` in RSpec 4. mocks.verify_partial_doubles = true end # This option will default to `:apply_to_host_groups` in RSpec 4 (and will # have no way to turn it off -- the option exists only for backwards # compatibility in RSpec 3). It causes shared context metadata to be # inherited by the metadata hash of host groups and examples, rather than # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups end metadata-json-lint-5.0.0/tests/000077500000000000000000000000001504664412400163575ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/bad_license/000077500000000000000000000000001504664412400206075ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/bad_license/Rakefile000066400000000000000000000001421504664412400222510ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/bad_license/expected000066400000000000000000000001221504664412400223260ustar00rootroot00000000000000License identifier Unknown-1.0 is not in the SPDX list: http://spdx.org/licenses/ metadata-json-lint-5.0.0/tests/bad_license/metadata.json000066400000000000000000000032161504664412400232640ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Unknown-1.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/firewall", "version_requirement": ">= 0.0.4 <1.0.0" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/broken/000077500000000000000000000000001504664412400176375ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/broken/Rakefile000066400000000000000000000001421504664412400213010ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/broken/expected000066400000000000000000000000471504664412400213640ustar00rootroot00000000000000Error: Unable to parse metadata.json: metadata-json-lint-5.0.0/tests/broken/metadata.json000066400000000000000000000033261504664412400223160ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql" "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/firewall", "version_requirement": ">= 0.0.4" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/duplicate-dep/000077500000000000000000000000001504664412400210775ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/duplicate-dep/Rakefile000066400000000000000000000001421504664412400225410ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/duplicate-dep/expected000066400000000000000000000000541504664412400226220ustar00rootroot00000000000000Duplicate dependencies on puppetlabs/stdlib metadata-json-lint-5.0.0/tests/duplicate-dep/metadata.json000066400000000000000000000033331504664412400235540ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "5.5.1" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/firewall", "version_requirement": ">= 0.0.4" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/duplicate-requirement/000077500000000000000000000000001504664412400226675ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/duplicate-requirement/Rakefile000066400000000000000000000001421504664412400243310ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/duplicate-requirement/expected000066400000000000000000000001041504664412400244060ustar00rootroot00000000000000Duplicate entries in the 'requirements' list with the name 'puppet' metadata-json-lint-5.0.0/tests/duplicate-requirement/metadata.json000066400000000000000000000033231504664412400253430ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "5.5.1" }, { "name": "puppet", "version_requirement": "6.11.0" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/firewall", "version_requirement": ">= 0.0.4" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/invalid_escape_char/000077500000000000000000000000001504664412400223225ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/invalid_escape_char/Rakefile000066400000000000000000000001421504664412400237640ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/invalid_escape_char/expected000066400000000000000000000001111504664412400240370ustar00rootroot00000000000000Error: Unable to parse metadata.json: Invalid escape character in string metadata-json-lint-5.0.0/tests/invalid_escape_char/metadata.json000066400000000000000000000007411504664412400247770ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "A description with an invalid \( escape sequence", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ ], "requirements": [ ], "dependencies": [ ] } metadata-json-lint-5.0.0/tests/json_format/000077500000000000000000000000001504664412400207005ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/json_format/Rakefile000066400000000000000000000001421504664412400223420ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/json_format/expected000066400000000000000000000001751504664412400224270ustar00rootroot00000000000000"warnings":\[{"check":"license","msg":"License identifier Unknown-1.0 is not in the SPDX list: http://spdx.org/licenses/"}\] metadata-json-lint-5.0.0/tests/json_format/metadata.json000066400000000000000000000032161504664412400233550ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Unknown-1.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/firewall", "version_requirement": ">= 0.0.4 <1.0.0" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/long_summary/000077500000000000000000000000001504664412400210735ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/long_summary/Rakefile000066400000000000000000000001421504664412400225350ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/long_summary/expected000066400000000000000000000001221504664412400226120ustar00rootroot00000000000000(ERROR) summary: The property 'summary' was not of a maximum string length of 144 metadata-json-lint-5.0.0/tests/long_summary/metadata.json000066400000000000000000000010211504664412400235400ustar00rootroot00000000000000{ "name": "foo-bar", "version": "1.0.0", "author": "foo/bar", "summary": "This is obviously a way way tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long", "license": "Apache-2.0", "source": "", "project_page": "", "issues_url": "", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] } ], "requirements": [ ], "dependencies": [ ] } metadata-json-lint-5.0.0/tests/missing_newline/000077500000000000000000000000001504664412400215515ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/missing_newline/Rakefile000066400000000000000000000001421504664412400232130ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/missing_newline/expected000066400000000000000000000000761504664412400233000ustar00rootroot00000000000000Error: metadata.json does not have a valid newline at the end metadata-json-lint-5.0.0/tests/missing_newline/metadata.json000066400000000000000000000007411504664412400242260ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "A metadata.json file without a newline at the end", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ ], "requirements": [ ], "dependencies": [ ] }metadata-json-lint-5.0.0/tests/missing_version_requirement/000077500000000000000000000000001504664412400242155ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/missing_version_requirement/Rakefile000066400000000000000000000001421504664412400256570ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/missing_version_requirement/expected000066400000000000000000000001161504664412400257370ustar00rootroot00000000000000Dependency puppetlabs/stdlib has an open ended dependency version requirement metadata-json-lint-5.0.0/tests/missing_version_requirement/metadata.json000066400000000000000000000012421504664412400266670ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "7" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib" } ] } metadata-json-lint-5.0.0/tests/mixed_version_syntax/000077500000000000000000000000001504664412400226405ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/mixed_version_syntax/Rakefile000066400000000000000000000001421504664412400243020ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/mixed_version_syntax/expected000066400000000000000000000002471504664412400243670ustar00rootroot00000000000000(WARN) dependencies: Mixing "x" or "\*" version syntax with operators is not recommended in metadata.json, use one style in the puppetlabs/stdlib dependency: >= 3.2.x metadata-json-lint-5.0.0/tests/mixed_version_syntax/metadata.json000066400000000000000000000013251504664412400253140ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "7" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 3.2.x" } ] } metadata-json-lint-5.0.0/tests/multiple_problems/000077500000000000000000000000001504664412400221155ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/multiple_problems/Rakefile000066400000000000000000000001421504664412400235570ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/multiple_problems/expected000066400000000000000000000002331504664412400236370ustar00rootroot00000000000000Required field 'license' not found in metadata.json. Required field 'summary' not found in metadata.json. Deprecated field 'types' found in metadata.json. metadata-json-lint-5.0.0/tests/multiple_problems/metadata.json000066400000000000000000000032361504664412400245740ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "types": "stuff", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/firewall", "version_requirement": ">= 0.0.4" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/no_dependencies/000077500000000000000000000000001504664412400215015ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/no_dependencies/Rakefile000066400000000000000000000001421504664412400231430ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/no_dependencies/metadata.json000066400000000000000000000024351504664412400241600ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [] } metadata-json-lint-5.0.0/tests/no_files/000077500000000000000000000000001504664412400201555ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/no_files/.gitkeep000066400000000000000000000000001504664412400215740ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/no_files/expected000066400000000000000000000000771504664412400217050ustar00rootroot00000000000000Error: Unable to read metadata file: No such file or directory metadata-json-lint-5.0.0/tests/no_pe/000077500000000000000000000000001504664412400174575ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/no_pe/Rakefile000066400000000000000000000001421504664412400211210ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/no_pe/metadata.json000066400000000000000000000013631504664412400221350ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "7" ] } ], "requirements": [ { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib" } ] } metadata-json-lint-5.0.0/tests/no_version_range/000077500000000000000000000000001504664412400217145ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/no_version_range/Rakefile000066400000000000000000000001421504664412400233560ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/no_version_range/metadata.json000066400000000000000000000014401504664412400243660ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "7" ] } ], "requirements": [ { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_range": ">= 1.0.0" } ] } metadata-json-lint-5.0.0/tests/non_array_requirements/000077500000000000000000000000001504664412400231525ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/non_array_requirements/Rakefile000066400000000000000000000001421504664412400246140ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/non_array_requirements/expected000066400000000000000000000001511504664412400246730ustar00rootroot00000000000000(ERROR) requirements: The property 'requirements' of type string did not match the following type: array metadata-json-lint-5.0.0/tests/non_array_requirements/metadata.json000066400000000000000000000023271504664412400256310ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": "aoeu", "dependencies": [] } metadata-json-lint-5.0.0/tests/noname/000077500000000000000000000000001504664412400176345ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/noname/Rakefile000066400000000000000000000001421504664412400212760ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/noname/expected000066400000000000000000000001201504664412400213510ustar00rootroot00000000000000(ERROR) required_fields: The file did not contain a required property of 'name' metadata-json-lint-5.0.0/tests/noname/metadata.json000066400000000000000000000032641504664412400223140ustar00rootroot00000000000000{ "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/firewall", "version_requirement": ">= 0.0.4" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/open_ended_dependency/000077500000000000000000000000001504664412400226555ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/open_ended_dependency/Rakefile000066400000000000000000000001421504664412400243170ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/open_ended_dependency/expected000066400000000000000000000001271504664412400244010ustar00rootroot00000000000000Dependency puppetlabs/stdlib has an open ended dependency version requirement >= 3.2.0 metadata-json-lint-5.0.0/tests/open_ended_dependency/metadata.json000066400000000000000000000013251504664412400253310ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "7" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 3.2.0" } ] } metadata-json-lint-5.0.0/tests/perfect/000077500000000000000000000000001504664412400200075ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/perfect/Rakefile000066400000000000000000000001421504664412400214510ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/perfect/metadata.json000066400000000000000000000034531504664412400224670ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "1.2.3" }, { "name": "puppetlabs/apt", "version_requirement": "< 1.2.3" }, { "name": "puppetlabs/puppetdb", "version_requirement": "<= 1.2.3" }, { "name": "puppetlabs/vcsrepo", "version_requirement": ">= 1.0.0 < 2.0.0" }, { "name": "puppetlabs/rabbitmq", "version_requirement": "1.x" }, { "name": "puppetlabs/motd", "version_requirement": "1.2.x" } ] } metadata-json-lint-5.0.0/tests/proprietary/000077500000000000000000000000001504664412400207375ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/proprietary/Rakefile000066400000000000000000000001421504664412400224010ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/proprietary/metadata.json000066400000000000000000000030551504664412400234150ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "proprietary", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/rake_chaining/000077500000000000000000000000001504664412400211415ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/rake_chaining/Rakefile000066400000000000000000000002721504664412400226070ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' task test: %i[metadata_lint success] task :success do puts 'Successfully linted' end metadata-json-lint-5.0.0/tests/rake_chaining/metadata.json000066400000000000000000000034531504664412400236210ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "1.2.3" }, { "name": "puppetlabs/apt", "version_requirement": "< 1.2.3" }, { "name": "puppetlabs/puppetdb", "version_requirement": "<= 1.2.3" }, { "name": "puppetlabs/vcsrepo", "version_requirement": ">= 1.0.0 < 2.0.0" }, { "name": "puppetlabs/rabbitmq", "version_requirement": "1.x" }, { "name": "puppetlabs/motd", "version_requirement": "1.2.x" } ] } metadata-json-lint-5.0.0/tests/rake_global_options/000077500000000000000000000000001504664412400223745ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/rake_global_options/Rakefile000066400000000000000000000003041504664412400240360ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' MetadataJsonLint.options.strict_license = false MetadataJsonLint.options.fail_on_warnings = false metadata-json-lint-5.0.0/tests/rake_global_options/expected000066400000000000000000000001261504664412400241170ustar00rootroot00000000000000License identifier invalid_license is not in the SPDX list: http://spdx.org/licenses/ metadata-json-lint-5.0.0/tests/rake_global_options/metadata.json000066400000000000000000000030611504664412400250470ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "invalid_license", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/rake_multiple_json_options/000077500000000000000000000000001504664412400240205ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/rake_multiple_json_options/Rakefile000066400000000000000000000007221504664412400254660ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata_json_lint' MetadataJsonLint.options.fail_on_warnings = false desc "Test metadata_lint on multiple files. Don't fail" task :metadata_lint_multi do MetadataJsonLint.parse('metadata_license.json') do |options| options.strict_license = false end MetadataJsonLint.parse('metadata_ok.json') do |options| options.strict_license = true options.fail_on_warnings = true end end metadata-json-lint-5.0.0/tests/rake_multiple_json_options/metadata_license.json000066400000000000000000000030611504664412400301750ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "invalid_license", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/rake_multiple_json_options/metadata_ok.json000066400000000000000000000030541504664412400271660ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] } metadata-json-lint-5.0.0/tests/requirements_eol_version/000077500000000000000000000000001504664412400235065ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/requirements_eol_version/Rakefile000066400000000000000000000001421504664412400251500ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/requirements_eol_version/expected000066400000000000000000000003141504664412400252300ustar00rootroot00000000000000(WARN) requirements: 3.2.0 is no longer supported. Minimum supported version is 4.10.0(WARN) requirement: 3.2.0 is no longer supported. Minimum supported version is 4.10.0 Warnings found in metadata.json metadata-json-lint-5.0.0/tests/requirements_eol_version/metadata.json000066400000000000000000000035071504664412400261660ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "tags": [ "postgres" ], "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.2.0" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "1.2.3" }, { "name": "puppetlabs/apt", "version_requirement": "< 1.2.3" }, { "name": "puppetlabs/puppetdb", "version_requirement": "<= 1.2.3" }, { "name": "puppetlabs/vcsrepo", "version_requirement": ">= 1.0.0 < 2.0.0" }, { "name": "puppetlabs/rabbitmq", "version_requirement": "1.x" }, { "name": "puppetlabs/motd", "version_requirement": "1.2.x" } ] } metadata-json-lint-5.0.0/tests/tags_no_array/000077500000000000000000000000001504664412400212075ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/tags_no_array/Rakefile000066400000000000000000000001421504664412400226510ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/tags_no_array/expected000066400000000000000000000001311504664412400227260ustar00rootroot00000000000000(ERROR) tags: The property 'tags' of type string did not match the following type: array metadata-json-lint-5.0.0/tests/tags_no_array/metadata.json000066400000000000000000000036221504664412400236650ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "tags": "postgres", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "1.2.3" }, { "name": "puppetlabs/apt", "version_requirement": "< 1.2.3" }, { "name": "puppetlabs/puppetdb", "version_requirement": "<= 1.2.3" }, { "name": "puppetlabs/vcsrepo", "version_requirement": ">= 1.0.0 < 2.0.0" }, { "name": "puppetlabs/rabbitmq", "version_requirement": "1.x" }, { "name": "puppetlabs/motd", "version_requirement": "1.2.x" } ] } metadata-json-lint-5.0.0/tests/tags_with_array/000077500000000000000000000000001504664412400215465ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/tags_with_array/Rakefile000066400000000000000000000001421504664412400232100ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/tags_with_array/metadata.json000066400000000000000000000035031504664412400242220ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "tags": ["postgres"], "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "1.2.3" }, { "name": "puppetlabs/apt", "version_requirement": "< 1.2.3" }, { "name": "puppetlabs/puppetdb", "version_requirement": "<= 1.2.3" }, { "name": "puppetlabs/vcsrepo", "version_requirement": ">= 1.0.0 < 2.0.0" }, { "name": "puppetlabs/rabbitmq", "version_requirement": "1.x" }, { "name": "puppetlabs/motd", "version_requirement": "1.2.x" } ] } metadata-json-lint-5.0.0/tests/test.sh000077500000000000000000000133511504664412400177000ustar00rootroot00000000000000#!/bin/bash set -u # Ensure this can be called from outside its directory. cd $(dirname $0) SUCCESS=0 FAILURE=1 STATUS=0 fail() { echo $* STATUS=1 } # Tests the metadata-json-lint bin and if no additional arguments are given, also the rake task. test() { local name=$1; shift local expect=$1; shift test_bin $name $expect $* # Only check the Rakefile when no additional arguments were passed to metadata-json-lint. # In these cases, rake will likely have the opposite return code and cause false failures. if [ $# -eq 0 ]; then test_rake $name $expect metadata_lint fi } test_bin() { local name=$1; shift local expect=$1; shift local RESULT=-1 cd $name; bundle exec metadata-json-lint $* metadata.json >last_output 2>&1 RESULT=$? if [ $RESULT -ne $expect ]; then fail "Failing Test '${name}' (unexpected exit code '${RESULT}' instead of '${expect}') (bin)" echo " Note: you can examine '${name}/last_output' for any output" else # If the test is not expected to succeed then it should match an expected output if [ $expect -eq $SUCCESS ]; then echo "Successful Test '${name}' (bin)" else if [ -f expected ]; then if grep --quiet -f expected last_output; then echo "Successful Test '${name}' (bin)" else fail "Failing Test '${name}' (did not get expected output) (bin)" echo " Comparing '${name}/expected' with '${name}/last_output':" echo " Expected: '`cat expected`'" echo " Actual: '`cat last_output`'" fi else fail "Failing Test '${name}' (expected output file ${name}/expected is missing) (bin)" echo " Actual output that needs tested ('${name}/last_output'): '`cat last_output`'" fi fi fi cd .. } test_rake() { local name=$1; shift local expect=$1; shift local rake_task="${1-metadata_lint}" local RESULT=-1; cd $name; bundle exec rake $rake_task >last_rake_output 2>&1 RESULT=$? if [ $RESULT -ne $expect ]; then fail "Failing Test '${name}' (rake: ${rake_task})" else echo "Successful Test '${name}' (rake: ${rake_task})" fi; cd .. } # Run a broken one, expect FAILURE test "broken" $FAILURE # Run a perfect one, expect SUCCESS test "perfect" $SUCCESS # Run a broken one, expect FAILURE test "noname" $FAILURE # Run a broken one, expect FAILURE test "types" $FAILURE # Run a broken one, expect FAILURE test "multiple_problems" $FAILURE # Run a broken one, expect FAILURE test "duplicate-dep" $FAILURE # Run with --no-fail-on-warnings, expect SUCCESS test "duplicate-dep" $SUCCESS --no-fail-on-warnings # Run a broken one, expect FAILURE test "bad_license" $FAILURE # Run with --no-strict-license only, expect SUCCESS test "bad_license" $SUCCESS --no-strict-license # Run with --no-fail-on-warnings, expect SUCCESS test "bad_license" $SUCCESS --no-fail-on-warnings # Run a broken one, expect FAILURE test "invalid_escape_char" $FAILURE # Run a broken one, expect FAILURE test "missing_newline" $FAILURE # Run a broken one, expect FAILURE test "long_summary" $FAILURE # Run a broken one, expect FAILURE test "mixed_version_syntax" $FAILURE # Run one with empty dependencies array, expect SUCCESS test "no_dependencies" $SUCCESS # Run one with open ended dependency, expect SUCCESS as strict deps is off by default test "open_ended_dependency" $SUCCESS # Run one with open ended dependency and --strict-dependencies, expect FAILURE test "open_ended_dependency" $FAILURE --strict-dependencies # Run one with open ended dependency and --strict-dependencies, but pass on warnings, expect SUCCESS test "open_ended_dependency" $SUCCESS --strict-dependencies --no-fail-on-warnings # Run one with missing version_requirement and --no-strict-dependency, expect SUCCESS test "missing_version_requirement" $SUCCESS # Run one with open ended dependency and --strict-dependencies, expect FAILURE test "missing_version_requirement" $FAILURE --strict-dependencies # Run one with open ended dependency and --strict-dependencies, but pass on warnings, expect SUCCESS test "missing_version_requirement" $SUCCESS --strict-dependencies --no-fail-on-warnings # Run test for "proprietary"-licensed modules, expect SUCCESS test "proprietary" $SUCCESS # Run without a metadata.json or Rakefile, expect FAILURE test "no_files" $FAILURE # Run with tags in an array in metadata.json, expect SUCCESS test "tags_with_array" $SUCCESS # Run with tags not in an array in metadata.json, expect FAILURE test "tags_no_array" $FAILURE # Run with json output format test "json_format" $FAILURE --format json # Run against a metadata.json with a string for the requirements test "non_array_requirements" $FAILURE # Run against a metadata.json with an unsupported minimum Puppet version for the requirements test "requirements_eol_version" $FAILURE --strict-puppet-version # Run a broken one, expect FAILURE test "duplicate-requirement" $FAILURE # Test running without specifying file to parse cd perfect bundle exec metadata-json-lint if [ $? -ne 0 ]; then fail "Failing Test 'running without specifying metadata.json' (bin)" else echo "Successful Test 'running without specifying metadata.json' (bin)" fi cd .. # Test changing the rake task using settings # The bin test will fail due to strict licensing # The rake test should pass due to licensing option being set in Rakefile test_bin "rake_global_options" $FAILURE test_rake "rake_global_options" $SUCCESS # Test multiple lints with different options test_rake "rake_multiple_json_options" $SUCCESS metadata_lint_multi # Test successful lint followed by further tasks test_rake "rake_chaining" $SUCCESS test if ! grep -qx "Successfully linted" rake_chaining/last_rake_output; then fail "Failing Test 'rake_chaining' failed to run second rake task" fi exit $STATUS metadata-json-lint-5.0.0/tests/types/000077500000000000000000000000001504664412400175235ustar00rootroot00000000000000metadata-json-lint-5.0.0/tests/types/Rakefile000066400000000000000000000001421504664412400211650ustar00rootroot00000000000000$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) require 'metadata-json-lint/rake_task' metadata-json-lint-5.0.0/tests/types/expected000066400000000000000000000000611504664412400212440ustar00rootroot00000000000000Deprecated field 'types' found in metadata.json. metadata-json-lint-5.0.0/tests/types/metadata.json000066400000000000000000000033531504664412400222020ustar00rootroot00000000000000{ "name": "puppetlabs-postgresql", "types": "balls", "version": "3.4.1", "author": "Inkling/Puppet Labs", "summary": "PostgreSQL defined resource types", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppet-postgresql.git", "project_page": "https://github.com/puppetlabs/puppet-postgresql", "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "4.x" }, { "name": "puppetlabs/firewall", "version_requirement": ">= 0.0.4" }, { "name": "puppetlabs/apt", "version_requirement": ">=1.1.0 <2.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 1.1.0 <2.0.0" } ] }