voxpupuli / metadata-json-lint

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

Lazy load metadata_json_lint #123

Open ekohl opened 1 year ago

ekohl commented 1 year ago

It should not be required to load the whole library just to define the rake task. This prevents pulling in many libraries when a user runs rake -T or an unrelated rake task.

codecov[bot] commented 1 year ago

Codecov Report

Base: 50.23% // Head: 50.47% // Increases project coverage by +0.23% :tada:

Coverage data is based on head (e65068d) compared to base (e089948). Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #123 +/- ## ========================================== + Coverage 50.23% 50.47% +0.23% ========================================== Files 5 5 Lines 211 210 -1 ========================================== Hits 106 106 + Misses 105 104 -1 ``` | [Impacted Files](https://codecov.io/gh/voxpupuli/metadata-json-lint/pull/123?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli) | Coverage Δ | | |---|---|---| | [lib/metadata-json-lint/rake\_task.rb](https://codecov.io/gh/voxpupuli/metadata-json-lint/pull/123?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli#diff-bGliL21ldGFkYXRhLWpzb24tbGludC9yYWtlX3Rhc2sucmI=) | `0.00% <0.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

ekohl commented 1 year ago

The test now fails with:

$ be rake -T 
rake aborted!
NameError: uninitialized constant MetadataJsonLint

MetadataJsonLint.options.strict_license = false
^^^^^^^^^^^^^^^^
/home/ekohl/dev/metadata-json-lint/tests/rake_global_options/Rakefile:3:in `<top (required)>'
/home/ekohl/.gem/ruby/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:58:in `load'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:23:in `run'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/cli.rb:486:in `exec'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/cli.rb:31:in `dispatch'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/cli.rb:25:in `start'
/usr/share/gems/gems/bundler-2.3.26/libexec/bundle:48:in `block in <top (required)>'
/usr/share/gems/gems/bundler-2.3.26/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/usr/share/gems/gems/bundler-2.3.26/libexec/bundle:36:in `<top (required)>'
/home/ekohl/bin/bundle:23:in `load'
/home/ekohl/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)

So I guess this is incompatible. Perhaps I should utilize autoload like I did in https://github.com/voxpupuli/puppet-syntax/pull/134 instead.

ekohl commented 1 year ago

https://github.com/voxpupuli/metadata-json-lint/pull/124 may be a better idea.