scelint 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/pr_tests.yml +1 -1
- data/.github/workflows/tag_deploy_rubygem.yml +2 -2
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -2
- data/exe/scelint +1 -1
- data/lib/scelint/cli.rb +27 -1
- data/lib/scelint/version.rb +1 -1
- data/lib/scelint.rb +31 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cbcb49e907f0804f22a550c9507f56a6849ba26f2ba67f1893df0d41a289ea43
|
|
4
|
+
data.tar.gz: f4c83fa4d9e8cea6dec15625475904e7cf84f05b69de57657ad2a06b70fff5eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2661057050cc3819c58818bb726a429d5e47260c2505bd08c6a084c494b24b0a359bc8a2cfa7618ef8012f71899e54ce8ef0dbb5c68d02ad74958de16edde55a
|
|
7
|
+
data.tar.gz: e2362ae54fc4107861bd76244699386489b50efefebf09211bb38b7ff44d7fd7dc4ef3df4a77a49ce25a34cecd10e4598862a841bd7a322ef408008b02ee6643
|
|
@@ -92,7 +92,7 @@ jobs:
|
|
|
92
92
|
echo "release_command=$GEM_RELEASE_COMMAND" | tee -a "$GITHUB_OUTPUT"
|
|
93
93
|
- uses: ruby/setup-ruby@v1
|
|
94
94
|
with:
|
|
95
|
-
ruby-version: 4.0.
|
|
95
|
+
ruby-version: 4.0.1
|
|
96
96
|
bundler-cache: true
|
|
97
97
|
- name: Test build the package
|
|
98
98
|
run: "${{ steps.commands.outputs.build_command }}"
|
|
@@ -187,7 +187,7 @@ jobs:
|
|
|
187
187
|
clean: true
|
|
188
188
|
- uses: ruby/setup-ruby@v1
|
|
189
189
|
with:
|
|
190
|
-
ruby-version: 4.0.
|
|
190
|
+
ruby-version: 4.0.1
|
|
191
191
|
bundler-cache: true
|
|
192
192
|
- name: Build RubyGem
|
|
193
193
|
run: |
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
### 0.6.0 / 2026-03-11
|
|
2
|
+
* Add `.scelint` defaults file support (rspec-style CLI argument defaults)
|
|
3
|
+
* Add `--allow-reserved-words` option to skip reserved word checks on parameter names
|
|
4
|
+
|
|
5
|
+
### 0.5.0 / 2026-03-11
|
|
6
|
+
* Validate parameter names
|
|
7
|
+
* Fix command-line argument processing
|
|
8
|
+
|
|
1
9
|
### 0.4.1 / 2026-01-26
|
|
2
10
|
* Support compliance_engine 0.2.x
|
|
3
11
|
* Test with Ruby 4.0
|
data/Gemfile
CHANGED
|
@@ -7,7 +7,7 @@ gem 'rake', '~> 13.3.0'
|
|
|
7
7
|
|
|
8
8
|
group :tests do
|
|
9
9
|
gem 'rspec', '~> 3.13.1'
|
|
10
|
-
gem 'rubocop', '~> 1.
|
|
10
|
+
gem 'rubocop', '~> 1.85.0'
|
|
11
11
|
gem 'rubocop-performance', '~> 1.26.0'
|
|
12
12
|
gem 'rubocop-rake', '~> 0.7.1'
|
|
13
13
|
gem 'rubocop-rspec', '~> 3.9.0'
|
|
@@ -16,5 +16,5 @@ end
|
|
|
16
16
|
group :development do
|
|
17
17
|
gem 'pry', '~> 0.16.0'
|
|
18
18
|
gem 'pry-byebug', '~> 3.12.0'
|
|
19
|
-
gem 'rdoc', '~> 7.
|
|
19
|
+
gem 'rdoc', '~> 7.2.0'
|
|
20
20
|
end
|
data/exe/scelint
CHANGED
data/lib/scelint/cli.rb
CHANGED
|
@@ -6,15 +6,41 @@ require 'logger'
|
|
|
6
6
|
|
|
7
7
|
# SCELint CLI
|
|
8
8
|
class Scelint::CLI < Thor
|
|
9
|
+
def self.exit_on_failure?
|
|
10
|
+
true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
DEFAULTS_FILE = '.scelint'
|
|
14
|
+
|
|
15
|
+
# Load default arguments from .scelint in the current directory.
|
|
16
|
+
# Each non-blank, non-comment line may contain one or more arguments.
|
|
17
|
+
def self.load_defaults
|
|
18
|
+
return [] unless File.exist?(DEFAULTS_FILE)
|
|
19
|
+
File.readlines(DEFAULTS_FILE, chomp: true)
|
|
20
|
+
.reject { |line| line.strip.empty? || line.strip.start_with?('#') }
|
|
21
|
+
.flat_map(&:split)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# When the first argument is not a known subcommand or an option flag,
|
|
25
|
+
# treat all arguments as paths for the default `lint` command.
|
|
26
|
+
def self.start(given_args = ARGV, config = {})
|
|
27
|
+
args = load_defaults + given_args
|
|
28
|
+
if args.first && !args.first.start_with?('-') && !all_commands.key?(args.first)
|
|
29
|
+
args = ['lint'] + args
|
|
30
|
+
end
|
|
31
|
+
super(args, config)
|
|
32
|
+
end
|
|
33
|
+
|
|
9
34
|
class_option :quiet, type: :boolean, aliases: '-q', default: false
|
|
10
35
|
class_option :verbose, type: :boolean, aliases: '-v', default: false
|
|
11
36
|
class_option :debug, type: :boolean, aliases: '-d', default: false
|
|
12
37
|
|
|
13
38
|
desc 'lint PATH', 'Lint all files in PATH'
|
|
14
39
|
option :strict, type: :boolean, aliases: '-s', default: false
|
|
40
|
+
option :allow_reserved_words, type: :boolean, default: false
|
|
15
41
|
def lint(*paths)
|
|
16
42
|
paths = ['.'] if paths.nil? || paths.empty?
|
|
17
|
-
lint = Scelint::Lint.new(paths, logger: logger)
|
|
43
|
+
lint = Scelint::Lint.new(paths, logger: logger, allow_reserved_words: options[:allow_reserved_words])
|
|
18
44
|
|
|
19
45
|
count = lint.files.count
|
|
20
46
|
|
data/lib/scelint/version.rb
CHANGED
data/lib/scelint.rb
CHANGED
|
@@ -134,8 +134,9 @@ module Scelint
|
|
|
134
134
|
#
|
|
135
135
|
# @param paths [Array<String>] Paths to look for SCE data in. Defaults to ['.']
|
|
136
136
|
# @param logger [Logger] A logger to send messages to. Defaults to an instance of Logger with the log level set to INFO.
|
|
137
|
-
def initialize(paths = ['.'], logger: Logger.new(STDOUT, level: Logger::INFO))
|
|
137
|
+
def initialize(paths = ['.'], logger: Logger.new(STDOUT, level: Logger::INFO), allow_reserved_words: false)
|
|
138
138
|
@log = logger
|
|
139
|
+
@allow_reserved_words = allow_reserved_words
|
|
139
140
|
@errors = []
|
|
140
141
|
@warnings = []
|
|
141
142
|
@notes = []
|
|
@@ -396,7 +397,35 @@ module Scelint
|
|
|
396
397
|
# @param check [String] The name of the check
|
|
397
398
|
# @param parameter [String] The parameter to validate
|
|
398
399
|
def check_parameter(file, check, parameter)
|
|
399
|
-
|
|
400
|
+
# Regular expression to match valid Puppet class parameter names
|
|
401
|
+
valid_parameter = %r{\A([a-z][a-z0-9_]*::)+[a-z][a-z0-9_]*\z}
|
|
402
|
+
# From https://www.puppet.com/docs/puppet/7/lang_reserved.html
|
|
403
|
+
reserved_words = ['and', 'application', 'attr', 'case', 'component', 'consumes', 'default', 'define', 'elsif',
|
|
404
|
+
'environment', 'false', 'function', 'if', 'import', 'in', 'inherits', 'node',
|
|
405
|
+
'or', 'private', 'produces', 'regexp', 'site', 'true', 'type', 'undef', 'unit', 'unless',
|
|
406
|
+
'main', 'settings', 'init', 'any', 'array', 'binary', 'boolean', 'catalogentry', 'class',
|
|
407
|
+
'collection', 'callable', 'data', 'default', 'deferred', 'enum', 'float', 'hash', 'integer',
|
|
408
|
+
'notundef', 'numeric', 'optional', 'pattern', 'resource', 'regexp', 'runtime', 'scalar',
|
|
409
|
+
'semver', 'semVerRange', 'sensitive', 'string', 'struct', 'timespan', 'timestamp', 'tuple',
|
|
410
|
+
'type', 'undef', 'variant', 'facts', 'trusted', 'server_facts', 'title', 'name'].freeze
|
|
411
|
+
|
|
412
|
+
unless parameter.is_a?(String) && !parameter.empty?
|
|
413
|
+
errors << "#{file} (check '#{check}'): invalid parameter '#{parameter}'"
|
|
414
|
+
return
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
unless parameter.match?(valid_parameter)
|
|
418
|
+
errors << "#{file} (check '#{check}'): invalid parameter name '#{parameter}'"
|
|
419
|
+
return
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
return if @allow_reserved_words
|
|
423
|
+
|
|
424
|
+
parameter.split('::').each do |part|
|
|
425
|
+
if reserved_words.include?(part)
|
|
426
|
+
errors << "#{file} (check '#{check}'): parameter name '#{parameter}' contains reserved word '#{part}'"
|
|
427
|
+
end
|
|
428
|
+
end
|
|
400
429
|
end
|
|
401
430
|
|
|
402
431
|
# Check remediation
|