Skip to content

(CAT-2281) Remove puppet 7 infrastructure #407

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 3 commits into from
Apr 10, 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
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ jobs:
fail-fast: false
matrix:
ruby_version:
- "2.7"
- "3.2"
include:
- ruby-version: '2.7'
puppet_gem_version: '~> 7.0'
- ruby_version: '3.2'
puppet_gem_version: '~> 8.0'
runs_on:
Expand All @@ -42,11 +39,8 @@ jobs:
strategy:
matrix:
ruby_version:
- "2.7"
- "3.2"
include:
- ruby-version: '2.7'
puppet_gem_version: '~> 7.0'
- ruby_version: '3.2'
puppet_gem_version: 'https://github.com/puppetlabs/puppet' # puppet8'
runs_on:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ jobs:
fail-fast: false
matrix:
ruby_version:
- "2.7"
- "3.2"
include:
- ruby-version: '2.7'
puppet_gem_version: '~> 7.0'
- ruby_version: '3.2'
puppet_gem_version: '~> 8.0'
runs_on:
Expand All @@ -34,11 +31,8 @@ jobs:
strategy:
matrix:
ruby_version:
- "2.7"
- "3.2"
include:
- ruby-version: '2.7'
puppet_gem_version: '~> 7.0'
- ruby_version: '3.2'
puppet_gem_version: 'https://github.com/puppetlabs/puppet' # puppet8'
runs_on:
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AllCops:
- vendor/bundle/**/*
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: '2.7'
TargetRubyVersion: '3.1'

# Disabled
Style/ClassAndModuleChildren:
Expand Down
28 changes: 18 additions & 10 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-01-22 15:21:03 UTC using RuboCop version 1.50.2.
# on 2025-04-09 10:54:46 UTC using RuboCop version 1.70.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -14,7 +14,7 @@ Gemspec/RequireMFA:
Exclude:
- 'puppet-strings.gemspec'

# Offense count: 45
# Offense count: 44
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 95
Expand All @@ -25,17 +25,12 @@ Metrics/AbcSize:
Metrics/BlockLength:
Max: 44

# Offense count: 1
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 4

# Offense count: 5
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 283

# Offense count: 34
# Offense count: 33
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 36
Expand Down Expand Up @@ -68,6 +63,7 @@ Naming/AccessorMethodName:
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'Rakefile.rb'
- 'lib/puppet-strings.rb'

# Offense count: 1
Expand All @@ -85,12 +81,14 @@ Naming/MethodParameterName:
- 'lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb'
- 'lib/puppet-strings/yard/parsers/puppet/parser.rb'

# Offense count: 2
# Offense count: 4
# Configuration parameters: MinSize.
Performance/CollectionLiteralInLoop:
Exclude:
- 'lib/puppet-strings/yard/handlers/puppet/base.rb'
- 'lib/puppet-strings/yard/handlers/ruby/provider_handler.rb'
- 'lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb'
- 'lib/puppet-strings/yard/util.rb'

# Offense count: 1
RSpec/BeforeAfterAll:
Expand Down Expand Up @@ -123,7 +121,7 @@ RSpec/DescribeClass:
- 'spec/acceptance/generate_markdown_spec.rb'
- 'spec/acceptance/running_strings_generate_spec.rb'

# Offense count: 48
# Offense count: 51
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 66
Expand Down Expand Up @@ -159,6 +157,7 @@ Style/ClassVars:
- 'lib/puppet-strings/yard/templates/default/layout/html/setup.rb'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CombinableLoops:
Exclude:
- 'lib/puppet-strings/markdown.rb'
Expand Down Expand Up @@ -187,3 +186,12 @@ Style/OptionalBooleanParameter:
- 'lib/puppet-strings/yard/code_objects/type.rb'
- 'lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb'
- 'lib/puppet-strings/yard/handlers/ruby/function_handler.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'lib/puppet-strings/yard/handlers/puppet/function_handler.rb'
- 'lib/puppet-strings/yard/handlers/ruby/function_handler.rb'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ group :development do
gem 'rspec', '~> 3.1'
gem 'rspec-its', '~> 1.0'

gem 'rubocop', '~> 1.64.0', require: false
gem 'rubocop', '~> 1.70.0', require: false
gem 'rubocop-performance', '~> 1.16', require: false
gem 'rubocop-rspec', '~> 3.0', require: false

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Strings processes code and YARD-style code comments to create documentation in H

### Requirements

* Ruby 2.7.0 or newer
* Puppet 7.0.0 or newer
* Ruby 3.1.0 or newer
* Puppet 8.0.0 or newer

### Install Puppet Strings

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-strings/markdown/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def defaults
def toc_info
{
name: name.to_s,
link: link,
link:,
desc: summary || @registry[:docstring][:text][0..140].tr("\n", ' '),
private: private?
}
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-strings/yard/code_objects/function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def to_hash
hash[:signatures] << { signature: o.signature, docstring: PuppetStrings::Yard::Util.docstring_to_hash(o.docstring, %i[param option enum return example]) }
end
else
hash[:signatures] << { signature: signature, docstring: PuppetStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example]) }
hash[:signatures] << { signature:, docstring: PuppetStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example]) }
end

hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-strings/yard/handlers/puppet/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def set_parameter_types(object)
tags.each do |tag|
next if statement.parameters.find { |p| tag.name == p.name }

log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}." unless tag.name == 'name' || tag.name == 'title'
log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}." unless %w[name title].include?(tag.name)
end

