Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
fail-fast: false
matrix:
ruby_version:
- '2.7'
- '3.2'
- '3.3'
name: "spec (ruby ${{ matrix.ruby_version }})"
Expand All @@ -34,7 +33,6 @@ jobs:
fail-fast: false
matrix:
ruby_version:
- '2.7'
- '3.2'
- '3.3'
name: "acceptance (ruby ${{ matrix.ruby_version }})"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
fail-fast: false
matrix:
ruby_version:
- '2.7'
- '3.2'
- '3.3'
name: "spec (ruby ${{ matrix.ruby_version }})"
Expand All @@ -26,7 +25,6 @@ jobs:
fail-fast: false
matrix:
ruby_version:
- '2.7'
- '3.2'
- '3.3'
name: "acceptance (ruby ${{ matrix.ruby_version }})"
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet-lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ def print_problems
# def check
# end
# end
def self.new_check(name, &block)
def self.new_check(name, &)
class_name = name.to_s.split('_').map(&:capitalize).join
klass = PuppetLint.const_set(:"Check#{class_name}", Class.new(PuppetLint::CheckPlugin))
klass.const_set(:NAME, name)
klass.class_exec(&block)
klass.class_exec(&)
PuppetLint.configuration.add_check(name, klass)
PuppetLint::Data.ignore_overrides[name] ||= {}
end
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet-lint/checkplugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ def manifest_lines
def default_info
@default_info ||= {
check: self.class.const_get(:NAME),
fullpath: fullpath,
path: path,
filename: filename
fullpath:,
path:,
filename:
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def load_data(path, content)
problems << {
kind: :error,
check: :syntax,
message: message,
message:,
line: e.line_no,
column: e.column,
fullpath: PuppetLint::Data.fullpath,
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def self.add_check(check)
# Signature
#
# <option>=(value)
def method_missing(method, *args, &_block)
def method_missing(method, *args, &)
super unless method.to_s =~ %r{^(\w+)=?$}

option = Regexp.last_match(1)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def definition_indexes(type)
end: i + j + 1,
tokens: tokens[i..(i + j + 1)],
param_tokens: param_tokens(tokens[i..(i + j + 1)]),
type: type,
type:,
name_token: token.next_code_token,
inherited_token: inherited_class
}
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet-lint/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def heredoc_queue
# \p{Zs} == ASCII + Unicode non-linebreaking whitespace
WHITESPACE_RE = (RUBY_VERSION == '1.8.7') ? %r{[\t\v\f ]} : %r{[\t\v\f\p{Zs}]}

LINE_END_RE = %r{(?:\r\n|\r|\n)}.freeze
LINE_END_RE = %r{(?:\r\n|\r|\n)}

NAME_RE = %r{\A((?:(?:::)?[_a-z0-9][-\w]*)(?:::[a-z0-9][-\w]*)*)}.freeze
NAME_RE = %r{\A((?:(?:::)?[_a-z0-9][-\w]*)(?:::[a-z0-9][-\w]*)*)}

# Internal: An Array of Arrays containing tokens that can be described by
# a single regular expression. Each sub-Array contains 2 elements, the
Expand Down
12 changes: 6 additions & 6 deletions lib/puppet-lint/lexer/string_slurper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class PuppetLint::Lexer
class StringSlurper
attr_accessor :scanner, :results, :interp_stack

START_INTERP_PATTERN = %r{\$\{}.freeze
END_INTERP_PATTERN = %r{\}}.freeze
END_STRING_PATTERN = %r{(\A|[^\\])(\\\\)*"}.freeze
UNENC_VAR_PATTERN = %r{(\A|[^\\])\$(::)?(\w+(-\w+)*::)*\w+(-\w+)*}.freeze
ESC_DQUOTE_PATTERN = %r{\\+"}.freeze
LBRACE_PATTERN = %r{\{}.freeze
START_INTERP_PATTERN = %r{\$\{}
END_INTERP_PATTERN = %r{\}}
END_STRING_PATTERN = %r{(\A|[^\\])(\\\\)*"}
UNENC_VAR_PATTERN = %r{(\A|[^\\])\$(::)?(\w+(-\w+)*::)*\w+(-\w+)*}
ESC_DQUOTE_PATTERN = %r{\\+"}
LBRACE_PATTERN = %r{\{}

def initialize(string)
@scanner = StringScanner.new(string)
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet-lint/monkeypatches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class String
Percent = instance_method(:%) unless defined?(Percent)

def %(*a, &b)
def %(*a, &)

Check warning on line 8 in lib/puppet-lint/monkeypatches.rb

View check run for this annotation

Codecov / codecov/patch

lib/puppet-lint/monkeypatches.rb#L8

Added line #L8 was not covered by tests
a.flatten!

string = case a.last
Expand All @@ -18,7 +18,7 @@
if a.empty?
string
else
Percent.bind_call(string, a, &b)
Percent.bind_call(string, a, &)

Check warning on line 21 in lib/puppet-lint/monkeypatches.rb

View check run for this annotation

Codecov / codecov/patch

lib/puppet-lint/monkeypatches.rb#L21

Added line #L21 was not covered by tests
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def gem_directories
end
end

Dir[File.expand_path('plugins/**/*.rb', File.dirname(__FILE__))].sort.each do |file|
Dir[File.expand_path('plugins/**/*.rb', File.dirname(__FILE__))].each do |file|
require file
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def check
message: "arrow should be on the right operand's line",
line: token.line,
column: token.column,
token: token,
token:,
description: 'Test the manifest tokens for chaining arrow that is on the line of the left operand when the right operand is on another line.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#chaining-arrow-syntax',
)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/plugins/check_comments/slash_comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def check
message: '// comment found',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the manifest tokens for any comments started with slashes (//) and record a warning for each instance found.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#comments',
)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/plugins/check_comments/star_comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def check
message: '/* */ comment found',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the manifest tokens for any comments encapsulated with slash-asterisks (/* */) and record a warning for each instance found.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#comments',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def check
message: 'unquoted node name found',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the manifest for unquoted node names and record a warning for each instance found.',
help_uri: nil,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def check
message: "ensure found on line but it's not the first attribute",
line: ensure_token.line,
column: ensure_token.column,
resource: resource,
resource:,
description: 'Check the tokens of each resource instance for an ensure parameter and if ' \
'found, check that it is the first parameter listed. If it is not the first parameter, record a warning.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#attribute-ordering',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def check
line: value_token.line,
column: value_token.column,
param_token: ensure_token,
value_token: value_token,
value_token:,
description: 'Check the tokens of each File resource instance for an ensure parameter and ' \
'record a warning if the value of that parameter looks like a symlink target (starts with a \'/\').',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#symbolic-links',
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/plugins/check_resources/file_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
MSG = 'mode should be represented as a 4 digit octal value or symbolic mode'.freeze
SYM_RE = '([ugoa]*[-=+][-=+rstwxXugo]*)(,[ugoa]*[-=+][-=+rstwxXugo]*)*'.freeze
IGNORE_TYPES = Set[:VARIABLE, :UNDEF, :FUNCTION_NAME]
MODE_RE = %r{\A([0-7]{4}|#{SYM_RE})\Z}.freeze
MODE_RE = %r{\A([0-7]{4}|#{SYM_RE})\Z}

PuppetLint.new_check(:file_mode) do
def check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def check
message: 'unquoted resource title',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the manifest tokens for any resource titles / namevars that are not quoted and record a warning for each instance found.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#resource-names',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# each instance found.
#
# https://puppet.com/docs/puppet/latest/style_guide.html#quoting
ESCAPE_CHAR_RE = %r{(\\\$|\\"|\\'|'|\r|\t|\\t|\\s|\n|\\n|\\\\)}.freeze
ESCAPE_CHAR_RE = %r{(\\\$|\\"|\\'|'|\r|\t|\\t|\\s|\n|\\n|\\\\)}

PuppetLint.new_check(:double_quoted_strings) do
def check
Expand All @@ -18,7 +18,7 @@ def check
message: 'double quoted string containing no variables',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the manifest tokens for any double quoted strings that don\'t ' \
'contain any variables or common escape characters and record a warning for each instance found.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#quoting',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def check
message: 'string containing only a variable',
line: var_token.line,
column: var_token.column,
start_token: start_token,
var_token: var_token,
start_token:,
var_token:,
end_token: eos_token,
description: 'Check the manifest tokens for double quoted strings that contain a single variable only and record a warning for each instance found.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#quoting',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def check
message: 'puppet:// URL without modules/ found',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the manifest tokens for any puppet:// URL strings where the path section doesn\'t start with modules/ and record a warning for each instance found.',
help_uri: nil,
)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/plugins/check_strings/quoted_booleans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def check
message: 'quoted boolean value found',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the manifest tokens for any double or single quoted strings containing only a boolean value and record a warning for each instance found.',
help_uri: nil,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def check
message: 'variable not enclosed in {}',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the manifest tokens for any variables in a string that have not been enclosed by braces ({}) and record a warning for each instance found.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#quoting',
)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def check
message: 'tab character found',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the raw manifest string for lines containing hard tab characters and record an error for each instance found.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def check
notify(
:warning,
message: "there should be a single space before '=>' on line #{line}, column #{column}",
line: line,
column: column,
line:,
column:,
token: prev_token,
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def check
message: 'trailing whitespace found',
line: token.line,
column: token.column,
token: token,
token:,
description: 'Check the manifest tokens for lines ending with whitespace and record an error for each instance found.',
help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace',
)
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet-lint/plugins/legacy_facts/legacy_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def check_puppet
message: "legacy fact '#{fact_name}'",
line: token.line,
column: token.column,
token: token,
fact_name: fact_name
token:,
fact_name:
}
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def check
message: 'top scope fact instead of facts hash',
line: token.line,
column: token.column,
token: token
token:
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/report/codeclimate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def self.write_report_file(problems, report_file)
check_name: message[:check],
description: message[:message],
categories: [:Style],
severity: severity,
severity:,
location: {
path: message[:path],
lines: {
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet-lint/tasks/puppet-lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class PuppetLint::RakeTask < Rake::TaskLib
#
# PuppetLint::RakeTask.new
# rubocop:disable Lint/MissingSuper
def initialize(*args, &task_block)
def initialize(*args, &)
@name = args.shift || :lint
@pattern = DEFAULT_PATTERN
@with_filename = true
@disable_checks = []
@only_checks = []
@ignore_paths = []

define(args, &task_block)
define(args, &)
end

def define(args, &task_block)
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet-lint/tasks/release_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run_cmd(message, *cmd)
[output.strip, status.success?]
end

def with_puppet_lint_head(&block)
def with_puppet_lint_head(&)
print(' Updating Gemfile to use puppet-lint HEAD... ')

buffer = Parser::Source::Buffer.new('Gemfile')
Expand All @@ -49,7 +49,7 @@ def with_puppet_lint_head(&block)

puts 'Done'

Bundler.with_clean_env(&block)
Bundler.with_clean_env(&)

run_cmd('Restoring Gemfile', 'git', 'checkout', '--', 'Gemfile')
end
Expand Down
2 changes: 1 addition & 1 deletion puppet-lint.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
]
spec.license = 'MIT'

spec.required_ruby_version = Gem::Requirement.new('>= 2.7'.freeze)
spec.required_ruby_version = Gem::Requirement.new('>= 3.1'.freeze)
end
2 changes: 1 addition & 1 deletion rubocop_baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AllCops:
NewCops: enable
ExtraDetails: true
DisplayStyleGuide: true
TargetRubyVersion: '2.7'
TargetRubyVersion: '3.1'
DisplayCopNames: true
SuggestExtensions: false
Exclude:
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HaveProblem
def initialize(method, message)
@expected_problem = {
kind: method.to_s.delete_prefix('contain_').to_sym,
message: message
message:
}
@description = ["contain a #{@expected_problem[:kind]}"]
end
Expand Down Expand Up @@ -107,7 +107,7 @@ def failure_message_when_negated
end
end

def method_missing(method, *args, &block)
def method_missing(method, *args, &)
return HaveProblem.new(method, args.first) if method.to_s.start_with?('contain_')

super
Expand Down