Skip to content

(CAT-2281) Remove puppet 7 infrastructure #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 11, 2025
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
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ require:
- rubocop-performance
- rubocop-rspec
AllCops:
NewCops: enable
DisplayCopNames: true
TargetRubyVersion: '2.7'
TargetRubyVersion: '3.1'
SuggestExtensions: false
Include:
- "**/*.rb"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ group :coverage, optional: ENV['COVERAGE']!='yes' do
end

group :rubocop do
gem 'rubocop', '~> 1.6.1', require: false
gem 'rubocop', '~> 1.60.0', require: false
gem 'rubocop-performance', '~> 1.9.1', require: false
gem 'rubocop-rspec', '~> 2.0.1', require: false
end
Expand Down
12 changes: 6 additions & 6 deletions lib/puppet-lint/plugins/check_unsafe_interpolations.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PuppetLint.new_check(:check_unsafe_interpolations) do
COMMANDS = Array['command', 'onlyif', 'unless']
INTERPOLATED_STRINGS = Array[:DQPRE, :DQMID]
USELESS_CHARS = Array[:WHITESPACE, :COMMA]
COMMANDS = ['command', 'onlyif', 'unless'].freeze
INTERPOLATED_STRINGS = [:DQPRE, :DQMID].freeze
USELESS_CHARS = [:WHITESPACE, :COMMA].freeze
def check
# Gather any exec commands' resources into an array
exec_resources = resource_indexes.map { |resource|
resource_parameters = resource[:param_tokens].map(&:value)
resource if resource[:type].value == 'exec' && !(COMMANDS & resource_parameters).empty?
resource if resource[:type].value == 'exec' && !COMMANDS.intersect?(resource_parameters).nil?
}.compact

# Iterate over title tokens and raise a warning if any are variables
Expand All @@ -33,7 +33,7 @@ def check_unsafe_title(title)
def check_unsafe_interpolations(command_resources)
command_resources[:tokens].each do |token|
# Skip iteration if token isn't a command of type :NAME
next unless COMMANDS.include?(token.value) && (token.type == :NAME || token.type == :UNLESS)
next unless COMMANDS.include?(token.value) && [:NAME, :UNLESS].include?(token.type)
# Don't check the command if it is parameterised
next if parameterised?(token)

Expand Down Expand Up @@ -106,7 +106,7 @@ def get_exec_titles
result << tokens[title_start_idx..title_end_idx]
# Title is in single quotes
else
tokens_array.concat([tokens[token_idx].next_code_token.next_code_token])
tokens_array.push(tokens[token_idx].next_code_token.next_code_token)

result << tokens_array
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/plugins/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# version of this gem
class CheckUnsafeInterpolations
VERSION ||= '0.0.5'.freeze
VERSION = '0.0.5'.freeze
end
5 changes: 3 additions & 2 deletions puppet-lint-check_unsafe_interpolations.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'puppet-lint/plugins/version'

Gem::Specification.new do |spec|
spec.name = "puppet-lint-check_unsafe_interpolations"
spec.name = 'puppet-lint-check_unsafe_interpolations'
spec.version = CheckUnsafeInterpolations::VERSION
spec.authors = ['Puppet, Inc.']
spec.files = Dir[
Expand All @@ -20,7 +20,8 @@ Gem::Specification.new do |spec|
EOF
spec.homepage = 'https://github.com/puppetlabs/puppet-lint-check_unsafe_interpolations'
spec.license = 'Apache-2.0'
spec.required_ruby_version = Gem::Requirement.new(">= 2.5".freeze)
spec.required_ruby_version = Gem::Requirement.new('>= 3.1')

spec.add_dependency 'puppet-lint', '~> 4.0'
spec.metadata['rubygems_mfa_required'] = 'true'
end