metadata-json-lint 4.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1327a043726b715003e697e9024bda80b0134896e7fb2b97f9de14ee8b28e8b7
4
- data.tar.gz: ff6e85957f67e2d1b2a37f2a9383640867bf7bf4f04cc1ed5bc10ed7b9c738fb
3
+ metadata.gz: b60ce6545987408a2b495837f6817aec37c8caf185ed8d607ecc2067421e4604
4
+ data.tar.gz: b945326563aa3db151f3c11dc52bb8a3aca36920d541dc3a23a2ed1bb0c85ee3
5
5
  SHA512:
6
- metadata.gz: 841c877388db1e132ba061ef657f21f63b5f10b68255b96a673b1a79a5d4052327a54cc696a99c850addb4f8c830dab139c9891ae35ecf7444e83d53e8d86cc2
7
- data.tar.gz: caf5db87f9dd3fa2a33fb75b36992f6447ec80c335c0757246d6c9be7d22019581464ee6bc65f26549f162f6cc3ac9efb6ee9f3cbe546af5465f414882179e1c
6
+ metadata.gz: 6248271c94ffdaa61d9236884c01af123114f14850885f09d7699ebeaa639f262fc476834781b80c6ae413ef434b8cec269368f63a54681f8c39ad178a1a640f
7
+ data.tar.gz: 61690474cee73b0fc0f14a32dd9c87d3a82ea682a3754e695acc4c87d261093f531ad0407a95d91d68d317ba8c5cd409bb9d80ff8c995a90d40b35240fe7cdb6
@@ -11,10 +11,10 @@ jobs:
11
11
  if: github.repository_owner == 'voxpupuli'
12
12
  steps:
13
13
  - uses: actions/checkout@v4
14
- - name: Install Ruby 3.0
14
+ - name: Install Ruby 3.4
15
15
  uses: ruby/setup-ruby@v1
16
16
  with:
17
- ruby-version: '3.0'
17
+ ruby-version: '3.4'
18
18
  env:
19
19
  BUNDLE_WITHOUT: release
20
20
  - name: Build gem
@@ -10,48 +10,45 @@ env:
10
10
  BUNDLE_WITHOUT: release
11
11
 
12
12
  jobs:
13
- rubocop:
13
+ rubocop_and_matrix:
14
14
  runs-on: ubuntu-latest
15
+ outputs:
16
+ ruby: ${{ steps.ruby.outputs.versions }}
15
17
  steps:
16
18
  - uses: actions/checkout@v4
17
- - name: Install Ruby ${{ matrix.ruby }}
19
+ - name: Install Ruby 3.4
18
20
  uses: ruby/setup-ruby@v1
19
21
  with:
20
- ruby-version: "3.0"
22
+ ruby-version: '3.4'
21
23
  bundler-cache: true
22
- - name: Run Rubocop
24
+ - name: Run RuboCop
23
25
  run: bundle exec rake rubocop
24
- rspec:
26
+ - id: ruby
27
+ uses: voxpupuli/ruby-version@v1
28
+
29
+ test:
30
+ name: "Ruby ${{ matrix.ruby }}"
25
31
  runs-on: ubuntu-latest
32
+ needs: rubocop_and_matrix
26
33
  strategy:
34
+ fail-fast: false
27
35
  matrix:
28
- include:
29
- - ruby: "2.7"
30
- - ruby: "3.0"
31
- - ruby: "3.1"
32
- coverage: "yes"
33
- - ruby: "3.2"
34
- env:
35
- COVERAGE: ${{ matrix.coverage }}
36
- # https://github.com/rubygems/rubygems/issues/5234#issuecomment-1003773622
37
- RUBYOPT: '--disable-did_you_mean'
38
- name: RSpec - Ruby ${{ matrix.ruby }}
36
+ ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }}
39
37
  steps:
40
38
  - uses: actions/checkout@v4