# Assign the types for the parameter
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-strings/yard/handlers/ruby/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class PuppetStrings::Yard::Handlers::Ruby::Base < YARD::Handlers::Ruby::Base
# A regular expression for detecting the start of a Ruby heredoc.
# Note: the first character of the heredoc start may have been cut off by YARD.
HEREDOC_START = /^<?<[-~]?['"]?(\w+)['"]?[^\n]*\n?/.freeze
HEREDOC_START = /^<?<[-~]?['"]?(\w+)['"]?[^\n]*\n?/

protected

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def extract_params(hash)
default = value['value'] unless value['value'].nil?
end
data_type = [data_type] unless data_type.nil? || data_type.is_a?(Array)
params_hash[key] = { types: data_type, default: default }
params_hash[key] = { types: data_type, default: }
end

params_hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def register_provider_docstring(object)
# Look for a call to a dispatch method with a block
next unless
child.method_name &&
(child.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
['desc', 'doc='].include?(child.method_name.source) &&
child.parameters(false).count == 1

docstring = node_as_string(child.parameters[0])
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-strings/yard/handlers/ruby/type_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def find_docstring(node, kind)
elsif child.is_a?(YARD::Parser::Ruby::MethodCallNode)
# Look for a call to a dispatch method with a block
next unless child.method_name &&
(child.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
['desc', 'doc='].include?(child.method_name.source) &&
child.parameters(false).count == 1

docstring = node_as_string(child.parameters[0])
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet-strings/yard/parsers/puppet/statement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module PuppetStrings::Yard::Parsers::Puppet
# Represents the base Puppet language statement.
class Statement
# The pattern for parsing docstring comments.
COMMENT_REGEX = /^\s*#+\s?/.freeze
COMMENT_REGEX = /^\s*#+\s?/

attr_reader :source, :file, :line, :docstring, :comments_range

Expand Down Expand Up @@ -170,7 +170,7 @@ def initialize(object, file)
case type_expr
when Puppet::Pops::Model::AccessExpression
# TODO: I don't like rebuilding the source from the AST, but AccessExpressions don't expose the original source
@alias_of = +"#{PuppetStrings::Yard::Util.ast_to_text(type_expr.left_expr)}[" # alias_of should be mutable so we add a + to the string.
@alias_of = "#{PuppetStrings::Yard::Util.ast_to_text(type_expr.left_expr)}[" # alias_of should be mutable so we add a + to the string.
@alias_of << type_expr.keys.map { |key| PuppetStrings::Yard::Util.ast_to_text(key) }.join(', ')
@alias_of << ']'
else
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet-strings/yard/tags/overload_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
# @param [Array] args The args passed to the method.
# @param block The block passed to the method.
# @return Returns what the method call on the object would return.
def method_missing(method_name, *args, &block)
return object.send(method_name, *args, &block) if object.respond_to? method_name
def method_missing(method_name, ...)
return object.send(method_name, ...) if object.respond_to? method_name

Check warning on line 79 in lib/puppet-strings/yard/tags/overload_tag.rb

View check run for this annotation

Codecov / codecov/patch

lib/puppet-strings/yard/tags/overload_tag.rb#L79

Added line #L79 was not covered by tests

super
end
Expand Down
8 changes: 1 addition & 7 deletions lib/puppet-strings/yard/templates/default/tags/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
# @return [Array<YARD::Tag>] Returns the parameter tags if the object should have parameters.
def param
tag(:param) if
object.type == :method ||
object.type == :puppet_class ||
object.type == :puppet_data_type ||
object.type == :puppet_defined_type ||
object.type == :puppet_function ||
object.type == :puppet_task ||
object.type == :puppet_plan
%i[method puppet_class puppet_data_type puppet_defined_type puppet_function puppet_task puppet_plan].include?(object.type)

Check warning on line 7 in lib/puppet-strings/yard/templates/default/tags/setup.rb

View check run for this annotation

Codecov / codecov/patch

lib/puppet-strings/yard/templates/default/tags/setup.rb#L7

Added line #L7 was not covered by tests
end

# Renders the overload section.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-strings/yard/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def self.tags_to_hashes(tags)

tag = { tag_name: t.tag_name }
# grab nested information for @option and @enum tags
if tag[:tag_name] == 'option' || tag[:tag_name] == 'enum'
if %w[option enum].include?(tag[:tag_name])
tag[:opt_name] = t.pair.name
tag[:opt_text] = t.pair.text
tag[:opt_types] = t.pair.types if t.pair.types
Expand Down
8 changes: 4 additions & 4 deletions puppet-strings.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.summary = 'Puppet documentation via YARD'
s.email = '[email protected]'
s.homepage = 'https://github.com/puppetlabs/puppet-strings'
s.required_ruby_version = '>= 2.7.0'
s.required_ruby_version = '>= 3.1.0'

s.extra_rdoc_files = [
'CHANGELOG.md',
Expand All @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
]
s.files = Dir['CHANGELOG.md', 'README.md', 'LICENSE', 'lib/**/*', 'exe/**/*']

s.add_runtime_dependency 'puppet', '>= 7.0.0'
s.add_runtime_dependency 'rgen', '~> 0.9'
s.add_runtime_dependency 'yard', '~> 0.9'
s.add_dependency 'puppet', '>= 8.0.0'
s.add_dependency 'rgen', '~> 0.9'
s.add_dependency 'yard', '~> 0.9'
end
2 changes: 1 addition & 1 deletion spec/unit/puppet-strings/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
#
# @param [Proc] block The block to capture output from
# @return [Hash] A hash containing the captured output
def capture_output(&_block)
def capture_output(&)
begin
$stdout = StringIO.new
$stderr = StringIO.new
Expand Down
Loading