diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 576a75fe..42f3e975 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f8aae476..304e9722 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -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: @@ -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: diff --git a/.rubocop.yml b/.rubocop.yml index 3e374020..08f3b6f3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - vendor/bundle/**/* NewCops: enable SuggestExtensions: false - TargetRubyVersion: '2.7' + TargetRubyVersion: '3.1' # Disabled Style/ClassAndModuleChildren: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d927f4ef..d3ec3074 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 @@ -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' @@ -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' diff --git a/Gemfile b/Gemfile index 5755615e..00823ad9 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/README.md b/README.md index 87efc885..a8143b52 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/puppet-strings/markdown/base.rb b/lib/puppet-strings/markdown/base.rb index 5e5e49b1..7e1fae38 100644 --- a/lib/puppet-strings/markdown/base.rb +++ b/lib/puppet-strings/markdown/base.rb @@ -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? } diff --git a/lib/puppet-strings/yard/code_objects/function.rb b/lib/puppet-strings/yard/code_objects/function.rb index 03916a08..f7162d38 100644 --- a/lib/puppet-strings/yard/code_objects/function.rb +++ b/lib/puppet-strings/yard/code_objects/function.rb @@ -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) diff --git a/lib/puppet-strings/yard/handlers/puppet/base.rb b/lib/puppet-strings/yard/handlers/puppet/base.rb index ffa0b0cc..16093351 100644 --- a/lib/puppet-strings/yard/handlers/puppet/base.rb +++ b/lib/puppet-strings/yard/handlers/puppet/base.rb @@ -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 diff --git a/lib/puppet-strings/yard/handlers/ruby/base.rb b/lib/puppet-strings/yard/handlers/ruby/base.rb index 81c3c9bf..a93a72d9 100644 --- a/lib/puppet-strings/yard/handlers/ruby/base.rb +++ b/lib/puppet-strings/yard/handlers/ruby/base.rb @@ -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 = /^] 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) end # Renders the overload section. diff --git a/lib/puppet-strings/yard/util.rb b/lib/puppet-strings/yard/util.rb index 8025b150..e0369f56 100644 --- a/lib/puppet-strings/yard/util.rb +++ b/lib/puppet-strings/yard/util.rb @@ -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 diff --git a/puppet-strings.gemspec b/puppet-strings.gemspec index f72c4fba..7a6dfb95 100644 --- a/puppet-strings.gemspec +++ b/puppet-strings.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.summary = 'Puppet documentation via YARD' s.email = 'info@puppet.com' 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', @@ -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 diff --git a/spec/unit/puppet-strings/json_spec.rb b/spec/unit/puppet-strings/json_spec.rb index 03431245..b101b1a0 100644 --- a/spec/unit/puppet-strings/json_spec.rb +++ b/spec/unit/puppet-strings/json_spec.rb @@ -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