41
- - name: Install Ruby ${{ matrix.ruby }}
39
+ - name: Setup ruby
42
40
  uses: ruby/setup-ruby@v1
43
41
  with:
44
42
  ruby-version: ${{ matrix.ruby }}
45
43
  bundler-cache: true
46
- - name: spec tests
44
+ - name: Run tests
47
45
  run: bundle exec rake test
48
- - name: Verify gem builds
46
+ - name: Build the gem
49
47
  run: gem build --strict --verbose *.gemspec
50
48
 
51
49
  tests:
52
50
  needs:
53
- - rubocop
54
- - rspec
51
+ - test
55
52
  runs-on: ubuntu-latest
56
53
  name: Test suite
57
54
  steps:
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2023-09-15 14:22:01 UTC using RuboCop version 1.54.2.
3
+ # on 2024-06-20 08:26:07 UTC using RuboCop version 1.63.5.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -20,19 +20,11 @@ RSpec/ContextWording:
20
20
 
21
21
  # Offense count: 2
22
22
  # This cop supports unsafe autocorrection (--autocorrect-all).
23
- # Configuration parameters: SkipBlocks, EnforcedStyle.
23
+ # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
24
24
  # SupportedStyles: described_class, explicit
25
25
  RSpec/DescribedClass:
26
26
  Exclude:
27
- - 'spec/version_requirement_spec.rb'
28
-
29
- # Offense count: 2
30
- # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
31
- # Include: **/*_spec*rb*, **/spec/**/*
32
- RSpec/FilePath:
33
- Exclude:
34
- - 'spec/schema_spec.rb'
35
- - 'spec/version_requirement_spec.rb'
27
+ - 'spec/metadata_json_lint/version_requirement_spec.rb'
36
28
 
37
29
  # Offense count: 2
38
30
  # Configuration parameters: .
@@ -49,7 +41,7 @@ RSpec/MultipleExpectations:
49
41
  # SupportedStyles: always, named_only
50
42
  RSpec/NamedSubject:
51
43
  Exclude:
52
- - 'spec/schema_spec.rb'
44
+ - 'spec/metadata_json_lint/schema_spec.rb'
53
45
 
54
46
  # Offense count: 1
55
47
  # Configuration parameters: AllowedConstants.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.2.0](https://github.com/voxpupuli/metadata-json-lint/tree/4.2.0) (2025-01-24)
4
+
5
+ [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.1.0...4.2.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Fail if metadata.json has no proper newline [\#154](https://github.com/voxpupuli/metadata-json-lint/pull/154) ([bastelfreak](https://github.com/bastelfreak))
10
+ - Fail on escape sequences in metadata.json [\#152](https://github.com/voxpupuli/metadata-json-lint/pull/152) ([bastelfreak](https://github.com/bastelfreak))
11
+ - Rake: Use RuboCop tasks from voxpupuli-rubocop [\#150](https://github.com/voxpupuli/metadata-json-lint/pull/150) ([bastelfreak](https://github.com/bastelfreak))
12
+ - Add Ruby 3.4 to CI [\#149](https://github.com/voxpupuli/metadata-json-lint/pull/149) ([bastelfreak](https://github.com/bastelfreak))
13
+
14
+ **Merged pull requests:**
15
+
16
+ - CI: Switch to voxpupuli/ruby-version [\#156](https://github.com/voxpupuli/metadata-json-lint/pull/156) ([bastelfreak](https://github.com/bastelfreak))
17
+ - Drop code coverage in testing [\#153](https://github.com/voxpupuli/metadata-json-lint/pull/153) ([ekohl](https://github.com/ekohl))
18
+ - Update voxpupuli-rubocop requirement from ~\> 2.8.0 to ~\> 3.0.0 [\#147](https://github.com/voxpupuli/metadata-json-lint/pull/147) ([dependabot[bot]](https://github.com/apps/dependabot))
19
+
20
+ ## [4.1.0](https://github.com/voxpupuli/metadata-json-lint/tree/4.1.0) (2024-08-19)
21
+
22
+ [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.0.0...4.1.0)
23
+
24
+ **Implemented enhancements:**
25
+
26
+ - json-schema: Allow 5.x [\#145](https://github.com/voxpupuli/metadata-json-lint/pull/145) ([bastelfreak](https://github.com/bastelfreak))
27
+ - Add Ruby 3.3 to CI [\#142](https://github.com/voxpupuli/metadata-json-lint/pull/142) ([bastelfreak](https://github.com/bastelfreak))
28
+
3
29
  ## [4.0.0](https://github.com/voxpupuli/metadata-json-lint/tree/4.0.0) (2023-09-15)
4
30
 
5
31
  [Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/3.0.3...4.0.0)
data/Gemfile CHANGED
@@ -6,8 +6,3 @@ group :release do
6
6
  gem 'faraday-retry', require: false
7
7
  gem 'github_changelog_generator', require: false
8
8
  end
9
-
10
- group :coverage, optional: ENV['COVERAGE'] != 'yes' do
11
- gem 'codecov', require: false
12
- gem 'simplecov-console', require: false
13
- end
data/README.md CHANGED
@@ -11,7 +11,8 @@ The metadata-json-lint tool validates and lints `metadata.json` files in Puppet
11
11
 
12
12
  ## Compatibility
13
13
 
14
- metadata-json-lint is compatible with Ruby versions 2.0.0, 2.1.9, 2.3.1, and 2.4.1.
14
+ metadata-json-lint is tested on Ruby 2.7 to 3.3. The the authoritative source,
15
+ check the `required_ruby_version` attribute in the gemspec file.
15
16
 
16
17
  ## Installation
17
18
 
data/Rakefile CHANGED
@@ -2,16 +2,9 @@ desc 'Run all tests'
2
2
  task test: %i[spec test:acceptance]
3
3
 
4
4
  begin
5
- require 'rubocop/rake_task'
5
+ require 'voxpupuli/rubocop/rake'
6
6
  rescue LoadError
7
- # RuboCop is an optional group
8
- else
9
- RuboCop::RakeTask.new(:rubocop) do |task|
10
- # These make the rubocop experience maybe slightly less terrible
11
- task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
12
- # Use Rubocop's Github Actions formatter if possible
13
- task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true'
14
- end
7
+ # the voxpupuli-rubocop gem is optional
15
8
  end
16
9
 
17
10
  namespace :test do
@@ -8,6 +8,9 @@ require 'metadata-json-lint/version_requirement'
8
8
 
9
9
  module MetadataJsonLint
10
10
  MIN_PUPPET_VER = '4.10.0'.freeze
11
+ # Regex looks for:
12
+ # 1. Invalid escape sequences (\x or incomplete \u)
13
+ INVALID_ESCAPE_REGEX = %r{\\[^"/bfnrtu]|\\u(?![0-9a-fA-F]{4})}.freeze
11
14
 
12
15
  def options
13
16
  @options ||= Struct.new(
@@ -69,6 +72,16 @@ module MetadataJsonLint
69
72
  end
70
73
  module_function :run
71
74
 
75
+ def contains_invalid_escape?(content)
76
+ content.match?(INVALID_ESCAPE_REGEX)
77
+ end
78
+ module_function :contains_invalid_escape?
79
+
80
+ def misses_newline_at_end?(content)
81
+ content[-1] != "\n"
82
+ end
83
+ module_function :misses_newline_at_end?
84
+
72
85
  def parse(metadata)
73
86
  @errors = []
74
87
  @warnings = []
@@ -83,6 +96,10 @@ module MetadataJsonLint
83
96
  abort("Error: Unable to read metadata file: #{e.exception}")
84
97
  end
85
98
 
99
+ abort('Error: metadata.json does not have a valid newline at the end') if misses_newline_at_end?(f)
100
+
101
+ abort('Error: Unable to parse metadata.json: Invalid escape character in string') if contains_invalid_escape?(f)
102
+
86
103
  begin
87
104
  parsed = JSON.parse(f)
88
105
  rescue Exception => e
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'metadata-json-lint'
3
- s.version = '4.0.0'
3
+ s.version = '4.2.0'
4
4
  s.summary = 'metadata-json-lint /path/to/metadata.json'
5
5
  s.description = 'Utility to verify Puppet metadata.json files'
6
6
  s.authors = ['Vox Pupuli']
@@ -14,10 +14,10 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.required_ruby_version = '>= 2.7.0'
16
16
 
17
- s.add_runtime_dependency 'json-schema', '>= 2.8', '< 5.0'
18
- s.add_runtime_dependency 'semantic_puppet', '~> 1.0'
19
- s.add_runtime_dependency 'spdx-licenses', '~> 1.0'
17
+ s.add_dependency 'json-schema', '>= 2.8', '< 6.0'
18
+ s.add_dependency 'semantic_puppet', '~> 1.0'
19
+ s.add_dependency 'spdx-licenses', '~> 1.0'
20
20
  s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
21
21
  s.add_development_dependency 'rspec', '~> 3.12'
22
- s.add_development_dependency 'voxpupuli-rubocop', '~> 2.0'
22
+ s.add_development_dependency 'voxpupuli-rubocop', '~> 3.0.0'
23
23
  end
data/spec/spec_helper.rb CHANGED
@@ -1,27 +1,3 @@
1
- begin
2
- require 'simplecov'
3
- require 'simplecov-console'
4
- require 'codecov'
5
- rescue LoadError
6
- else
7
- SimpleCov.start do
8
- track_files 'lib/**/*.rb'
9
-
10
- add_filter '/spec'
11
-
12
- enable_coverage :branch
13
-
14
- # do not track vendored files
15
- add_filter '/vendor'
16
- add_filter '/.vendor'
17
- end
18
-
19
- SimpleCov.formatters = [
20
- SimpleCov::Formatter::Console,
21
- SimpleCov::Formatter::Codecov,
22
- ]
23
- end
24
-
25
1
  require 'metadata_json_lint'
26
2
 
27
3
  # This file was generated by the `rspec --init` command
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
2
+ require 'metadata-json-lint/rake_task'
@@ -0,0 +1 @@
1
+ Error: Unable to parse metadata.json: Invalid escape character in string
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "puppetlabs-postgresql",
3
+ "version": "3.4.1",
4
+ "author": "Inkling/Puppet Labs",
5
+ "summary": "A description with an invalid \( escape sequence",
6
+ "license": "Apache-2.0",
7
+ "source": "git://github.com/puppetlabs/puppet-postgresql.git",
8
+ "project_page": "https://github.com/puppetlabs/puppet-postgresql",
9
+ "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues",
10
+ "operatingsystem_support": [
11
+ ],
12
+ "requirements": [
13
+ ],
14
+ "dependencies": [
15
+ ]
16
+ }
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
2
+ require 'metadata-json-lint/rake_task'
@@ -0,0 +1 @@
1
+ Error: metadata.json does not have a valid newline at the end
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "puppetlabs-postgresql",
3
+ "version": "3.4.1",
4
+ "author": "Inkling/Puppet Labs",
5
+ "summary": "A metadata.json file without a newline at the end",
6
+ "license": "Apache-2.0",
7
+ "source": "git://github.com/puppetlabs/puppet-postgresql.git",
8
+ "project_page": "https://github.com/puppetlabs/puppet-postgresql",
9
+ "issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues",
10
+ "operatingsystem_support": [
11
+ ],
12
+ "requirements": [
13
+ ],
14
+ "dependencies": [
15
+ ]
16
+ }
data/tests/test.sh CHANGED
@@ -103,6 +103,12 @@ test "bad_license" $SUCCESS --no-strict-license
103
103
  # Run with --no-fail-on-warnings, expect SUCCESS
104
104
  test "bad_license" $SUCCESS --no-fail-on-warnings
105
105
 
106
+ # Run a broken one, expect FAILURE
107
+ test "invalid_escape_char" $FAILURE
108
+
109
+ # Run a broken one, expect FAILURE
110
+ test "missing_newline" $FAILURE
111
+
106
112
  # Run a broken one, expect FAILURE
107
113
  test "long_summary" $FAILURE
108
114
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metadata-json-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-09-15 00:00:00.000000000 Z
10
+ date: 2025-01-24 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: json-schema
@@ -19,7 +18,7 @@ dependencies:
19
18
  version: '2.8'
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
- version: '5.0'
21
+ version: '6.0'
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +28,7 @@ dependencies:
29
28
  version: '2.8'
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
- version: '5.0'
31
+ version: '6.0'
33
32
  - !ruby/object:Gem::Dependency
34
33
  name: semantic_puppet
35
34
  requirement: !ruby/object:Gem::Requirement
@@ -98,14 +97,14 @@ dependencies:
98
97
  requirements:
99
98
  - - "~>"
100
99
  - !ruby/object:Gem::Version
101
- version: '2.0'
100
+ version: 3.0.0
102
101
  type: :development
103
102
  prerelease: false
104
103
  version_requirements: !ruby/object:Gem::Requirement
105
104
  requirements:
106
105
  - - "~>"
107
106
  - !ruby/object:Gem::Version
108
- version: '2.0'
107
+ version: 3.0.0
109
108
  description: Utility to verify Puppet metadata.json files
110
109
  email: voxpupuli@groups.io
111
110
  executables:
@@ -132,10 +131,10 @@ files:
132
131
  - lib/metadata-json-lint/version_requirement.rb
133
132
  - lib/metadata_json_lint.rb
134
133
  - metadata-json-lint.gemspec
134
+ - spec/metadata_json_lint/schema_spec.rb
135
+ - spec/metadata_json_lint/version_requirement_spec.rb
135
136
  - spec/metadata_json_lint_spec.rb
136
- - spec/schema_spec.rb
137
137
  - spec/spec_helper.rb
138
- - spec/version_requirement_spec.rb
139
138
  - tests/bad_license/Rakefile
140
139
  - tests/bad_license/expected
141
140
  - tests/bad_license/metadata.json
@@ -148,12 +147,18 @@ files:
148
147
  - tests/duplicate-requirement/Rakefile
149
148
  - tests/duplicate-requirement/expected
150
149
  - tests/duplicate-requirement/metadata.json
150
+ - tests/invalid_escape_char/Rakefile
151
+ - tests/invalid_escape_char/expected
152
+ - tests/invalid_escape_char/metadata.json
151
153
  - tests/json_format/Rakefile
152
154
  - tests/json_format/expected
153
155
  - tests/json_format/metadata.json
154
156
  - tests/long_summary/Rakefile
155
157
  - tests/long_summary/expected
156
158
  - tests/long_summary/metadata.json
159
+ - tests/missing_newline/Rakefile
160
+ - tests/missing_newline/expected
161
+ - tests/missing_newline/metadata.json
157
162
  - tests/missing_version_requirement/Rakefile
158
163
  - tests/missing_version_requirement/expected
159
164
  - tests/missing_version_requirement/metadata.json
@@ -208,7 +213,6 @@ homepage: https://github.com/voxpupuli/metadata-json-lint
208
213
  licenses:
209
214
  - Apache-2.0
210
215
  metadata: {}
211
- post_install_message:
212
216
  rdoc_options: []
213
217
  require_paths:
214
218
  - lib
@@ -223,8 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
227
  - !ruby/object:Gem::Version
224
228
  version: '0'
225
229
  requirements: []
226
- rubygems_version: 3.2.33
227
- signing_key:
230
+ rubygems_version: 3.6.2
228
231
  specification_version: 4
229
232
  summary: metadata-json-lint /path/to/metadata.json
230
233
  test_files: []