From 92f0101ab90e3d627d560112ee74dd0370723172 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Thu, 13 Apr 2023 13:35:38 +0100 Subject: [PATCH 01/60] (CONT-812) Update dependencies --- Gemfile | 49 ++++++++++++++++++------------------------ puppet-strings.gemspec | 6 +++--- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/Gemfile b/Gemfile index eff427ae..5cf8c0a3 100644 --- a/Gemfile +++ b/Gemfile @@ -4,18 +4,21 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" gemspec -gem 'rgen' -gem 'redcarpet' -gem 'yard', '~> 0.9.11' - -if ENV['PUPPET_GEM_VERSION'] - gem 'puppet', ENV['PUPPET_GEM_VERSION'], :require => false -else - gem 'puppet', :require => false +def location_for(place_or_version, fake_version = nil) + git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} + file_url_regex = %r{\Afile:\/\/(?.*)} + + if place_or_version && (git_url = place_or_version.match(git_url_regex)) + [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact + elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) + ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] + else + [place_or_version, { require: false }] + end end group :development do - gem 'codecov' + gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) gem 'json_spec', '~> 1.1', '>= 1.1.5' @@ -24,6 +27,7 @@ group :development do gem 'pry', require: false gem 'pry-byebug', require: false gem 'pry-stack_explorer', require: false + # Need the following otherwise we end up with puppetlabs_spec_helper 1.1.1 gem 'mocha', '~> 1.0' gem 'puppetlabs_spec_helper' @@ -31,30 +35,19 @@ group :development do gem 'rake' gem 'rspec', '~> 3.1' gem 'rspec-its', '~> 1.0' - gem 'rubocop', '~> 1.6.1', require: false - gem 'rubocop-rspec', '~> 2.0.1', require: false - gem 'rubocop-performance', '~> 1.9.1', require: false + + gem 'rubocop', '~> 1.48', require: false + gem 'rubocop-performance', '~> 1.16', require: false + gem 'rubocop-rspec', '~> 2.19', require: false gem 'serverspec' - gem 'simplecov-console', require: false if ENV['COVERAGE'] == 'yes' - gem 'simplecov', require: false if ENV['COVERAGE'] == 'yes' + gem 'simplecov', require: false + gem 'simplecov-console', require: false + + gem 'redcarpet' end group :acceptance do gem 'puppet_litmus' gem 'net-ssh' end - -group :release do - gem 'github_changelog_generator', require: false -end - -# Evaluate Gemfile.local if it exists -if File.exists? "#{__FILE__}.local" - eval(File.read("#{__FILE__}.local"), binding) -end - -# Evaluate ~/.gemfile if it exists -if File.exists?(File.join(Dir.home, '.gemfile')) - eval(File.read(File.join(Dir.home, '.gemfile')), binding) -end diff --git a/puppet-strings.gemspec b/puppet-strings.gemspec index 4c04f899..2bfbb1d6 100644 --- a/puppet-strings.gemspec +++ b/puppet-strings.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |s| ] s.files = Dir['CHANGELOG.md', 'README.md', 'LICENSE', 'lib/**/*', 'exe/**/*'] - s.add_runtime_dependency 'yard', '~> 0.9.5' - s.add_runtime_dependency 'rgen', '~> 0.9.0' - s.requirements << 'puppet, >= 6.0.0' + s.add_runtime_dependency 'rgen', '~> 0.9' + s.add_runtime_dependency 'yard', '~> 0.9' + s.requirements << 'puppet, >= 7.0.0' end From cc302b58e068e8ce1649217f7a83850dba56083d Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Thu, 13 Apr 2023 13:35:57 +0100 Subject: [PATCH 02/60] (CONT-812) Update test matrix setups --- .github/workflows/ci.yml | 43 +++++++++++++++++++++++++++++------ .github/workflows/nightly.yml | 43 ++++++++++++++++++++++++++++------- 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00aaca05..feec48d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,24 +1,53 @@ name: "ci" on: - schedule: - - cron: "0 0 * * *" + pull_request: + branches: + - "main" workflow_dispatch: jobs: - spec: + strategy: + 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: 'https://github.com/puppetlabs/puppet' # puppet8' + runs_on: + - "ubuntu-latest" + - "windows-latest" + name: "spec (${{ matrix.runs_on }} ruby ${{ matrix.ruby_version }} | puppet ${{matrix.puppet_gem_version}})" uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main" secrets: "inherit" + with: + ruby_version: ${{ matrix.ruby_version }} + puppet_gem_version: ${{ matrix.puppet_gem_version }} + runs_on: ${{ matrix.runs_on }} acceptance: needs: "spec" strategy: matrix: - puppet: - - "puppet6" - - "puppet7" + 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: + - "ubuntu-latest" + - "windows-latest" uses: "puppetlabs/cat-github-actions/.github/workflows/gem_acceptance.yml@main" secrets: "inherit" with: - puppet_version: ${{ matrix.puppet }} + ruby_version: ${{ matrix.ruby_version }} + puppet_version: ${{ matrix.puppet_gem_version }} + runs_on: ${{ matrix.runs_on }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index d6eddb51..b7af4460 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,25 +1,52 @@ name: "nightly" on: - pull_request: - branches: - - "main" + schedule: + - cron: "0 0 * * *" workflow_dispatch: jobs: - spec: + strategy: + 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: 'https://github.com/puppetlabs/puppet' # puppet8' + runs_on: + - "ubuntu-latest" + - "windows-latest" + name: "spec (${{ matrix.runs_on }} ruby ${{ matrix.ruby_version }} | puppet ${{matrix.puppet_gem_version}})" uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main" secrets: "inherit" + with: + ruby_version: ${{ matrix.ruby_version }} + puppet_gem_version: ${{ matrix.puppet_gem_version }} + runs_on: ${{ matrix.runs_on }} acceptance: needs: "spec" strategy: matrix: - puppet: - - "puppet6" - - "puppet7" + 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: + - "ubuntu-latest" + - "windows-latest" uses: "puppetlabs/cat-github-actions/.github/workflows/gem_acceptance.yml@main" secrets: "inherit" with: - puppet_version: ${{ matrix.puppet }} + ruby_version: ${{ matrix.ruby_version }} + puppet_version: ${{ matrix.puppet_gem_version }} + runs_on: ${{ matrix.runs_on }} From fa334f3610f3e536bc44d58bb82666090be8c4b1 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Thu, 13 Apr 2023 13:36:21 +0100 Subject: [PATCH 03/60] (CONT-812) Update acceptance test setup --- .fixtures.yml | 3 +- Rakefile | 140 +-------------------------- spec/spec_helper_acceptance_local.rb | 2 +- 3 files changed, 8 insertions(+), 137 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index d59a99b4..bb49d80e 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -3,4 +3,5 @@ fixtures: facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' provision: 'https://github.com/puppetlabs/provision.git' puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - symlinks: [] + symlinks: + test: "#{source_dir}/spec/fixtures/acceptance/modules/test" diff --git a/Rakefile b/Rakefile index aa00696e..9a7c6f9c 100644 --- a/Rakefile +++ b/Rakefile @@ -15,7 +15,12 @@ RSpec::Core::RakeTask.new(:spec) do |t| t.exclude_pattern = "spec/acceptance/**/*.rb" end +RSpec::Core::RakeTask.new(:acceptance) do |t| + t.pattern = "spec/unit/**/*.rb" +end + task :spec => :spec_clean +task :acceptance => :spec_prep # Add our own tasks require 'puppet-strings/tasks' @@ -32,138 +37,3 @@ task :validate do sh "erb -P -x -T '-' #{template} | ruby -c" end end - -namespace :litmus do - def install_remote_gem(gem_name, target_nodes, inventory_hash) - # TODO: Currently this is Linux only - install_command = "/opt/puppetlabs/puppet/bin/gem install #{gem_name}" - result = run_command(install_command, target_nodes, config: nil, inventory: inventory_hash) - if result.is_a?(Array) - result.each do |node| - puts "#{node['target']} failed: '#{node['value']}'" if node['status'] != 'success' - end - else - raise "Failed trying to run '#{install_command}' against inventory." - end - end - - def install_build_tools(target_nodes, inventory_hash) - puts 'Installing build tools...' - install_build_command = "yum -y group install 'Development Tools'" - result = run_command(install_build_command, target_nodes, config: nil, inventory: inventory_hash) - if result.is_a?(Array) - result.each do |node| - puts "#{node['target']} failed: '#{node['value']}'" if node['status'] != 'success' - end - else - raise "Failed trying to run '#{install_build_command}' against inventory." - end - end - - # Install the gem under test and required fixture on a collection of nodes - # - # @param :target_node_name [Array] nodes on which to install a puppet module for testing. - desc 'install_gems - build and install module fixtures' - task :install_gems, [:target_node_name] do |_task, args| - inventory_hash = inventory_hash_from_inventory_file - target_nodes = find_targets(inventory_hash, args[:target_node_name]) - if target_nodes.empty? - puts 'No targets found' - exit 0 - end - require 'bolt_spec/run' - include BoltSpec::Run - - # Build the gem - puts 'Building gem...' - `gem build puppet-strings.gemspec --quiet` - result = $CHILD_STATUS - raise "Unable to build the puppet-strings gem. Returned exit code #{result.exitstatus}" unless result.exitstatus.zero? - - # Find the gem build artifact - gem_tar = Dir.glob('puppet-strings-*.gem').max_by { |f| File.mtime(f) } - raise "Unable to find package in 'puppet-strings-*.gem'" if gem_tar.nil? - - gem_tar = File.expand_path(gem_tar) - - target_string = if args[:target_node_name].nil? - 'all' - else - args[:target_node_name] - end - puts 'Copying gem to targets...' - upload_file(gem_tar, File.basename(gem_tar), target_string, inventory: inventory_hash) - - install_build_tools(target_nodes, inventory_hash) - - # Install dependent gems - puts 'Installing yard gem...' - install_remote_gem('yard', target_nodes, inventory_hash) - puts 'Installing rgen gem...' - install_remote_gem('rgen', target_nodes, inventory_hash) - # Install puppet-strings - puts 'Installing puppet-strings gem...' - install_remote_gem(File.basename(gem_tar), target_nodes, inventory_hash) - puts 'Installed' - end -end - -#### CHANGELOG #### -begin - require 'github_changelog_generator/task' - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - require 'puppet-strings/version' - config.future_release = "v#{PuppetStrings::VERSION}" - config.header = "# Changelog\n\n" \ - "All significant changes to this repo will be summarized in this file.\n" - config.configure_sections = { - added: { - prefix: "Added", - labels: ["enhancement"] - }, - fixed: { - prefix: "Fixed", - labels: ["bugfix"] - }, - breaking: { - prefix: "Changed", - labels: ["backwards-incompatible"] - } - } - config.exclude_labels = ['maintenance','incomplete'] - config.user = 'puppetlabs' - config.project = 'puppet-strings' - end -rescue LoadError - desc 'Install github_changelog_generator to get access to automatic changelog generation' - task :changelog do - raise 'Install github_changelog_generator to get access to automatic changelog generation' - end -end - -desc 'Run acceptance tests' -task :acceptance do - - begin - if ENV['MATRIX_TARGET'] - agent_version = ENV['MATRIX_TARGET'].chomp - else - agent_version = 'puppet7' - end - - Rake::Task['litmus:provision'].invoke('docker', 'litmusimage/centos:7') - - Rake::Task['litmus:install_agent'].invoke(agent_version.to_s) - - Rake::Task['litmus:install_modules_from_directory'].invoke('./spec/fixtures/acceptance/modules') - - Rake::Task['litmus:install_gems'].invoke - - Rake::Task['litmus:acceptance:parallel'].invoke - - rescue StandardError => e - puts e.message - raise e - end - -end diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index 7234e697..17366c64 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true def sut_module_path(module_regex) - modules = JSON.parse(run_shell('puppet module list --render-as json').stdout) + modules = JSON.parse(run_shell('bundle exec puppet module list --modulepath spec/fixtures/modules --render-as json').stdout) test_module_info = modules['modules_by_path'].values.flatten.find { |mod_info| mod_info =~ module_regex } test_module_info.match(%r{\(([^)]*)\)})[1] end From 5fa82770495340443cab92251ead4423e4c73eb2 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Thu, 13 Apr 2023 13:45:33 +0100 Subject: [PATCH 04/60] (CONT-812) Update rubocop config --- .rubocop.yml | 527 ++-------------------------------------------- .rubocop_todo.yml | 198 +++++++++++++++++ 2 files changed, 211 insertions(+), 514 deletions(-) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 35821c9b..2ccc89f3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,520 +1,19 @@ ---- +inherit_from: .rubocop_todo.yml + require: -- rubocop-performance -- rubocop-rspec + - rubocop-performance + - rubocop-rspec + AllCops: - DisplayCopNames: true - TargetRubyVersion: '2.5' - Include: - - "**/*.rb" Exclude: - - bin/* - - ".vendor/**/*" - - "**/Gemfile" - - "**/Rakefile" - - pkg/**/* - - spec/fixtures/**/* - - vendor/**/* - - "**/Puppetfile" - - "**/Vagrantfile" - - "**/Guardfile" - - '**/*.erb' - - 'lib/puppet-strings/yard/templates/**/*' + - Gemfile + - Rakefile + - spec/fixtures/**/* + - vendor/bundle/**/* + NewCops: enable SuggestExtensions: false -Layout/LineLength: - Description: People have wide screens, use them. - Max: 200 -RSpec/BeforeAfterAll: - Description: Beware of using after(:all) as it may cause state to leak between tests. - A necessary evil in acceptance testing. - Exclude: - - spec/acceptance/**/*.rb -RSpec/HookArgument: - Description: Prefer explicit :each argument, matching existing module's style - EnforcedStyle: each -Style/BlockDelimiters: - Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to - be consistent then. - EnforcedStyle: braces_for_chaining + TargetRubyVersion: '2.7' + +# Disabled Style/ClassAndModuleChildren: - Description: Compact style reduces the required amount of indentation. - EnforcedStyle: compact -Style/EmptyElse: - Description: Enforce against empty else clauses, but allow `nil` for clarity. - EnforcedStyle: empty -Style/FormatString: - Description: Following the main puppet project's style, prefer the % format format. - EnforcedStyle: percent -Style/FormatStringToken: - Description: Following the main puppet project's style, prefer the simpler template - tokens over annotated ones. - EnforcedStyle: template -Style/Lambda: - Description: Prefer the keyword for easier discoverability. - EnforcedStyle: literal -Style/RegexpLiteral: - Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 - EnforcedStyle: percent_r -Style/TernaryParentheses: - Description: Checks for use of parentheses around ternary conditions. Enforce parentheses - on complex expressions for better readability, but seriously consider breaking - it up. - EnforcedStyle: require_parentheses_when_complex -Style/TrailingCommaInArguments: - Description: Prefer always trailing comma on multiline argument lists. This makes - diffs, and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/TrailingCommaInArrayLiteral: - Description: Prefer always trailing comma on multiline literals. This makes diffs, - and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/SymbolArray: - Description: Using percent style obscures symbolic intent of array's contents. - EnforcedStyle: brackets -RSpec/MessageSpies: - EnforcedStyle: receive -Style/Documentation: - Exclude: - - spec/**/* -Style/WordArray: - EnforcedStyle: brackets -Performance/AncestorsInclude: - Enabled: true -Performance/BigDecimalWithNumericArgument: - Enabled: true -Performance/BlockGivenWithExplicitBlock: - Enabled: true -Performance/CaseWhenSplat: - Enabled: true -Performance/ConstantRegexp: - Enabled: true -Performance/MethodObjectAsBlock: - Enabled: true -Performance/RedundantSortBlock: - Enabled: true -Performance/RedundantStringChars: - Enabled: true -Performance/ReverseFirst: - Enabled: true -Performance/SortReverse: - Enabled: true -Performance/Squeeze: - Enabled: true -Performance/StringInclude: - Enabled: true -Performance/Sum: - Enabled: true -Style/CollectionMethods: - Enabled: true -Style/MethodCalledOnDoEndBlock: - Enabled: true -Style/StringMethods: - Enabled: true -Bundler/InsecureProtocolSource: - Enabled: false -Gemspec/DuplicatedAssignment: - Enabled: false -Gemspec/OrderedDependencies: - Enabled: false -Gemspec/RequiredRubyVersion: - Enabled: false -Gemspec/RubyVersionGlobalsUsage: - Enabled: false -Layout/ArgumentAlignment: - Enabled: false -Layout/BeginEndAlignment: - Enabled: false -Layout/ClosingHeredocIndentation: - Enabled: true -Layout/EmptyComment: - Enabled: false -Layout/EmptyLineAfterGuardClause: - Enabled: false -Layout/EmptyLinesAroundArguments: - Enabled: false -Layout/EmptyLinesAroundAttributeAccessor: - Enabled: false -Layout/EndOfLine: - Enabled: false -Layout/FirstArgumentIndentation: - Enabled: false -Layout/HashAlignment: - Enabled: false -Layout/HeredocIndentation: - Enabled: true -Layout/LeadingEmptyLines: - Enabled: false -Layout/SpaceAroundMethodCallOperator: - Enabled: false -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: false -Layout/SpaceInsideReferenceBrackets: - Enabled: false -Lint/BigDecimalNew: - Enabled: false -Lint/BooleanSymbol: - Enabled: false -Lint/ConstantDefinitionInBlock: - Enabled: false -Lint/DeprecatedOpenSSLConstant: - Enabled: false -Lint/DisjunctiveAssignmentInConstructor: - Enabled: false -Lint/DuplicateElsifCondition: - Enabled: false -Lint/DuplicateRequire: - Enabled: false -Lint/DuplicateRescueException: - Enabled: false -Lint/EmptyConditionalBody: - Enabled: false -Lint/EmptyFile: - Enabled: false -Lint/ErbNewArguments: - Enabled: false -Lint/FloatComparison: - Enabled: false -Lint/HashCompareByIdentity: - Enabled: false -Lint/IdentityComparison: - Enabled: false -Lint/InterpolationCheck: - Enabled: false -Lint/MissingCopEnableDirective: - Enabled: false -Lint/MixedRegexpCaptureTypes: - Enabled: false -Lint/NestedPercentLiteral: - Enabled: false -Lint/NonDeterministicRequireOrder: - Enabled: false -Lint/OrderedMagicComments: - Enabled: false -Lint/OutOfRangeRegexpRef: - Enabled: false -Lint/RaiseException: - Enabled: false -Lint/RedundantCopEnableDirective: - Enabled: false -Lint/RedundantRequireStatement: - Enabled: false -Lint/RedundantSafeNavigation: - Enabled: false -Lint/RedundantWithIndex: - Enabled: false -Lint/RedundantWithObject: - Enabled: false -Lint/RegexpAsCondition: - Enabled: false -Lint/ReturnInVoidContext: - Enabled: false -Lint/SafeNavigationConsistency: - Enabled: false -Lint/SafeNavigationWithEmpty: - Enabled: false -Lint/SelfAssignment: - Enabled: false -Lint/SendWithMixinArgument: - Enabled: false -Lint/ShadowedArgument: - Enabled: false -Lint/StructNewOverride: - Enabled: false -Lint/ToJSON: - Enabled: false -Lint/TopLevelReturnWithArgument: - Enabled: false -Lint/TrailingCommaInAttributeDeclaration: - Enabled: false -Lint/UnreachableLoop: - Enabled: false -Lint/UriEscapeUnescape: - Enabled: false -Lint/UriRegexp: - Enabled: false -Lint/UselessMethodDefinition: - Enabled: false -Lint/UselessTimes: - Enabled: false -Metrics/AbcSize: - Enabled: false -Metrics/BlockLength: - Enabled: false -Metrics/BlockNesting: - Enabled: false -Metrics/ClassLength: - Enabled: false -Metrics/CyclomaticComplexity: - Enabled: false -Metrics/MethodLength: - Enabled: false -Metrics/ModuleLength: - Enabled: false -Metrics/ParameterLists: - Enabled: false -Metrics/PerceivedComplexity: - Enabled: false -Migration/DepartmentName: - Enabled: false -Naming/AccessorMethodName: - Enabled: false -Naming/BlockParameterName: - Enabled: false -Naming/HeredocDelimiterCase: - Enabled: false -Naming/HeredocDelimiterNaming: - Enabled: false -Naming/MemoizedInstanceVariableName: - Enabled: false -Naming/MethodParameterName: - Enabled: false -Naming/RescuedExceptionsVariableName: - Enabled: false -Naming/VariableNumber: - Enabled: false -Performance/BindCall: - Enabled: false -Performance/DeletePrefix: - Enabled: false -Performance/DeleteSuffix: - Enabled: false -Performance/InefficientHashSearch: - Enabled: false -Performance/UnfreezeString: - Enabled: false -Performance/UriDefaultParser: - Enabled: false -RSpec/Be: - Enabled: false -RSpec/Capybara/CurrentPathExpectation: - Enabled: false -RSpec/Capybara/FeatureMethods: - Enabled: false -RSpec/Capybara/VisibilityMatcher: - Enabled: false -RSpec/ContextMethod: - Enabled: false -RSpec/ContextWording: - Enabled: false -RSpec/DescribeClass: - Enabled: false -RSpec/EmptyHook: - Enabled: false -RSpec/EmptyLineAfterExample: - Enabled: false -RSpec/EmptyLineAfterExampleGroup: - Enabled: false -RSpec/EmptyLineAfterHook: - Enabled: false -RSpec/ExampleLength: - Enabled: false -RSpec/ExampleWithoutDescription: - Enabled: false -RSpec/ExpectChange: - Enabled: false -RSpec/ExpectInHook: - Enabled: false -RSpec/FactoryBot/AttributeDefinedStatically: - Enabled: false -RSpec/FactoryBot/CreateList: - Enabled: false -RSpec/FactoryBot/FactoryClassName: - Enabled: false -RSpec/FilePath: - Enabled: false -RSpec/HooksBeforeExamples: - Enabled: false -RSpec/ImplicitBlockExpectation: - Enabled: false -RSpec/ImplicitSubject: - Enabled: false -RSpec/LeakyConstantDeclaration: - Enabled: false -RSpec/LetBeforeExamples: - Enabled: false -RSpec/MissingExampleGroupArgument: - Enabled: false -RSpec/MultipleExpectations: - Enabled: false -RSpec/MultipleMemoizedHelpers: - Enabled: false -RSpec/MultipleSubjects: - Enabled: false -RSpec/NestedGroups: - Enabled: false -RSpec/PredicateMatcher: - Enabled: false -RSpec/ReceiveCounts: - Enabled: false -RSpec/ReceiveNever: - Enabled: false -RSpec/RepeatedExampleGroupBody: - Enabled: false -RSpec/RepeatedExampleGroupDescription: - Enabled: false -RSpec/RepeatedIncludeExample: - Enabled: false -RSpec/ReturnFromStub: - Enabled: false -RSpec/SharedExamples: - Enabled: false -RSpec/StubbedMock: - Enabled: false -RSpec/UnspecifiedException: - Enabled: false -RSpec/VariableDefinition: - Enabled: false -RSpec/VoidExpect: - Enabled: false -RSpec/Yield: - Enabled: false -Security/Open: - Enabled: false -Style/AccessModifierDeclarations: - Enabled: false -Style/AccessorGrouping: - Enabled: false -Style/AsciiComments: - Enabled: false -Style/BisectedAttrAccessor: - Enabled: false -Style/CaseLikeIf: - Enabled: false -Style/ClassEqualityComparison: - Enabled: false -Style/ColonMethodDefinition: - Enabled: false -Style/CombinableLoops: - Enabled: false -Style/CommentedKeyword: - Enabled: false -Style/Dir: - Enabled: false -Style/DoubleCopDisableDirective: - Enabled: false -Style/EmptyBlockParameter: - Enabled: false -Style/EmptyLambdaParameter: - Enabled: false -Style/Encoding: - Enabled: false -Style/EvalWithLocation: - Enabled: false -Style/ExpandPathArguments: - Enabled: false -Style/ExplicitBlockArgument: - Enabled: false -Style/ExponentialNotation: - Enabled: false -Style/FloatDivision: - Enabled: false -Style/FrozenStringLiteralComment: - Enabled: false -Style/GlobalStdStream: - Enabled: false -Style/HashAsLastArrayItem: - Enabled: false -Style/HashLikeCase: - Enabled: false -Style/HashTransformKeys: - Enabled: false -Style/HashTransformValues: - Enabled: false -Style/IfUnlessModifier: - Enabled: false -Style/KeywordParametersOrder: - Enabled: false -Style/MinMax: - Enabled: false -Style/MixinUsage: - Enabled: false -Style/MultilineWhenThen: - Enabled: false -Style/NegatedUnless: - Enabled: false -Style/NumericPredicate: - Enabled: false -Style/OptionalBooleanParameter: - Enabled: false -Style/OrAssignment: - Enabled: false -Style/RandomWithOffset: - Enabled: false -Style/RedundantAssignment: - Enabled: false -Style/RedundantCondition: - Enabled: false -Style/RedundantConditional: - Enabled: false -Style/RedundantFetchBlock: - Enabled: false -Style/RedundantFileExtensionInRequire: - Enabled: false -Style/RedundantRegexpCharacterClass: - Enabled: false -Style/RedundantRegexpEscape: - Enabled: false -Style/RedundantSelfAssignment: - Enabled: false -Style/RedundantSort: - Enabled: false -Style/RescueStandardError: - Enabled: false -Style/SingleArgumentDig: - Enabled: false -Style/SlicingWithRange: - Enabled: false -Style/SoleNestedConditional: - Enabled: false -Style/StderrPuts: - Enabled: false -Style/StringConcatenation: - Enabled: false -Style/Strip: - Enabled: false -Style/SymbolProc: - Enabled: false -Style/TrailingBodyOnClass: - Enabled: false -Style/TrailingBodyOnMethodDefinition: - Enabled: false -Style/TrailingBodyOnModule: - Enabled: false -Style/TrailingCommaInHashLiteral: - Enabled: false -Style/TrailingMethodEndStatement: - Enabled: false -Style/UnpackFirst: - Enabled: false -Lint/DuplicateBranch: - Enabled: false -Lint/DuplicateRegexpCharacterClassElement: - Enabled: false -Lint/EmptyBlock: - Enabled: false -Lint/EmptyClass: - Enabled: false -Lint/NoReturnInBeginEndBlocks: - Enabled: false -Lint/ToEnumArguments: - Enabled: false -Lint/UnexpectedBlockArity: - Enabled: false -Lint/UnmodifiedReduceAccumulator: - Enabled: false -Performance/CollectionLiteralInLoop: - Enabled: false -Style/ArgumentsForwarding: - Enabled: false -Style/CollectionCompact: - Enabled: false -Style/DocumentDynamicEvalDefinition: - Enabled: false -Style/NegatedIfElseCondition: - Enabled: false -Style/NilLambda: - Enabled: false -Style/RedundantArgument: - Enabled: false -Style/SwapValues: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..b91c658b --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,198 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-04-13 12:45:07 UTC using RuboCop version 1.50.1. +# 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 +# versions of RuboCop, may require this file to be generated again. + +Naming/FileName: + Exclude: + - 'lib/puppet-strings.rb' + +Naming/MethodName: + Exclude: + - 'lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb' + - 'lib/puppet-strings/yard/parsers/puppet/parser.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/RequireMFA: + Exclude: + - 'puppet-strings.gemspec' + +# Offense count: 46 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 98 + +# Offense count: 11 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. +# AllowedMethods: refine +Metrics/BlockLength: + Max: 119 + +# Offense count: 1 +# Configuration parameters: CountBlocks. +Metrics/BlockNesting: + Max: 4 + +# Offense count: 5 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ClassLength: + Max: 283 + +# Offense count: 33 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/CyclomaticComplexity: + Max: 36 + +# Offense count: 44 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Max: 75 + +# Offense count: 2 +# Configuration parameters: CountKeywordArgs. +Metrics/ParameterLists: + MaxOptionalParameters: 5 + Max: 10 + +# Offense count: 28 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/PerceivedComplexity: + Max: 37 + +# Offense count: 2 +Naming/AccessorMethodName: + Exclude: + - 'lib/puppet-strings/yard/handlers/puppet/base.rb' + - 'lib/puppet-strings/yard/handlers/ruby/type_base.rb' + +# Offense count: 1 +# Configuration parameters: ForbiddenDelimiters. +# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +Naming/HeredocDelimiterNaming: + Exclude: + - 'spec/acceptance/generate_markdown_spec.rb' + +# Offense count: 24 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb' + - 'lib/puppet-strings/yard/parsers/puppet/parser.rb' + +# Offense count: 2 +# Configuration parameters: MinSize. +Performance/CollectionLiteralInLoop: + Exclude: + - 'lib/puppet-strings/yard/handlers/ruby/provider_handler.rb' + - 'lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb' + +# Offense count: 1 +RSpec/BeforeAfterAll: + Exclude: + - 'spec/spec_helper.rb' + - 'spec/rails_helper.rb' + - 'spec/support/**/*.rb' + - 'spec/acceptance/running_strings_generate_spec.rb' + +# Offense count: 7 +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/unit/puppet-strings/markdown/base_spec.rb' + - 'spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb' + - 'spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb' + - 'spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb' + +# Offense count: 3 +# Configuration parameters: IgnoredMetadata. +RSpec/DescribeClass: + Exclude: + - '**/spec/features/**/*' + - '**/spec/requests/**/*' + - '**/spec/routing/**/*' + - '**/spec/system/**/*' + - '**/spec/views/**/*' + - 'spec/acceptance/generate_json_spec.rb' + - 'spec/acceptance/generate_markdown_spec.rb' + - 'spec/acceptance/running_strings_generate_spec.rb' + +# Offense count: 48 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 66 + +# Offense count: 6 +RSpec/ExpectInHook: + Exclude: + - 'spec/unit/puppet-strings/json_spec.rb' + +# Offense count: 20 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/FilePath: + Enabled: false + +# Offense count: 91 +RSpec/MultipleExpectations: + Max: 64 + +# Offense count: 5 +# Configuration parameters: AllowedGroups. +RSpec/NestedGroups: + Max: 4 + +# Offense count: 2 +RSpec/RepeatedExampleGroupDescription: + Exclude: + - 'spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb' + +# Offense count: 1 +Style/ClassVars: + Exclude: + - 'lib/puppet-strings/yard/templates/default/layout/html/setup.rb' + +# Offense count: 3 +Style/CombinableLoops: + Exclude: + - 'lib/puppet-strings/markdown.rb' + - 'lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb' + - 'lib/puppet-strings/tasks/generate.rb' + +# Offense count: 1 +Style/MixinUsage: + Exclude: + - 'spec/acceptance/running_strings_generate_spec.rb' + +# Offense count: 17 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'lib/puppet-strings.rb' + - 'lib/puppet-strings/describe.rb' + - 'lib/puppet-strings/yard/code_objects/class.rb' + - 'lib/puppet-strings/yard/code_objects/data_type.rb' + - 'lib/puppet-strings/yard/code_objects/data_type_alias.rb' + - 'lib/puppet-strings/yard/code_objects/defined_type.rb' + - 'lib/puppet-strings/yard/code_objects/function.rb' + - 'lib/puppet-strings/yard/code_objects/plan.rb' + - 'lib/puppet-strings/yard/code_objects/provider.rb' + - 'lib/puppet-strings/yard/code_objects/task.rb' + - '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: 139 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 200 From cb6d2dc8a6156a65e3e24913ee14b99ed40527ed Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Thu, 13 Apr 2023 14:15:54 +0100 Subject: [PATCH 05/60] (CONT-812) Fix failing acceptance test --- spec/acceptance/running_strings_generate_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/running_strings_generate_spec.rb b/spec/acceptance/running_strings_generate_spec.rb index af37a9a4..e65bb65f 100644 --- a/spec/acceptance/running_strings_generate_spec.rb +++ b/spec/acceptance/running_strings_generate_spec.rb @@ -87,9 +87,9 @@ def expect_file_contain(path, expected_contents) expect_file_contain('doc/puppet_classes/test.html', [ '

Enum Options (myenum):

', 'a', - "—
\n

Option A

\n
", + "—

Option A

\n
", 'b', - "—
\n

Option B

\n
", + "—

Option B

\n
", ]) end end From ce14c005616994e486896f0610bba96b590d2f9e Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 11:57:04 +0100 Subject: [PATCH 06/60] (CONT-812) Correct Layout/EmptyLineAfterGuardClause --- lib/puppet-strings.rb | 1 + lib/puppet-strings/tasks/generate.rb | 2 ++ lib/puppet-strings/yard/handlers/helpers.rb | 1 + lib/puppet-strings/yard/handlers/json/task_handler.rb | 1 + lib/puppet-strings/yard/handlers/ruby/function_handler.rb | 1 + lib/puppet-strings/yard/handlers/ruby/type_base.rb | 1 + lib/puppet-strings/yard/parsers/puppet/statement.rb | 3 +++ 7 files changed, 10 insertions(+) diff --git a/lib/puppet-strings.rb b/lib/puppet-strings.rb index db65123e..02193729 100644 --- a/lib/puppet-strings.rb +++ b/lib/puppet-strings.rb @@ -60,6 +60,7 @@ def self.generate(search_patterns = DEFAULT_SEARCH_PATTERNS, options = {}) end return unless options[:describe] + render_describe(options[:describe_types], options[:describe_list], options[:providers]) end diff --git a/lib/puppet-strings/tasks/generate.rb b/lib/puppet-strings/tasks/generate.rb index 57b8d993..3fd84095 100644 --- a/lib/puppet-strings/tasks/generate.rb +++ b/lib/puppet-strings/tasks/generate.rb @@ -29,8 +29,10 @@ # @return nil def parse_format_option(args, options, format) return unless args.has_key? format + options[format] = args[format] == 'false' || args[format].empty? ? false : true return unless options[format] + options[:path] = args[format] == 'true' ? nil : args[format] end # rubocop:enable Style/PreferredHashMethods diff --git a/lib/puppet-strings/yard/handlers/helpers.rb b/lib/puppet-strings/yard/handlers/helpers.rb index 35828260..61070fd4 100644 --- a/lib/puppet-strings/yard/handlers/helpers.rb +++ b/lib/puppet-strings/yard/handlers/helpers.rb @@ -4,6 +4,7 @@ module PuppetStrings::Yard::Handlers::Helpers def self.validate_summary_tag(object) return unless object.has_tag?(:summary) && object.tag(:summary).text.length > 140 + log.warn "The length of the summary for #{object.type} '#{object.name}' exceeds the recommended limit of 140 characters." end end diff --git a/lib/puppet-strings/yard/handlers/json/task_handler.rb b/lib/puppet-strings/yard/handlers/json/task_handler.rb index 6ce505f7..19652fdc 100644 --- a/lib/puppet-strings/yard/handlers/json/task_handler.rb +++ b/lib/puppet-strings/yard/handlers/json/task_handler.rb @@ -26,6 +26,7 @@ def validate_description def validate_params return if @statement.parameters.empty? + @statement.parameters.each do |param, val| log.warn "Missing description for param '#{param}' in #{@kind}" if val['description'].nil? end diff --git a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb index dbf067d5..74b8eab6 100644 --- a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb @@ -123,6 +123,7 @@ def add_tags(object) # If there's only one overload, move the tags to the object itself return unless overloads.length == 1 + overload = overloads.first object.parameters = overload.parameters object.add_tag(*overload.tags) diff --git a/lib/puppet-strings/yard/handlers/ruby/type_base.rb b/lib/puppet-strings/yard/handlers/ruby/type_base.rb index ea681f88..450ac60c 100644 --- a/lib/puppet-strings/yard/handlers/ruby/type_base.rb +++ b/lib/puppet-strings/yard/handlers/ruby/type_base.rb @@ -110,6 +110,7 @@ def set_values(node, object) return unless object.is_a? PuppetStrings::Yard::CodeObjects::Type::Parameter # Process the options for parameter base types return unless parameters.count >= 2 + parameters[1].each do |kvp| next unless kvp.count == 2 next unless node_as_string(kvp[0]) == 'parent' diff --git a/lib/puppet-strings/yard/parsers/puppet/statement.rb b/lib/puppet-strings/yard/parsers/puppet/statement.rb index a5247940..3a414f20 100644 --- a/lib/puppet-strings/yard/parsers/puppet/statement.rb +++ b/lib/puppet-strings/yard/parsers/puppet/statement.rb @@ -89,6 +89,7 @@ def initialize(parameter) end # Take the exact text for the default value expression return unless parameter.value + @value = PuppetStrings::Yard::Util.ast_to_text(parameter.value) end end @@ -144,8 +145,10 @@ def initialize(object, file) super(object, file) @name = object.name return unless object.respond_to? :return_type + type = object.return_type return unless type + @type = PuppetStrings::Yard::Util.ast_to_text(type).gsub('>> ', '') end end From e917077f435d49c272128d1cbfbf43bbb2905e50 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 11:57:55 +0100 Subject: [PATCH 07/60] (CONT-812) Correct Layout/HashAlignment --- spec/acceptance/generate_json_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/generate_json_spec.rb b/spec/acceptance/generate_json_spec.rb index 5858a69b..08d37ea1 100644 --- a/spec/acceptance/generate_json_spec.rb +++ b/spec/acceptance/generate_json_spec.rb @@ -43,7 +43,7 @@ 'text' => 'This is the function documentation for `function3x`', 'tags' => ['tag_name' => 'return', 'text' => '', 'types' => ['Any']] }, - 'source' => "Puppet::Parser::Functions.newfunction(:function3x, :doc => \"This is the function documentation for `function3x`\") do |args|\nend", + 'source' => "Puppet::Parser::Functions.newfunction(:function3x, :doc => \"This is the function documentation for `function3x`\") do |args|\nend", ], 'puppet_tasks' => [], 'puppet_plans' => [] From 75c653fed0058d30e095630eda4d9d777657d2c0 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 11:58:37 +0100 Subject: [PATCH 08/60] (CONT-812) Correct Layout/LeadingCommentSpace --- .../templates/default/puppet_data_type_alias/html/setup.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb index 288661e7..890e7efc 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb @@ -9,8 +9,8 @@ def init def alias_of # Properties are the same thing as parameters (from the documentation standpoint), # so reuse the same template but with a different title and data source. - #@parameters = object.properties || [] - #@parameters.sort_by! { |p| p.name } + # @parameters = object.properties || [] + # @parameters.sort_by! { |p| p.name } @tag_title = 'Alias of' @alias_of = object.alias_of erb(:alias_of) From f23f0f145a756eb95d3442e62a3d3ed1af964af6 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 11:59:23 +0100 Subject: [PATCH 09/60] (CONT-812) Correct Layout/LineContinuationSpacing --- lib/puppet-strings/yard/handlers/puppet/base.rb | 4 ++-- .../yard/handlers/ruby/data_type_handler.rb | 4 ++-- .../yard/handlers/ruby/function_handler.rb | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/puppet-strings/yard/handlers/puppet/base.rb b/lib/puppet-strings/yard/handlers/puppet/base.rb index bbc71314..34a34886 100644 --- a/lib/puppet-strings/yard/handlers/puppet/base.rb +++ b/lib/puppet-strings/yard/handlers/puppet/base.rb @@ -37,8 +37,8 @@ def set_parameter_types(object) # Warn if the parameter type and tag types don't match if parameter.type && tag.types && !tag.types.empty? && parameter.type != tag.types[0] - log.warn "The type of the @param tag for parameter '#{parameter.name}' "\ - "does not match the parameter type specification near #{statement.file}:#{statement.line}: "\ + log.warn "The type of the @param tag for parameter '#{parameter.name}' " \ + "does not match the parameter type specification near #{statement.file}:#{statement.line}: " \ 'ignoring in favor of parameter type information.' end diff --git a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb index b36ab435..0d1b86cd 100644 --- a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb @@ -379,8 +379,8 @@ def validate_function_method!(object, meth, actual_function) if tag.tag_name == 'param' index += 1 if index > actual_function[:param_types].count - log.warn "The @param tag for '#{tag.name}' should not exist for function "\ - "'#{meth.name}' that is defined near #{object.file}:#{object.line}. "\ + log.warn "The @param tag for '#{tag.name}' should not exist for function " \ + "'#{meth.name}' that is defined near #{object.file}:#{object.line}. " \ "Expected only #{actual_function[:param_types].count} parameter/s" true else diff --git a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb index 74b8eab6..938e8c80 100644 --- a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb @@ -76,20 +76,20 @@ def add_tags(object) log.warn "Missing documentation for Puppet function '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty? && object.tags.empty? unless object.tags(:param).empty? - log.warn "The docstring for Puppet 4.x function '#{object.name}' "\ - "contains @param tags near #{object.file}:#{object.line}: parameter "\ + log.warn "The docstring for Puppet 4.x function '#{object.name}' " \ + "contains @param tags near #{object.file}:#{object.line}: parameter " \ 'documentation should be made on the dispatch call.' end unless object.tags(:return).empty? - log.warn "The docstring for Puppet 4.x function '#{object.name}' "\ - "contains @return tags near #{object.file}:#{object.line}: return "\ + log.warn "The docstring for Puppet 4.x function '#{object.name}' " \ + "contains @return tags near #{object.file}:#{object.line}: return " \ 'value documentation should be made on the dispatch call.' end unless object.tags(:overload).empty? - log.warn "The docstring for Puppet 4.x function '#{object.name}' "\ - "contains @overload tags near #{object.file}:#{object.line}: overload "\ + log.warn "The docstring for Puppet 4.x function '#{object.name}' " \ + "contains @overload tags near #{object.file}:#{object.line}: overload " \ 'tags are automatically generated from the dispatch calls.' end @@ -310,8 +310,8 @@ def add_param_tag(object, tags, name, file, line, type = nil, default = nil, opt log.warn "Missing @param tag for parameter '#{name}' near #{file}:#{line}." unless tag || object.docstring.all.empty? if type && tag && tag.types && !tag.types.empty? - log.warn "The @param tag for parameter '#{name}' should not contain a "\ - "type specification near #{file}:#{line}: ignoring in favor of "\ + log.warn "The @param tag for parameter '#{name}' should not contain a " \ + "type specification near #{file}:#{line}: ignoring in favor of " \ 'dispatch type information.' end From ede86562ed5cf56b99800ae4b4cfa66253d291a7 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:00:08 +0100 Subject: [PATCH 10/60] (CONT-812) Correct Layout/LineEndStringConcatenationIndentation --- lib/puppet-strings/yard/handlers/puppet/base.rb | 4 ++-- .../yard/handlers/ruby/data_type_handler.rb | 4 ++-- .../yard/handlers/ruby/function_handler.rb | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/puppet-strings/yard/handlers/puppet/base.rb b/lib/puppet-strings/yard/handlers/puppet/base.rb index 34a34886..ffa0b0cc 100644 --- a/lib/puppet-strings/yard/handlers/puppet/base.rb +++ b/lib/puppet-strings/yard/handlers/puppet/base.rb @@ -38,8 +38,8 @@ def set_parameter_types(object) # Warn if the parameter type and tag types don't match if parameter.type && tag.types && !tag.types.empty? && parameter.type != tag.types[0] log.warn "The type of the @param tag for parameter '#{parameter.name}' " \ - "does not match the parameter type specification near #{statement.file}:#{statement.line}: " \ - 'ignoring in favor of parameter type information.' + "does not match the parameter type specification near #{statement.file}:#{statement.line}: " \ + 'ignoring in favor of parameter type information.' end if parameter.type diff --git a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb index 0d1b86cd..14246e7d 100644 --- a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb @@ -380,8 +380,8 @@ def validate_function_method!(object, meth, actual_function) index += 1 if index > actual_function[:param_types].count log.warn "The @param tag for '#{tag.name}' should not exist for function " \ - "'#{meth.name}' that is defined near #{object.file}:#{object.line}. " \ - "Expected only #{actual_function[:param_types].count} parameter/s" + "'#{meth.name}' that is defined near #{object.file}:#{object.line}. " \ + "Expected only #{actual_function[:param_types].count} parameter/s" true else false diff --git a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb index 938e8c80..55e87e61 100644 --- a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb @@ -77,20 +77,20 @@ def add_tags(object) unless object.tags(:param).empty? log.warn "The docstring for Puppet 4.x function '#{object.name}' " \ - "contains @param tags near #{object.file}:#{object.line}: parameter " \ - 'documentation should be made on the dispatch call.' + "contains @param tags near #{object.file}:#{object.line}: parameter " \ + 'documentation should be made on the dispatch call.' end unless object.tags(:return).empty? log.warn "The docstring for Puppet 4.x function '#{object.name}' " \ - "contains @return tags near #{object.file}:#{object.line}: return " \ - 'value documentation should be made on the dispatch call.' + "contains @return tags near #{object.file}:#{object.line}: return " \ + 'value documentation should be made on the dispatch call.' end unless object.tags(:overload).empty? log.warn "The docstring for Puppet 4.x function '#{object.name}' " \ - "contains @overload tags near #{object.file}:#{object.line}: overload " \ - 'tags are automatically generated from the dispatch calls.' + "contains @overload tags near #{object.file}:#{object.line}: overload " \ + 'tags are automatically generated from the dispatch calls.' end # Delete any existing param/return/overload tags @@ -311,8 +311,8 @@ def add_param_tag(object, tags, name, file, line, type = nil, default = nil, opt if type && tag && tag.types && !tag.types.empty? log.warn "The @param tag for parameter '#{name}' should not contain a " \ - "type specification near #{file}:#{line}: ignoring in favor of " \ - 'dispatch type information.' + "type specification near #{file}:#{line}: ignoring in favor of " \ + 'dispatch type information.' end if repeated From 4f731e72ce966d54d6fb3f29e216dcd96a1a427a Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:01:10 +0100 Subject: [PATCH 11/60] (CONT-812) Correct Layout/SpaceAfterComma --- lib/puppet-strings/yard/templates/default/layout/html/setup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb index 0750fce3..b837b0c5 100644 --- a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb @@ -152,7 +152,7 @@ def objects_by_letter(*types) hash = {} objects = Registry.all(*types).sort_by {|o| o.name.to_s } objects = run_verifier(objects) - objects.each {|o| (hash[o.name.to_s[0,1].upcase] ||= []) << o } + objects.each {|o| (hash[o.name.to_s[0, 1].upcase] ||= []) << o } hash end From 2533c11540d66fe8a55a94357864854e08b90243 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:01:51 +0100 Subject: [PATCH 12/60] (CONT-812) Correct Layout/SpaceAroundMethodCallOperator --- .../yard/handlers/ruby/data_type_handler_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb index 2d5fbe17..f0d8271e 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb @@ -426,13 +426,13 @@ def suppress_yard_logging it 'outputs a warning about the wrong parameter type (func1)' do expect { spec_subject - } .to output(%r{\[warn\]: The @param tag for 'foo1' for function 'func1' has a different type definition than the actual function near .+ Expected \["Integer"\]}m).to_stdout_from_any_process + }.to output(%r{\[warn\]: The @param tag for 'foo1' for function 'func1' has a different type definition than the actual function near .+ Expected \["Integer"\]}m).to_stdout_from_any_process end it 'outputs a warning about the wrong parameter type (func2)' do expect { spec_subject - } .to output(%r{\[warn\]: The @param tag for 'param1' for function 'func2' has a different type definition than the actual function near .+ Expected \["Integer"\]}m).to_stdout_from_any_process + }.to output(%r{\[warn\]: The @param tag for 'param1' for function 'func2' has a different type definition than the actual function near .+ Expected \["Integer"\]}m).to_stdout_from_any_process end it 'automatically fixes function parameters, except for differring types' do From 69e206e54d6c5a997c2597e7f251b6265ea72d68 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:02:30 +0100 Subject: [PATCH 13/60] (CONT-812) Correct Layout/SpaceInsideBlockBraces --- .../templates/default/fulldoc/html/setup.rb | 18 +++++++++--------- .../templates/default/layout/html/setup.rb | 4 ++-- .../default/puppet_data_type/html/setup.rb | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb b/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb index 4087e9d9..967615a0 100644 --- a/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb @@ -10,7 +10,7 @@ def generate_puppet_class_list # Generates the searchable Puppet data type list. # @return [void] def generate_puppet_data_type_list - @items = Registry.all(:puppet_data_type, :puppet_data_type_alias).sort_by {|dt| dt.name.to_s } + @items = Registry.all(:puppet_data_type, :puppet_data_type_alias).sort_by { |dt| dt.name.to_s } @list_title = 'Data Type List' @list_type = 'puppet_data_type' generate_list_contents @@ -19,7 +19,7 @@ def generate_puppet_data_type_list # Generates the searchable Puppet defined type list. # @return [void] def generate_puppet_defined_type_list - @items = Registry.all(:puppet_defined_type).sort_by {|dt| dt.name.to_s } + @items = Registry.all(:puppet_defined_type).sort_by { |dt| dt.name.to_s } @list_title = 'Defined Type List' @list_type = 'puppet_defined_type' generate_list_contents @@ -28,7 +28,7 @@ def generate_puppet_defined_type_list # Generates the searchable Puppet resource type list. # @return [void] def generate_puppet_type_list - @items = Registry.all(:puppet_type).sort_by {|t| t.name.to_s } + @items = Registry.all(:puppet_type).sort_by { |t| t.name.to_s } @list_title = 'Resource Type List' @list_type = 'puppet_type' generate_list_contents @@ -37,7 +37,7 @@ def generate_puppet_type_list # Generates the searchable Puppet provider list. # @return [void] def generate_puppet_provider_list - @items = Registry.all(:puppet_provider).sort_by {|p| p.name.to_s } + @items = Registry.all(:puppet_provider).sort_by { |p| p.name.to_s } @list_title = 'Provider List' @list_type = 'puppet_provider' generate_list_contents @@ -46,7 +46,7 @@ def generate_puppet_provider_list # Generates the searchable Puppet function list. # @return [void] def generate_puppet_function_list - @items = Registry.all(:puppet_function).sort_by {|f| f.name.to_s } + @items = Registry.all(:puppet_function).sort_by { |f| f.name.to_s } @list_title = 'Puppet Function List' @list_type = 'puppet_function' generate_list_contents @@ -56,8 +56,8 @@ def generate_puppet_function_list # @return [void] def generate_method_list @items = prune_method_listing(Registry.all(:method), false) - @items = @items.reject {|m| m.name.to_s =~ /=$/ && m.is_attribute? } - @items = @items.sort_by {|m| m.name.to_s } + @items = @items.reject { |m| m.name.to_s =~ /=$/ && m.is_attribute? } + @items = @items.sort_by { |m| m.name.to_s } @list_title = 'Ruby Method List' @list_type = 'method' generate_list_contents @@ -75,7 +75,7 @@ def generate_class_list # Generates the searchable Puppet Task list. # @return [void] def generate_puppet_task_list - @items = Registry.all(:puppet_task).sort_by {|t| t.name.to_s } + @items = Registry.all(:puppet_task).sort_by { |t| t.name.to_s } @list_title = 'Puppet Task List' @list_type = 'puppet_task' generate_list_contents @@ -84,7 +84,7 @@ def generate_puppet_task_list # Generates the searchable Puppet Plan list. # @return [void] def generate_puppet_plan_list - @items = Registry.all(:puppet_plan).sort_by {|t| t.name.to_s } + @items = Registry.all(:puppet_plan).sort_by { |t| t.name.to_s } @list_title = 'Puppet Plan List' @list_type = 'puppet_plan' generate_list_contents diff --git a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb index b837b0c5..e1a12d62 100644 --- a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb @@ -150,9 +150,9 @@ def menu_lists # @return [Hash] Returns a hash of first letter of the object name to list of objects. def objects_by_letter(*types) hash = {} - objects = Registry.all(*types).sort_by {|o| o.name.to_s } + objects = Registry.all(*types).sort_by { |o| o.name.to_s } objects = run_verifier(objects) - objects.each {|o| (hash[o.name.to_s[0, 1].upcase] ||= []) << o } + objects.each { |o| (hash[o.name.to_s[0, 1].upcase] ||= []) << o } hash end diff --git a/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb index e7369a2c..3364c620 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb @@ -9,5 +9,5 @@ def method_listing end def sort_listing(list) - list.sort_by {|o| [o.scope.to_s, o.name.to_s.downcase] } + list.sort_by { |o| [o.scope.to_s, o.name.to_s.downcase] } end From d7f5e446476d39e04c607b6a7a189616ad6061ad Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:22:42 +0100 Subject: [PATCH 14/60] (CONT-812) Correct Lint/ErbNewArguments --- lib/puppet-strings/markdown.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/markdown.rb b/lib/puppet-strings/markdown.rb index 3ef2e9d8..ff179997 100644 --- a/lib/puppet-strings/markdown.rb +++ b/lib/puppet-strings/markdown.rb @@ -80,7 +80,7 @@ def self.erb(path) ERB.new(File.read(path), trim_mode: '-') else # This outputs warnings in Ruby 2.6+. - ERB.new(File.read(path), nil, '-') + ERB.new(File.read(path), trim_mode: '-') end end end From 10fd31e529772c8ed977157407321bb2318dc389 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:26:24 +0100 Subject: [PATCH 15/60] (CONT-812) Correct Lint/RedundantSafeNavigation --- lib/puppet-strings/markdown.rb | 6 ++---- lib/puppet-strings/yard/tags/parameter_directive.rb | 2 +- lib/puppet-strings/yard/tags/property_directive.rb | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/puppet-strings/markdown.rb b/lib/puppet-strings/markdown.rb index ff179997..4d9763ef 100644 --- a/lib/puppet-strings/markdown.rb +++ b/lib/puppet-strings/markdown.rb @@ -76,11 +76,9 @@ def self.render(path = nil) # @param [String] path The full path to the template file. # @return [ERB] Template def self.erb(path) - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0') - ERB.new(File.read(path), trim_mode: '-') - else + unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0') # This outputs warnings in Ruby 2.6+. - ERB.new(File.read(path), trim_mode: '-') end + ERB.new(File.read(path), trim_mode: '-') end end diff --git a/lib/puppet-strings/yard/tags/parameter_directive.rb b/lib/puppet-strings/yard/tags/parameter_directive.rb index da902319..ec8506db 100644 --- a/lib/puppet-strings/yard/tags/parameter_directive.rb +++ b/lib/puppet-strings/yard/tags/parameter_directive.rb @@ -7,7 +7,7 @@ class PuppetStrings::Yard::Tags::ParameterDirective < YARD::Tags::Directive # Called to invoke the directive. # @return [void] def call - return unless object&.respond_to?(:add_parameter) + return unless object.respond_to?(:add_parameter) # Add a parameter to the resource parameter = PuppetStrings::Yard::CodeObjects::Type::Parameter.new(tag.name, tag.text) diff --git a/lib/puppet-strings/yard/tags/property_directive.rb b/lib/puppet-strings/yard/tags/property_directive.rb index 9cf25b43..999e3883 100644 --- a/lib/puppet-strings/yard/tags/property_directive.rb +++ b/lib/puppet-strings/yard/tags/property_directive.rb @@ -7,7 +7,7 @@ class PuppetStrings::Yard::Tags::PropertyDirective < YARD::Tags::Directive # Called to invoke the directive. # @return [void] def call - return unless object&.respond_to?(:add_property) + return unless object.respond_to?(:add_property) # Add a property to the resource property = PuppetStrings::Yard::CodeObjects::Type::Property.new(tag.name, tag.text) From 99b764160724240c203157ab5c22b81bd64219fd Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:31:08 +0100 Subject: [PATCH 16/60] (CONT-812) Correct Performance/BindCall --- lib/puppet-strings/yard/code_objects/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/yard/code_objects/base.rb b/lib/puppet-strings/yard/code_objects/base.rb index c6e23cec..ba58b89d 100644 --- a/lib/puppet-strings/yard/code_objects/base.rb +++ b/lib/puppet-strings/yard/code_objects/base.rb @@ -7,7 +7,7 @@ class PuppetStrings::Yard::CodeObjects::Base < YARD::CodeObjects::NamespaceObjec # @return Returns the code object. def self.new(*args) # Skip the super class' implementation because it detects :: in names and this will cause namespaces in the output we don't want - object = Object.class.instance_method(:new).bind(self).call(*args) + object = Object.class.instance_method(:new).bind_call(self, *args) existing = YARD::Registry.at(object.path) object = existing if existing && existing.class == self yield(object) if block_given? From 3231e23fff2272968c82d79440ea09ea7b366a8b Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:36:46 +0100 Subject: [PATCH 17/60] (CONT-812) Correct Performance/StringInclude --- lib/puppet-strings/markdown/function.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet-strings/markdown/function.rb b/lib/puppet-strings/markdown/function.rb index da7e215e..62f4cd17 100644 --- a/lib/puppet-strings/markdown/function.rb +++ b/lib/puppet-strings/markdown/function.rb @@ -25,11 +25,11 @@ def render def type t = @registry[:type] - if %r{ruby4x}.match?(t) + if t.include?('ruby4x') 'Ruby 4.x API' - elsif %r{ruby3}.match?(t) + elsif t.include?('ruby3') 'Ruby 3.x API' - elsif %r{ruby}.match?(t) + elsif t.include?('ruby') 'Ruby' else 'Puppet Language' From d4c582ae151097eba2873580d0744976cc58712a Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:38:11 +0100 Subject: [PATCH 18/60] (CONT-812) Correct RSpec/BeEq --- .../yard/handlers/json/task_handler_spec.rb | 2 +- .../handlers/puppet/class_handler_spec.rb | 6 ++--- .../puppet/data_type_alias_handler_spec.rb | 4 ++-- .../puppet/defined_type_handler_spec.rb | 8 +++---- .../handlers/puppet/function_handler_spec.rb | 4 ++-- .../handlers/ruby/data_type_handler_spec.rb | 2 +- .../handlers/ruby/function_handler_spec.rb | 2 +- .../handlers/ruby/provider_handler_spec.rb | 2 +- .../yard/handlers/ruby/rsapi_handler_spec.rb | 22 +++++++++---------- .../handlers/ruby/type_extras_handler_spec.rb | 2 +- .../yard/handlers/ruby/type_handler_spec.rb | 22 +++++++++---------- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb index 650b7323..82ce29c9 100644 --- a/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb @@ -24,7 +24,7 @@ it 'logs an error' do expect { spec_subject }.to output(%r{\[error\]: Failed to parse \(stdin\):}).to_stdout_from_any_process - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb index 9fedb2fd..7676bf59 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb @@ -13,7 +13,7 @@ let(:source) { 'notice hi' } it 'no classes should be in the registry' do - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end @@ -22,7 +22,7 @@ it 'logs an error' do expect { spec_subject }.to output(%r{\[error\]: Failed to parse \(stdin\): Syntax error at end of (file|input)}).to_stdout_from_any_process - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end @@ -53,7 +53,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { expect(object).to be_a(PuppetStrings::Yard::CodeObjects::Class) expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::Classes.instance) expect(object.name).to eq(:foo) - expect(object.statement).not_to eq(nil) + expect(object.statement).not_to be_nil expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', 'hi']]) expect(object.docstring).to eq('A simple foo class.') expect(object.docstring.tags.size).to eq(4) diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb index c40939ad..b99df55f 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb @@ -13,7 +13,7 @@ let(:source) { 'notice hi' } it 'no aliases should be in the registry' do - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end @@ -22,7 +22,7 @@ it 'logs an error' do expect { spec_subject }.to output(%r{\[error\]: Failed to parse \(stdin\): Syntax error at end of (file|input)}).to_stdout_from_any_process - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb index 5807d179..e673fa85 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb @@ -13,7 +13,7 @@ let(:source) { 'notice hi' } it 'no defined types should be in the registry' do - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end @@ -22,7 +22,7 @@ it 'logs an error' do expect { spec_subject }.to output(%r{\[error\]: Failed to parse \(stdin\): Syntax error at end of (file|input)}).to_stdout_from_any_process - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end @@ -58,7 +58,7 @@ expect(object).to be_a(PuppetStrings::Yard::CodeObjects::DefinedType) expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::DefinedTypes.instance) expect(object.name).to eq(:foo) - expect(object.statement).not_to eq(nil) + expect(object.statement).not_to be_nil expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', 'hi']]) expect(object.docstring).to eq('A simple foo defined type.') expect(object.docstring.tags.size).to eq(5) @@ -66,7 +66,7 @@ expect(tags.size).to eq(4) expect(tags[0].name).to eq('name') expect(tags[0].text).to eq('The type name.') - expect(tags[0].types).to eq(nil) + expect(tags[0].types).to be_nil expect(tags[1].name).to eq('param1') expect(tags[1].text).to eq('First param.') expect(tags[1].types).to eq(['Integer']) diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb index aea363e8..ba15223f 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb @@ -14,7 +14,7 @@ let(:source) { 'notice hi' } it 'no functions should be in the registry' do - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end @@ -23,7 +23,7 @@ it 'logs an error' do expect { spec_subject }.to output(%r{\[error\]: Failed to parse \(stdin\): Syntax error at end of}).to_stdout_from_any_process - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb index f0d8271e..0f62c365 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb @@ -26,7 +26,7 @@ def suppress_yard_logging let(:source) { 'puts "hi"' } it 'no data types should be in the registry' do - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb index 08ee2698..10ae2d70 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb @@ -13,7 +13,7 @@ let(:source) { 'puts "hi"' } it 'no functions should be in the registry' do - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb index 90dfc189..98b8c751 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb @@ -13,7 +13,7 @@ let(:source) { 'puts "hi"' } it 'no providers should be in the registry' do - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb index e1c841ce..46d1bf72 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb @@ -13,7 +13,7 @@ let(:source) { 'puts "hi"' } it 'no types should be in the registry' do - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end @@ -126,52 +126,52 @@ expect(object.properties.size).to eq(4) expect(object.properties[0].name).to eq('dynamic_prop') expect(object.properties[0].docstring).to eq('Documentation for a dynamic property.') - expect(object.properties[0].isnamevar).to eq(false) + expect(object.properties[0].isnamevar).to be(false) expect(object.properties[0].values).to eq(['foo', 'bar']) expect(object.properties[1].name).to eq('ensure') expect(object.properties[1].docstring).to eq('What state the database should be in.') - expect(object.properties[1].isnamevar).to eq(false) + expect(object.properties[1].isnamevar).to be(false) expect(object.properties[1].default).to eq('up') expect(object.properties[1].data_type).to eq('Enum[present, absent, up, down]') expect(object.properties[1].aliases).to eq({}) expect(object.properties[2].name).to eq('file') expect(object.properties[2].docstring).to eq('The database file to use.') - expect(object.properties[2].isnamevar).to eq(false) + expect(object.properties[2].isnamevar).to be(false) expect(object.properties[2].default).to be_nil expect(object.properties[2].data_type).to eq('String') expect(object.properties[2].aliases).to eq({}) expect(object.properties[3].name).to eq('log_level') expect(object.properties[3].docstring).to eq('The log level to use.') - expect(object.properties[3].isnamevar).to eq(false) + expect(object.properties[3].isnamevar).to be(false) expect(object.properties[3].default).to eq('warn') expect(object.properties[3].data_type).to eq('Enum[debug, warn, error]') expect(object.properties[3].aliases).to eq({}) expect(object.parameters.size).to eq(5) expect(object.parameters[0].name).to eq('dynamic_param') expect(object.parameters[0].docstring).to eq('Documentation for a dynamic parameter.') - expect(object.parameters[0].isnamevar).to eq(false) + expect(object.parameters[0].isnamevar).to be(false) expect(object.parameters[0].values).to eq(['value1', 'value2']) expect(object.parameters[1].name).to eq('address') expect(object.parameters[1].docstring).to eq('The database server name.') - expect(object.parameters[1].isnamevar).to eq(true) + expect(object.parameters[1].isnamevar).to be(true) expect(object.parameters[1].default).to be_nil expect(object.parameters[1].data_type).to eq('String') expect(object.parameters[1].aliases).to eq({}) expect(object.parameters[2].name).to eq('encrypt') expect(object.parameters[2].docstring).to eq('Whether or not to encrypt the database.') - expect(object.parameters[2].isnamevar).to eq(false) - expect(object.parameters[2].default).to eq(false) + expect(object.parameters[2].isnamevar).to be(false) + expect(object.parameters[2].default).to be(false) expect(object.parameters[2].data_type).to eq('Boolean') expect(object.parameters[2].aliases).to eq({}) expect(object.parameters[3].name).to eq('encryption_key') expect(object.parameters[3].docstring).to eq('The encryption key to use.') - expect(object.parameters[3].isnamevar).to eq(false) + expect(object.parameters[3].isnamevar).to be(false) expect(object.parameters[3].default).to be_nil expect(object.parameters[3].data_type).to eq('Optional[String]') expect(object.parameters[3].aliases).to eq({}) expect(object.parameters[4].name).to eq('backup') expect(object.parameters[4].docstring).to eq('How often to backup the database.') - expect(object.parameters[4].isnamevar).to eq(false) + expect(object.parameters[4].isnamevar).to be(false) expect(object.parameters[4].default).to eq('never') expect(object.parameters[4].data_type).to eq('Enum[daily, monthly, never]') end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/type_extras_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/type_extras_handler_spec.rb index a79239ed..734e82ba 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/type_extras_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/type_extras_handler_spec.rb @@ -44,7 +44,7 @@ expect(object.parameters.size).to eq(1) expect(object.parameters[0].name).to eq('name') expect(object.parameters[0].docstring).to eq('The database server name.') - expect(object.parameters[0].isnamevar).to eq(true) + expect(object.parameters[0].isnamevar).to be(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb index db0e402a..15acb91d 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb @@ -13,7 +13,7 @@ let(:source) { 'puts "hi"' } it 'no types should be in the registry' do - expect(spec_subject.empty?).to eq(true) + expect(spec_subject.empty?).to be(true) end end @@ -163,52 +163,52 @@ expect(object.properties.size).to eq(4) expect(object.properties[0].name).to eq('dynamic_prop') expect(object.properties[0].docstring).to eq('Documentation for a dynamic property.') - expect(object.properties[0].isnamevar).to eq(false) + expect(object.properties[0].isnamevar).to be(false) expect(object.properties[0].values).to eq(['foo', 'bar']) expect(object.properties[1].name).to eq('ensure') expect(object.properties[1].docstring).to eq('What state the database should be in.') - expect(object.properties[1].isnamevar).to eq(false) + expect(object.properties[1].isnamevar).to be(false) expect(object.properties[1].default).to eq('up') expect(object.properties[1].values).to eq(['present', 'absent', 'up', 'down']) expect(object.properties[1].aliases).to eq({ 'down' => 'absent', 'up' => 'present' }) expect(object.properties[2].name).to eq('file') expect(object.properties[2].docstring).to eq('The database file to use.') - expect(object.properties[2].isnamevar).to eq(false) + expect(object.properties[2].isnamevar).to be(false) expect(object.properties[2].default).to be_nil expect(object.properties[2].values).to eq([]) expect(object.properties[2].aliases).to eq({}) expect(object.properties[3].name).to eq('log_level') expect(object.properties[3].docstring).to eq('The log level to use.') - expect(object.properties[3].isnamevar).to eq(false) + expect(object.properties[3].isnamevar).to be(false) expect(object.properties[3].default).to eq('warn') expect(object.properties[3].values).to eq(['debug', 'warn', 'error']) expect(object.properties[3].aliases).to eq({}) expect(object.parameters.size).to eq(5) expect(object.parameters[0].name).to eq('dynamic_param') expect(object.parameters[0].docstring).to eq('Documentation for a dynamic parameter.') - expect(object.parameters[0].isnamevar).to eq(false) + expect(object.parameters[0].isnamevar).to be(false) expect(object.parameters[0].values).to eq(['value1', 'value2']) expect(object.parameters[1].name).to eq('address') expect(object.parameters[1].docstring).to eq('The database server name.') - expect(object.parameters[1].isnamevar).to eq(true) + expect(object.parameters[1].isnamevar).to be(true) expect(object.parameters[1].default).to be_nil expect(object.parameters[1].values).to eq([]) expect(object.parameters[1].aliases).to eq({}) expect(object.parameters[2].name).to eq('encryption_key') expect(object.parameters[2].docstring).to eq('The encryption key to use.') - expect(object.parameters[2].isnamevar).to eq(false) + expect(object.parameters[2].isnamevar).to be(false) expect(object.parameters[2].default).to be_nil expect(object.parameters[2].values).to eq([]) expect(object.parameters[2].aliases).to eq({}) expect(object.parameters[3].name).to eq('encrypt') expect(object.parameters[3].docstring).to eq('Whether or not to encrypt the database.') - expect(object.parameters[3].isnamevar).to eq(false) + expect(object.parameters[3].isnamevar).to be(false) expect(object.parameters[3].default).to eq('false') expect(object.parameters[3].values).to eq(['true', 'false', 'yes', 'no']) expect(object.parameters[3].aliases).to eq({}) expect(object.parameters[4].name).to eq('backup') expect(object.parameters[4].docstring).to eq('How often to backup the database.') - expect(object.parameters[4].isnamevar).to eq(false) + expect(object.parameters[4].isnamevar).to be(false) expect(object.parameters[4].default).to eq('never') expect(object.parameters[4].values).to eq(['daily', 'monthly', 'never']) expect(object.features.size).to eq(2) @@ -267,7 +267,7 @@ object = spec_subject.first expect(object.parameters.size).to eq(1) expect(object.parameters[0].name).to eq('name') - expect(object.parameters[0].isnamevar).to eq(true) + expect(object.parameters[0].isnamevar).to be(true) end end From 5ff9836c45f6de00ff191bd5be9592ac8cab2932 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 12:43:52 +0100 Subject: [PATCH 19/60] (CONT-812) Correct RSpec/EmptyLineAfterExampleGroup --- spec/unit/puppet-strings/describe_spec.rb | 1 + spec/unit/puppet-strings/markdown/base_spec.rb | 3 +++ .../puppet-strings/yard/parsers/json/task_statement_spec.rb | 2 ++ 3 files changed, 6 insertions(+) diff --git a/spec/unit/puppet-strings/describe_spec.rb b/spec/unit/puppet-strings/describe_spec.rb index d4543b0b..ba3f843e 100644 --- a/spec/unit/puppet-strings/describe_spec.rb +++ b/spec/unit/puppet-strings/describe_spec.rb @@ -105,6 +105,7 @@ DATA expect { described_class.render(nil, true) }.to output(output).to_stdout end + it 'outputs the expected describe content for a type' do output = <<~'DATA' diff --git a/spec/unit/puppet-strings/markdown/base_spec.rb b/spec/unit/puppet-strings/markdown/base_spec.rb index 250858c7..48351227 100644 --- a/spec/unit/puppet-strings/markdown/base_spec.rb +++ b/spec/unit/puppet-strings/markdown/base_spec.rb @@ -69,11 +69,13 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { it 'returns a hash' do expect(toc).to be_instance_of Hash end + it 'prefers the summary for :desc' do expect(toc[:desc]).to eq 'A simple class.' end end end + context 'less basic class' do before :each do YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet) @@ -142,6 +144,7 @@ class klass::yeah( it 'returns a hash' do expect(toc).to be_instance_of Hash end + it 'uses overview for :desc in absence of summary' do expect(toc[:desc]).to eq 'An overview It\'s a longer overview Ya know?' end diff --git a/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb b/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb index 54d59231..5be37e3f 100644 --- a/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb @@ -36,12 +36,14 @@ expect(spec_subject.comments).to eq 'Allows you to backup your database to local file.' end end + describe '#parameters' do context 'with params' do it 'returns params' do expect(!spec_subject.parameters.empty?).to be true end end + context 'no params' do let(:source) { <<~'SOURCE' } { From 2b122ee404c4462c1dd4441ee85fc3f2b4c02528 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 13:12:41 +0100 Subject: [PATCH 20/60] (CONT-812) Correct RSpec/HookArgument --- spec/spec_helper.rb | 2 +- spec/unit/puppet-strings/describe_spec.rb | 2 +- spec/unit/puppet-strings/json_spec.rb | 2 +- spec/unit/puppet-strings/markdown/base_spec.rb | 4 ++-- spec/unit/puppet-strings/markdown_spec.rb | 6 +++--- .../yard/handlers/ruby/data_type_handler_spec.rb | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9fce165c..fe5cdb76 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -46,7 +46,7 @@ RSpec.configure do |config| config.mock_with :mocha - config.before(:each) do + config.before do # Always clear the YARD registry before each example YARD::Registry.clear end diff --git a/spec/unit/puppet-strings/describe_spec.rb b/spec/unit/puppet-strings/describe_spec.rb index ba3f843e..66106569 100644 --- a/spec/unit/puppet-strings/describe_spec.rb +++ b/spec/unit/puppet-strings/describe_spec.rb @@ -12,7 +12,7 @@ #--short - only list params describe PuppetStrings::Describe do - before :each do + before do # Populate the YARD registry with both Puppet and Ruby source YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :ruby) diff --git a/spec/unit/puppet-strings/json_spec.rb b/spec/unit/puppet-strings/json_spec.rb index 4c3ec4b8..22d77742 100644 --- a/spec/unit/puppet-strings/json_spec.rb +++ b/spec/unit/puppet-strings/json_spec.rb @@ -5,7 +5,7 @@ require 'tempfile' describe PuppetStrings::Json do - before :each do + before do # Populate the YARD registry with both Puppet and Ruby source expect(YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet).enumerator.length).to eq(2) # A simple class. diff --git a/spec/unit/puppet-strings/markdown/base_spec.rb b/spec/unit/puppet-strings/markdown/base_spec.rb index 48351227..27850f1a 100644 --- a/spec/unit/puppet-strings/markdown/base_spec.rb +++ b/spec/unit/puppet-strings/markdown/base_spec.rb @@ -4,7 +4,7 @@ describe PuppetStrings::Markdown::Base do context 'basic class' do - before :each do + before do YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet) # An overview # @api private @@ -77,7 +77,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end context 'less basic class' do - before :each do + before do YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet) # An overview # It's a longer overview diff --git a/spec/unit/puppet-strings/markdown_spec.rb b/spec/unit/puppet-strings/markdown_spec.rb index bfb5ae89..bd4154a6 100644 --- a/spec/unit/puppet-strings/markdown_spec.rb +++ b/spec/unit/puppet-strings/markdown_spec.rb @@ -49,7 +49,7 @@ def parse_data_type_content end end - before(:each) do + before do parse_shared_content end @@ -98,7 +98,7 @@ def parse_data_type_content end describe 'with Puppet Plans', if: TEST_PUPPET_PLANS do - before(:each) do + before do parse_plan_content end @@ -112,7 +112,7 @@ def parse_data_type_content end describe 'with Puppet Data Types', if: TEST_PUPPET_DATATYPES do - before(:each) do + before do parse_data_type_content end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb index 0f62c365..6e044493 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb @@ -13,7 +13,7 @@ # so remember the logging object prior to running the test. original_yard_logging_object = YARD::Logger.instance.io - after(:each) do + after do # Restore the original logging IO object YARD::Logger.instance.io = original_yard_logging_object end From 73787ec38aebc2541afd5fa31be11e97246c0f50 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 13:13:33 +0100 Subject: [PATCH 21/60] (CONT-812) Correct RSpec/PredicateMatcher --- .../yard/handlers/ruby/function_handler_spec.rb | 14 +++++++------- .../yard/parsers/json/parser_spec.rb | 2 +- .../yard/parsers/puppet/parser_spec.rb | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb index 10ae2d70..f6830413 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb @@ -258,7 +258,7 @@ def foo(param1, param2, param3 = nil) expect(object.signature).to eq('foo(Integer $param1, Any $param2, Optional[Array[String]] $param3)') expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', nil]]) expect(object.docstring).to eq('An example 4.x function.') - expect(object.docstring.tags(:overload).empty?).to be_truthy + expect(object.docstring.tags(:overload)).to be_empty expect(object.docstring.tags.size).to eq(5) tags = object.docstring.tags(:param) expect(tags.size).to eq(3) @@ -341,7 +341,7 @@ def foo(param1, param2, param3 = nil) expect(object.signature).to eq('foo(String $param1, Integer $param2, Optional[Array] $param3, String *$param4)') expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', nil], ['*param4', nil]]) expect(object.docstring).to eq('An example 4.x function.') - expect(object.docstring.tags(:overload).empty?).to be_truthy + expect(object.docstring.tags(:overload)).to be_empty expect(object.docstring.tags.size).to eq(6) tags = object.docstring.tags(:param) expect(tags.size).to eq(4) @@ -389,7 +389,7 @@ def foo(param1, param2, param3 = nil) expect(object.signature).to eq('foo(Optional[String] *$param)') expect(object.parameters).to eq([['*param', nil]]) expect(object.docstring).to eq('An example 4.x function.') - expect(object.docstring.tags(:overload).empty?).to be_truthy + expect(object.docstring.tags(:overload)).to be_empty expect(object.docstring.tags.size).to eq(3) tags = object.docstring.tags(:param) expect(tags.size).to eq(1) @@ -428,7 +428,7 @@ def foo(param1, param2, param3 = nil) expect(object.signature).to eq('foo(Callable &$a_block)') expect(object.parameters).to eq([['&a_block', nil]]) expect(object.docstring).to eq('An example 4.x function.') - expect(object.docstring.tags(:overload).empty?).to be_truthy + expect(object.docstring.tags(:overload)).to be_empty expect(object.docstring.tags.size).to eq(3) tags = object.docstring.tags(:param) expect(tags.size).to eq(1) @@ -467,7 +467,7 @@ def foo(param1, param2, param3 = nil) expect(object.signature).to eq('foo(Optional[Callable[String]] &$a_block)') expect(object.parameters).to eq([['&a_block', nil]]) expect(object.docstring).to eq('An example 4.x function.') - expect(object.docstring.tags(:overload).empty?).to be_truthy + expect(object.docstring.tags(:overload)).to be_empty expect(object.docstring.tags.size).to eq(3) tags = object.docstring.tags(:param) expect(tags.size).to eq(1) @@ -528,8 +528,8 @@ def other(b) expect(object.signature).to eq('') expect(object.parameters).to eq([]) expect(object.docstring).to eq('An example 4.x function.') - expect(object.docstring.tags(:param).empty?).to be_truthy - expect(object.docstring.tags(:return).empty?).to be_truthy + expect(object.docstring.tags(:param)).to be_empty + expect(object.docstring.tags(:return)).to be_empty expect(object.docstring.tags.size).to eq(3) overloads = object.docstring.tags(:overload) expect(overloads.size).to eq(2) diff --git a/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb b/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb index 264eab6d..94b40834 100644 --- a/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb @@ -22,7 +22,7 @@ it 'has no relevant statements' do spec_subject.parse - expect(spec_subject.enumerator.empty?).to be_truthy + expect(spec_subject.enumerator).to be_empty end end diff --git a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb index 108b767b..6b5b1e78 100644 --- a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb @@ -21,7 +21,7 @@ it 'has no relevant statements' do spec_subject.parse - expect(spec_subject.enumerator.empty?).to be_truthy + expect(spec_subject.enumerator).to be_empty end end From c3c05b6fdd132ca7546aeaf7149f614bdc77e542 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 13:15:10 +0100 Subject: [PATCH 22/60] (CONT-812) Correct Style/AccessorGrouping --- lib/puppet-strings/markdown/data_type.rb | 3 +-- lib/puppet-strings/yard/code_objects/class.rb | 3 +-- .../yard/code_objects/defined_type.rb | 3 +-- lib/puppet-strings/yard/code_objects/plan.rb | 3 +-- .../yard/parsers/puppet/statement.rb | 19 +++++-------------- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/lib/puppet-strings/markdown/data_type.rb b/lib/puppet-strings/markdown/data_type.rb index 3f2040ab..46ccab01 100644 --- a/lib/puppet-strings/markdown/data_type.rb +++ b/lib/puppet-strings/markdown/data_type.rb @@ -5,8 +5,7 @@ module PuppetStrings::Markdown # This class encapsualtes ruby data types and puppet type aliases class DataType < Base - attr_reader :alias_of - attr_reader :functions + attr_reader :alias_of, :functions group_name 'Data types' yard_types [:puppet_data_type, :puppet_data_type_alias] diff --git a/lib/puppet-strings/yard/code_objects/class.rb b/lib/puppet-strings/yard/code_objects/class.rb index 5346d6bd..692e8db9 100644 --- a/lib/puppet-strings/yard/code_objects/class.rb +++ b/lib/puppet-strings/yard/code_objects/class.rb @@ -20,8 +20,7 @@ def name(_prefix = false) # Implements the Puppet class code object. class PuppetStrings::Yard::CodeObjects::Class < PuppetStrings::Yard::CodeObjects::Base - attr_reader :statement - attr_reader :parameters + attr_reader :statement, :parameters # Initializes a Puppet class code object. # @param [PuppetStrings::Parsers::ClassStatement] statement The class statement that was parsed. diff --git a/lib/puppet-strings/yard/code_objects/defined_type.rb b/lib/puppet-strings/yard/code_objects/defined_type.rb index 2e5cb1c0..00c067ce 100644 --- a/lib/puppet-strings/yard/code_objects/defined_type.rb +++ b/lib/puppet-strings/yard/code_objects/defined_type.rb @@ -20,8 +20,7 @@ def name(_prefix = false) # Implements the Puppet defined type code object. class PuppetStrings::Yard::CodeObjects::DefinedType < PuppetStrings::Yard::CodeObjects::Base - attr_reader :statement - attr_reader :parameters + attr_reader :statement, :parameters # Initializes a Puppet defined type code object. # @param [PuppetStrings::Parsers::DefinedTypeStatement] statement The defined type statement that was parsed. diff --git a/lib/puppet-strings/yard/code_objects/plan.rb b/lib/puppet-strings/yard/code_objects/plan.rb index 6bec1fb3..5cc01a86 100644 --- a/lib/puppet-strings/yard/code_objects/plan.rb +++ b/lib/puppet-strings/yard/code_objects/plan.rb @@ -20,8 +20,7 @@ def name(_prefix = false) # Implements the Puppet plan code object. class PuppetStrings::Yard::CodeObjects::Plan < PuppetStrings::Yard::CodeObjects::Base - attr_reader :statement - attr_reader :parameters + attr_reader :statement, :parameters # Initializes a Puppet plan code object. # @param [PuppetStrings::Parsers::PlanStatement] statement The plan statement that was parsed. diff --git a/lib/puppet-strings/yard/parsers/puppet/statement.rb b/lib/puppet-strings/yard/parsers/puppet/statement.rb index 3a414f20..a718897b 100644 --- a/lib/puppet-strings/yard/parsers/puppet/statement.rb +++ b/lib/puppet-strings/yard/parsers/puppet/statement.rb @@ -9,11 +9,7 @@ class Statement # The pattern for parsing docstring comments. COMMENT_REGEX = %r{^\s*#+\s?}.freeze - attr_reader :source - attr_reader :file - attr_reader :line - attr_reader :docstring - attr_reader :comments_range + attr_reader :source, :file, :line, :docstring, :comments_range # Initializes the Puppet language statement. # @param object The Puppet parser model object for the statement. @@ -75,9 +71,7 @@ def first_line class ParameterizedStatement < Statement # Implements a parameter for a parameterized statement. class Parameter - attr_reader :name - attr_reader :type - attr_reader :value + attr_reader :name, :type, :value # Initializes the parameter. # @param [Puppet::Pops::Model::Parameter] parameter The parameter model object. @@ -107,8 +101,7 @@ def initialize(object, file) # Implements the Puppet class statement. class ClassStatement < ParameterizedStatement - attr_reader :name - attr_reader :parent_class + attr_reader :name, :parent_class # Initializes the Puppet class statement. # @param [Puppet::Pops::Model::HostClassDefinition] object The model object for the class statement. @@ -135,8 +128,7 @@ def initialize(object, file) # Implements the Puppet function statement. class FunctionStatement < ParameterizedStatement - attr_reader :name - attr_reader :type + attr_reader :name, :type # Initializes the Puppet function statement. # @param [Puppet::Pops::Model::FunctionDefinition] object The model object for the function statement. @@ -168,8 +160,7 @@ def initialize(object, file) # Implements the Puppet data type alias statement. class DataTypeAliasStatement < Statement - attr_reader :name - attr_reader :alias_of + attr_reader :name, :alias_of # Initializes the Puppet data type alias statement. # @param [Puppet::Pops::Model::TypeAlias] object The model object for the type statement. From 0af14197449d78ebad5170266aa3628fd0d78089 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 13:16:26 +0100 Subject: [PATCH 23/60] (CONT-812) Correct Style/BlockDelimiters --- lib/puppet-strings/yard/code_objects/function.rb | 4 ++-- lib/puppet-strings/yard/tags/overload_tag.rb | 4 ++-- .../yard/templates/default/puppet_class/html/setup.rb | 4 ++-- .../yard/handlers/ruby/data_type_handler_spec.rb | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/puppet-strings/yard/code_objects/function.rb b/lib/puppet-strings/yard/code_objects/function.rb index 59a79380..8b13d93c 100644 --- a/lib/puppet-strings/yard/code_objects/function.rb +++ b/lib/puppet-strings/yard/code_objects/function.rb @@ -65,7 +65,7 @@ def signature return '' if has_tag? :overload tags = self.tags(:param) - args = @parameters.map { |parameter| + args = @parameters.map do |parameter| name, default = parameter tag = tags.find { |t| t.name == name } if tags type = tag&.types ? "#{tag.type} " : 'Any ' @@ -73,7 +73,7 @@ def signature name = name[1..-1] if prefix default = " = #{default}" if default "#{type}#{prefix}$#{name}#{default}" - }.join(', ') + end.join(', ') @name.to_s + '(' + args + ')' end diff --git a/lib/puppet-strings/yard/tags/overload_tag.rb b/lib/puppet-strings/yard/tags/overload_tag.rb index e474dbc0..7826118a 100644 --- a/lib/puppet-strings/yard/tags/overload_tag.rb +++ b/lib/puppet-strings/yard/tags/overload_tag.rb @@ -21,7 +21,7 @@ def initialize(name, docstring) # @return [String] Returns the signature of the overload. def signature tags = self.tags(:param) - args = @parameters.map { |parameter| + args = @parameters.map do |parameter| name, default = parameter tag = tags.find { |t| t.name == name } if tags type = tag&.types ? "#{tag.type} " : 'Any ' @@ -29,7 +29,7 @@ def signature name = name[1..-1] if prefix default = " = #{default}" if default "#{type}#{prefix}$#{name}#{default}" - }.join(', ') + end.join(', ') @name + '(' + args + ')' end diff --git a/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb index bc98a85c..dcbd87e0 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb @@ -7,8 +7,8 @@ def init # Renders the box_info section. # @return [String] Returns the rendered section. def box_info - @subclasses = Registry.all(:puppet_class).find_all { |c| + @subclasses = Registry.all(:puppet_class).find_all do |c| c.statement.parent_class == object.name.to_s - } + end erb(:box_info) end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb index 6e044493..31d5ce93 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb @@ -424,15 +424,15 @@ def suppress_yard_logging end it 'outputs a warning about the wrong parameter type (func1)' do - expect { + expect do spec_subject - }.to output(%r{\[warn\]: The @param tag for 'foo1' for function 'func1' has a different type definition than the actual function near .+ Expected \["Integer"\]}m).to_stdout_from_any_process + end.to output(%r{\[warn\]: The @param tag for 'foo1' for function 'func1' has a different type definition than the actual function near .+ Expected \["Integer"\]}m).to_stdout_from_any_process end it 'outputs a warning about the wrong parameter type (func2)' do - expect { + expect do spec_subject - }.to output(%r{\[warn\]: The @param tag for 'param1' for function 'func2' has a different type definition than the actual function near .+ Expected \["Integer"\]}m).to_stdout_from_any_process + end.to output(%r{\[warn\]: The @param tag for 'param1' for function 'func2' has a different type definition than the actual function near .+ Expected \["Integer"\]}m).to_stdout_from_any_process end it 'automatically fixes function parameters, except for differring types' do From b8bcb5fa63fed750d13b91dfb97435443ecbb895 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 13:45:19 +0100 Subject: [PATCH 24/60] (CONT-812) Correct Style/CaseLikeIf --- lib/puppet-strings/yard/handlers/ruby/type_handler.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/puppet-strings/yard/handlers/ruby/type_handler.rb b/lib/puppet-strings/yard/handlers/ruby/type_handler.rb index a5eeba5c..7b84c45b 100644 --- a/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/type_handler.rb @@ -52,7 +52,8 @@ def populate_type_data(object) method_name = node.method_name.source parameters = node.parameters(false) - if method_name == 'newproperty' + case method_name + when 'newproperty' # Add a property to the object next unless parameters.count >= 1 @@ -60,7 +61,7 @@ def populate_type_data(object) next unless name object.add_property(create_property(name, node)) - elsif method_name == 'newparam' + when 'newparam' # Add a parameter to the object next unless parameters.count >= 1 @@ -68,7 +69,7 @@ def populate_type_data(object) next unless name object.add_parameter(create_parameter(name, node)) - elsif method_name == 'newcheck' + when 'newcheck' # Add a check to the object next unless parameters.count >= 1 @@ -76,7 +77,7 @@ def populate_type_data(object) next unless name object.add_check(create_check(name, node)) - elsif method_name == 'feature' + when 'feature' # Add a feature to the object next unless parameters.count >= 2 @@ -87,7 +88,7 @@ def populate_type_data(object) next unless docstring object.add_feature(PuppetStrings::Yard::CodeObjects::Type::Feature.new(name, docstring)) - elsif method_name == 'ensurable' + when 'ensurable' if node.block property = create_property('ensure', node) property.docstring = DEFAULT_ENSURABLE_DOCSTRING if property.docstring.empty? From e8d9d0c8b81d953838f0d017fcec0c7c727c6bc7 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:04:22 +0100 Subject: [PATCH 25/60] (CONT-812) Correct Style/ClassEqualityComparison --- lib/puppet-strings/yard/code_objects/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/yard/code_objects/base.rb b/lib/puppet-strings/yard/code_objects/base.rb index ba58b89d..2f6c19db 100644 --- a/lib/puppet-strings/yard/code_objects/base.rb +++ b/lib/puppet-strings/yard/code_objects/base.rb @@ -9,7 +9,7 @@ def self.new(*args) # Skip the super class' implementation because it detects :: in names and this will cause namespaces in the output we don't want object = Object.class.instance_method(:new).bind_call(self, *args) existing = YARD::Registry.at(object.path) - object = existing if existing && existing.class == self + object = existing if existing.instance_of?(self) yield(object) if block_given? object end From 7847a3e912ef81200b1a6b0dc70442e191c16c7c Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:05:06 +0100 Subject: [PATCH 26/60] (CONT-812) Correct Style/ExpandPathArguments --- puppet-strings.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/puppet-strings.gemspec b/puppet-strings.gemspec index 2bfbb1d6..049ffa54 100644 --- a/puppet-strings.gemspec +++ b/puppet-strings.gemspec @@ -1,6 +1,6 @@ # frozen_string_literal: true -lib = File.expand_path('../lib', __FILE__) +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'puppet-strings/version' From bea4f2f46b3c86e91356387c9cfbdeeab1dac293 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:06:04 +0100 Subject: [PATCH 27/60] (CONT-812) Correct Style/FileWrite --- lib/puppet-strings/markdown.rb | 2 +- lib/puppet-strings/tasks/gh_pages.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet-strings/markdown.rb b/lib/puppet-strings/markdown.rb index 4d9763ef..5609ac34 100644 --- a/lib/puppet-strings/markdown.rb +++ b/lib/puppet-strings/markdown.rb @@ -66,7 +66,7 @@ def self.render(path = nil) puts generate exit else - File.open(path, 'w') { |file| file.write(generate) } + File.write(path, generate) YARD::Logger.instance.debug "Wrote markdown to #{path}" end end diff --git a/lib/puppet-strings/tasks/gh_pages.rb b/lib/puppet-strings/tasks/gh_pages.rb index 576d5da4..d48bdaa7 100644 --- a/lib/puppet-strings/tasks/gh_pages.rb +++ b/lib/puppet-strings/tasks/gh_pages.rb @@ -30,7 +30,7 @@ task :configure do unless File.exist?(File.join('doc', '_config.yml')) Dir.chdir('doc') do - File.open('_config.yml', 'w+') { |f| f.write('include: _index.html') } + File.write('_config.yml', 'include: _index.html') end end end From 4971557b3b264627991b1665ed932428e601dea8 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:06:40 +0100 Subject: [PATCH 28/60] (CONT-812) Correct Style/FormatString --- lib/puppet-strings/describe.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/puppet-strings/describe.rb b/lib/puppet-strings/describe.rb index 2583008d..70d9f832 100644 --- a/lib/puppet-strings/describe.rb +++ b/lib/puppet-strings/describe.rb @@ -32,7 +32,7 @@ def self.render(describe_types = [], list = false, _providers = false) end def self.show_one_type(resource_type) - puts "\n%{name}\n%{underscore}" % { name: resource_type[:name], underscore: '=' * resource_type[:name].length } + puts format("\n%{name}\n%{underscore}", name: resource_type[:name], underscore: '=' * resource_type[:name].length) puts resource_type[:docstring][:text] combined_list = (resource_type[:parameters].nil? ? [] : resource_type[:parameters]) + @@ -47,10 +47,10 @@ def self.show_one_type(resource_type) end def self.show_one_parameter(parameter) - puts "\n- **%{name}**\n" % { name: parameter[:name] } + puts format("\n- **%{name}**\n", name: parameter[:name]) puts parameter[:description] - puts 'Valid values are `%{values}`.' % { values: parameter[:values].join('`, `') } unless parameter[:values].nil? - puts 'Requires features %{required_features}.' % { required_features: parameter[:required_features] } unless parameter[:required_features].nil? + puts format('Valid values are `%{values}`.', values: parameter[:values].join('`, `')) unless parameter[:values].nil? + puts format('Requires features %{required_features}.', required_features: parameter[:required_features]) unless parameter[:required_features].nil? end def self.list_one_type(type) From 3c1610e5360f24fc4eccd8646a6d3b243b672d63 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:07:28 +0100 Subject: [PATCH 29/60] (CONT-812) Correct Style/FormatStringToken --- lib/puppet-strings/describe.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/puppet-strings/describe.rb b/lib/puppet-strings/describe.rb index 70d9f832..97ae7c3f 100644 --- a/lib/puppet-strings/describe.rb +++ b/lib/puppet-strings/describe.rb @@ -32,7 +32,7 @@ def self.render(describe_types = [], list = false, _providers = false) end def self.show_one_type(resource_type) - puts format("\n%{name}\n%{underscore}", name: resource_type[:name], underscore: '=' * resource_type[:name].length) + puts format("\n%s\n%s", name: resource_type[:name], underscore: '=' * resource_type[:name].length) puts resource_type[:docstring][:text] combined_list = (resource_type[:parameters].nil? ? [] : resource_type[:parameters]) + @@ -47,10 +47,10 @@ def self.show_one_type(resource_type) end def self.show_one_parameter(parameter) - puts format("\n- **%{name}**\n", name: parameter[:name]) + puts format("\n- **%s**\n", name: parameter[:name]) puts parameter[:description] - puts format('Valid values are `%{values}`.', values: parameter[:values].join('`, `')) unless parameter[:values].nil? - puts format('Requires features %{required_features}.', required_features: parameter[:required_features]) unless parameter[:required_features].nil? + puts format('Valid values are `%s`.', values: parameter[:values].join('`, `')) unless parameter[:values].nil? + puts format('Requires features %s.', required_features: parameter[:required_features]) unless parameter[:required_features].nil? end def self.list_one_type(type) From 13baac0a776ab8d7d8a199323b3bb2ffbd7d0895 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:13:33 +0100 Subject: [PATCH 30/60] (CONT-812) Correct Style/FrozenStringLiteralComment --- lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb | 2 ++ lib/puppet-strings/yard/templates/default/layout/html/setup.rb | 2 ++ .../yard/templates/default/puppet_class/html/setup.rb | 2 ++ .../yard/templates/default/puppet_data_type/html/setup.rb | 2 ++ .../yard/templates/default/puppet_data_type_alias/html/setup.rb | 2 ++ .../yard/templates/default/puppet_defined_type/html/setup.rb | 2 ++ .../yard/templates/default/puppet_function/html/setup.rb | 2 ++ .../yard/templates/default/puppet_plan/html/setup.rb | 2 ++ .../yard/templates/default/puppet_provider/html/setup.rb | 2 ++ .../yard/templates/default/puppet_task/html/setup.rb | 2 ++ .../yard/templates/default/puppet_type/html/setup.rb | 2 ++ lib/puppet-strings/yard/templates/default/tags/setup.rb | 2 ++ 12 files changed, 24 insertions(+) diff --git a/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb b/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb index 967615a0..611d9a31 100644 --- a/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Generates the searchable Puppet class list. # @return [void] def generate_puppet_class_list diff --git a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb index e1a12d62..b75887e0 100644 --- a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb index dcbd87e0..be711d56 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb index 3364c620..08a48693 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb index 890e7efc..ae0cf43c 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb index 345336a4..7798bbad 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb index e99b57e9..ccaad68b 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb index c0bb74d0..79f4ba94 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb index 0ad6dce9..894fec0e 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb index 27820f88..972e29ad 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb index 759bdf92..d3b067e9 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Initializes the template. # @return [void] def init diff --git a/lib/puppet-strings/yard/templates/default/tags/setup.rb b/lib/puppet-strings/yard/templates/default/tags/setup.rb index b47b0772..695666cb 100644 --- a/lib/puppet-strings/yard/templates/default/tags/setup.rb +++ b/lib/puppet-strings/yard/templates/default/tags/setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Called to return parameter tags. # @return [Array] Returns the parameter tags if the object should have parameters. def param From ddaf409fa91941879a34ca5431e5806fd051296b Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:14:10 +0100 Subject: [PATCH 31/60] (CONT-812) Correct Style/GlobalStdStream --- lib/puppet-strings/tasks/validate.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet-strings/tasks/validate.rb b/lib/puppet-strings/tasks/validate.rb index 7b475061..53344442 100644 --- a/lib/puppet-strings/tasks/validate.rb +++ b/lib/puppet-strings/tasks/validate.rb @@ -10,7 +10,7 @@ filename = 'REFERENCE.md' unless File.exist?(filename) - STDERR.puts "#{filename} does not exist" + $stderr.puts "#{filename} does not exist" exit 1 end @@ -34,7 +34,7 @@ existing = File.read(filename) if generated != existing - STDERR.puts "#{filename} is outdated" + $stderr.puts "#{filename} is outdated" exit 1 end end From fdb4b3fbdd171426265ad44b8b742abc8a5e5b73 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:14:53 +0100 Subject: [PATCH 32/60] (CONT-812) Correct Style/HashConversion --- lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb index c9c36f52..d855a0ac 100644 --- a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb @@ -101,7 +101,7 @@ def hash_from_node(node) kv_pairs = node.children.map do |assoc| [value_from_node(assoc.children[0]), value_from_node(assoc.children[1])] end - Hash[kv_pairs] + kv_pairs.to_h end def var_ref_from_node(node) From 7ed93834ea376d6a2a7e43dc0efa19a73c0ecf66 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:17:28 +0100 Subject: [PATCH 33/60] (CONT-812) Correct Style/IfUnlessModifier --- lib/puppet-strings.rb | 8 ++------ lib/puppet-strings/describe.rb | 8 ++------ .../yard/handlers/ruby/data_type_handler.rb | 4 +--- lib/puppet-strings/yard/parsers/puppet/statement.rb | 4 +--- .../yard/templates/default/layout/html/setup.rb | 4 +--- lib/puppet-strings/yard/util.rb | 4 +--- 6 files changed, 8 insertions(+), 24 deletions(-) diff --git a/lib/puppet-strings.rb b/lib/puppet-strings.rb index 02193729..d96a7cdd 100644 --- a/lib/puppet-strings.rb +++ b/lib/puppet-strings.rb @@ -50,14 +50,10 @@ def self.generate(search_patterns = DEFAULT_SEARCH_PATTERNS, options = {}) YARD::CLI::Yardoc.run(*args) # If outputting JSON, render the output - if options[:json] && !options[:describe] - render_json(file) - end + render_json(file) if options[:json] && !options[:describe] # If outputting Markdown, render the output - if options[:markdown] - render_markdown(file) - end + render_markdown(file) if options[:markdown] return unless options[:describe] diff --git a/lib/puppet-strings/describe.rb b/lib/puppet-strings/describe.rb index 97ae7c3f..99e25cb3 100644 --- a/lib/puppet-strings/describe.rb +++ b/lib/puppet-strings/describe.rb @@ -58,12 +58,8 @@ def self.list_one_type(type) shortento = targetlength - 4 contentstring = type[:docstring][:text] end_of_line = contentstring.index("\n") # "." gives closer results to old describeb, but breaks for '.k5login' - unless end_of_line.nil? - contentstring = contentstring[0..end_of_line] - end - if contentstring.length > targetlength - contentstring = contentstring[0..shortento] + ' ...' - end + contentstring = contentstring[0..end_of_line] unless end_of_line.nil? + contentstring = contentstring[0..shortento] + ' ...' if contentstring.length > targetlength puts "#{type[:name].to_s.ljust(15)} - #{contentstring}" end diff --git a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb index 14246e7d..a826bc92 100644 --- a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb @@ -360,9 +360,7 @@ def validate_methods!(object, actual_functions_hash) # Puppet Data Type function invocation. So instead we derive a signature from the method definition. object.meths.each do |meth| params = '' - unless meth.docstring.tags(:param).empty? - params += '(' + meth.docstring.tags(:param).map { |t| t.name }.join(', ') + ')' - end + params += '(' + meth.docstring.tags(:param).map { |t| t.name }.join(', ') + ')' unless meth.docstring.tags(:param).empty? meth.signature = "#{object.name}.#{meth.name}" + params end diff --git a/lib/puppet-strings/yard/parsers/puppet/statement.rb b/lib/puppet-strings/yard/parsers/puppet/statement.rb index a718897b..b12a1b13 100644 --- a/lib/puppet-strings/yard/parsers/puppet/statement.rb +++ b/lib/puppet-strings/yard/parsers/puppet/statement.rb @@ -78,9 +78,7 @@ class Parameter def initialize(parameter) @name = parameter.name # Take the exact text for the type expression - if parameter.type_expr - @type = PuppetStrings::Yard::Util.ast_to_text(parameter.type_expr) - end + @type = PuppetStrings::Yard::Util.ast_to_text(parameter.type_expr) if parameter.type_expr # Take the exact text for the default value expression return unless parameter.value diff --git a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb index b75887e0..16d0ab45 100644 --- a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb @@ -66,9 +66,7 @@ def layout final_layout = erb(:layout) - if @file && @file.name == 'README' - PuppetStrings::Yard::Util.github_to_yard_links(final_layout) - end + PuppetStrings::Yard::Util.github_to_yard_links(final_layout) if @file && @file.name == 'README' final_layout end diff --git a/lib/puppet-strings/yard/util.rb b/lib/puppet-strings/yard/util.rb index 75c13691..8cb851e0 100644 --- a/lib/puppet-strings/yard/util.rb +++ b/lib/puppet-strings/yard/util.rb @@ -10,9 +10,7 @@ module PuppetStrings::Yard::Util # @return [String] A scrubbed string. def self.scrub_string(str) match = str.match(%r{^%[Qq]{(.*)}$}m) - if match - return Puppet::Util::Docs.scrub(match[1]) - end + return Puppet::Util::Docs.scrub(match[1]) if match Puppet::Util::Docs.scrub(str) end From 23d59e298faf3e735a45ee598b3a60da21dc9150 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:18:10 +0100 Subject: [PATCH 34/60] (CONT-812) Correct Style/IfWithBooleanLiteralBranches --- lib/puppet-strings/tasks/generate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/tasks/generate.rb b/lib/puppet-strings/tasks/generate.rb index 3fd84095..c06561bf 100644 --- a/lib/puppet-strings/tasks/generate.rb +++ b/lib/puppet-strings/tasks/generate.rb @@ -30,7 +30,7 @@ def parse_format_option(args, options, format) return unless args.has_key? format - options[format] = args[format] == 'false' || args[format].empty? ? false : true + options[format] = !(args[format] == 'false' || args[format].empty?) return unless options[format] options[:path] = args[format] == 'true' ? nil : args[format] From e314ce41db5bf96ccbab34c7eb09e9be55d7b768 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:20:01 +0100 Subject: [PATCH 35/60] (CONT-812) Correct Style/MultilineIfModifier --- .../yard/templates/default/layout/html/setup.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb index 16d0ab45..c698c5f8 100644 --- a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb @@ -130,11 +130,13 @@ def create_menu_lists menu_lists.delete_if { |e| YARD::Registry.all(e[:type].intern).empty? } # We must always return at least one group, so always keep the files list - menu_lists << { - type: 'file', - title: 'Files', - search_title: 'File List' - } if menu_lists.empty? || !YARD::Registry.all(:file).empty? + if menu_lists.empty? || !YARD::Registry.all(:file).empty? + menu_lists << { + type: 'file', + title: 'Files', + search_title: 'File List' + } + end menu_lists end From 0ea6dee9b8f6b30213ba4cac5dc0faee12b5ede7 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:20:40 +0100 Subject: [PATCH 36/60] (CONT-812) Correct Style/NumericPredicate --- lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb | 4 ++-- lib/puppet-strings/yard/parsers/puppet/parser.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb index d855a0ac..afac3995 100644 --- a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb @@ -53,9 +53,9 @@ def raise_parse_error(msg, location = statement) # check that the params of the register_type call are key/value pairs. def kv_arg_list?(params) params.type == :list && - params.children.count > 0 && + params.children.count.positive? && params.children.first.type == :list && - params.children.first.children.count > 0 && + params.children.first.children.count.positive? && statement.parameters.children.first.children.first.type == :assoc end diff --git a/lib/puppet-strings/yard/parsers/puppet/parser.rb b/lib/puppet-strings/yard/parsers/puppet/parser.rb index a8c76b9e..46587cb8 100644 --- a/lib/puppet-strings/yard/parsers/puppet/parser.rb +++ b/lib/puppet-strings/yard/parsers/puppet/parser.rb @@ -24,7 +24,7 @@ def initialize(source, filename) # rubocop:disable Lint/MissingSuper # @return [void] def parse begin - if @file.to_s.match?(%r{^plans|/plans/}) && Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') < 0 + if @file.to_s.match?(%r{^plans|/plans/}) && Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0').negative? log.warn "Skipping #{@file}: Puppet Plans require Puppet 5 or greater." return end From 2e2c7599b1e3a7bcab6d848167efe274edd4d85a Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:21:19 +0100 Subject: [PATCH 37/60] (CONT-812) Correct Style/OneLineConditional --- lib/puppet-strings/yard/templates/default/tags/setup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/yard/templates/default/tags/setup.rb b/lib/puppet-strings/yard/templates/default/tags/setup.rb index 695666cb..d6af2d2f 100644 --- a/lib/puppet-strings/yard/templates/default/tags/setup.rb +++ b/lib/puppet-strings/yard/templates/default/tags/setup.rb @@ -16,7 +16,7 @@ def param # Renders the overload section. # @return [String] Returns the rendered section. def overload - erb(if object.type == :puppet_function then :puppet_overload else :overload end) + erb(object.type == :puppet_function ? :puppet_overload : :overload) end # Renders the enum section. From ca99208de4e9194e7c7d9e17f698ab24f44558ca Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:22:06 +0100 Subject: [PATCH 38/60] (CONT-812) Correct Style/RedundantArgument --- lib/puppet-strings/markdown.rb | 2 +- lib/puppet-strings/markdown/function.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet-strings/markdown.rb b/lib/puppet-strings/markdown.rb index 5609ac34..32a36f39 100644 --- a/lib/puppet-strings/markdown.rb +++ b/lib/puppet-strings/markdown.rb @@ -56,7 +56,7 @@ def self.generate end end - output.join('') + output.join end # mimicks the behavior of the json render, although path will never be nil diff --git a/lib/puppet-strings/markdown/function.rb b/lib/puppet-strings/markdown/function.rb index 62f4cd17..901acd1e 100644 --- a/lib/puppet-strings/markdown/function.rb +++ b/lib/puppet-strings/markdown/function.rb @@ -37,11 +37,11 @@ def type end def error_type(type) - "`#{type.split(' ')[0]}`" + "`#{type.split[0]}`" end def error_text(text) - text.split(' ').drop(1).join(' ').to_s + text.split.drop(1).join(' ').to_s end end From ffe00f09f5459b3dccda638346619f737e98b03e Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:22:45 +0100 Subject: [PATCH 39/60] (CONT-812) Correct Style/RedundantFileExtensionInRequire --- lib/puppet-strings/tasks.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet-strings/tasks.rb b/lib/puppet-strings/tasks.rb index 08cadf4a..fa09d8e2 100644 --- a/lib/puppet-strings/tasks.rb +++ b/lib/puppet-strings/tasks.rb @@ -8,7 +8,7 @@ module PuppetStrings end # The module for Puppet Strings rake tasks. module PuppetStrings::Tasks - require 'puppet-strings/tasks/generate.rb' - require 'puppet-strings/tasks/gh_pages.rb' - require 'puppet-strings/tasks/validate.rb' + require 'puppet-strings/tasks/generate' + require 'puppet-strings/tasks/gh_pages' + require 'puppet-strings/tasks/validate' end From ddc7f43a2fa86914978c5e157ee193247e1af9b6 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:23:30 +0100 Subject: [PATCH 40/60] (CONT-812) Correct Style/RedundantHeredocDelimiterQuotes --- spec/acceptance/generate_markdown_spec.rb | 2 +- spec/unit/puppet-strings/describe_spec.rb | 10 ++-- spec/unit/puppet-strings/json_spec.rb | 10 ++-- .../unit/puppet-strings/markdown/base_spec.rb | 4 +- spec/unit/puppet-strings/markdown_spec.rb | 26 +++++----- .../yard/code_objects/task_spec.rb | 2 +- .../yard/handlers/json/task_handler_spec.rb | 8 ++-- .../handlers/puppet/class_handler_spec.rb | 16 +++---- .../puppet/data_type_alias_handler_spec.rb | 4 +- .../puppet/defined_type_handler_spec.rb | 16 +++---- .../handlers/puppet/function_handler_spec.rb | 28 +++++------ .../handlers/ruby/data_type_handler_spec.rb | 22 ++++----- .../handlers/ruby/function_handler_spec.rb | 48 +++++++++---------- .../handlers/ruby/provider_handler_spec.rb | 14 +++--- .../yard/handlers/ruby/rsapi_handler_spec.rb | 12 ++--- .../handlers/ruby/type_extras_handler_spec.rb | 6 +-- .../yard/handlers/ruby/type_handler_spec.rb | 22 ++++----- .../yard/parsers/json/parser_spec.rb | 4 +- .../yard/parsers/json/task_statement_spec.rb | 4 +- .../yard/parsers/puppet/parser_spec.rb | 20 ++++---- spec/unit/puppet-strings/yard/util_spec.rb | 2 +- 21 files changed, 140 insertions(+), 140 deletions(-) diff --git a/spec/acceptance/generate_markdown_spec.rb b/spec/acceptance/generate_markdown_spec.rb index 925d0c92..971bf403 100644 --- a/spec/acceptance/generate_markdown_spec.rb +++ b/spec/acceptance/generate_markdown_spec.rb @@ -11,7 +11,7 @@ sut_tmp_path end - expected = <<~'EOF' + expected = <<~EOF # Reference ## Classes diff --git a/spec/unit/puppet-strings/describe_spec.rb b/spec/unit/puppet-strings/describe_spec.rb index 66106569..28a7eb7b 100644 --- a/spec/unit/puppet-strings/describe_spec.rb +++ b/spec/unit/puppet-strings/describe_spec.rb @@ -15,13 +15,13 @@ before do # Populate the YARD registry with both Puppet and Ruby source - YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :ruby) + YARD::Parser::SourceParser.parse_string(<<~SOURCE, :ruby) Puppet::Type.newtype(:database) do desc 'An example database server resource type.' end SOURCE - YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :ruby) + YARD::Parser::SourceParser.parse_string(<<~SOURCE, :ruby) Puppet::ResourceApi.register_type( name: 'apt_key', docs: <<~'EOS', @@ -42,7 +42,7 @@ ) SOURCE - YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :ruby) + YARD::Parser::SourceParser.parse_string(<<~SOURCE, :ruby) Puppet::Type.type(:file).newproperty(:content) do include Puppet::Util::Checksums include Puppet::DataSync @@ -80,7 +80,7 @@ end SOURCE - YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :ruby) + YARD::Parser::SourceParser.parse_string(<<~SOURCE, :ruby) Puppet::Type.type(:file).newproperty(:source) do include Puppet::Util::Checksums include Puppet::DataSync @@ -97,7 +97,7 @@ describe 'rendering DESCRIBE to stdout' do it 'outputs the expected describe content for the list of types' do - output = <<~'DATA' + output = <<~DATA These are the types known to puppet: apt_key - This type provides Puppet with the capabiliti ... database - An example database server resource type. diff --git a/spec/unit/puppet-strings/json_spec.rb b/spec/unit/puppet-strings/json_spec.rb index 22d77742..03431245 100644 --- a/spec/unit/puppet-strings/json_spec.rb +++ b/spec/unit/puppet-strings/json_spec.rb @@ -7,7 +7,7 @@ describe PuppetStrings::Json do before do # Populate the YARD registry with both Puppet and Ruby source - expect(YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet).enumerator.length).to eq(2) + expect(YARD::Parser::SourceParser.parse_string(<<~SOURCE, :puppet).enumerator.length).to eq(2) # A simple class. # @todo Do a thing # @deprecated No longer supported and will be removed in a future release @@ -26,7 +26,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { } SOURCE - expect(YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet).enumerator.length).to eq(1) if TEST_PUPPET_PLANS + expect(YARD::Parser::SourceParser.parse_string(<<~SOURCE, :puppet).enumerator.length).to eq(1) if TEST_PUPPET_PLANS # A simple plan. # @param param1 First param. # @param param2 Second param. @@ -36,7 +36,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { SOURCE # Only include Puppet functions for 4.1+ - expect(YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet).enumerator.length).to eq(1) if TEST_PUPPET_FUNCTIONS + expect(YARD::Parser::SourceParser.parse_string(<<~SOURCE, :puppet).enumerator.length).to eq(1) if TEST_PUPPET_FUNCTIONS # A simple function. # @param param1 First param. # @param param2 Second param. @@ -47,7 +47,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { SOURCE # Only include Puppet types for 5.0+ - expect(YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :ruby).enumerator.length).to eq(1) if TEST_PUPPET_DATATYPES + expect(YARD::Parser::SourceParser.parse_string(<<~SOURCE, :ruby).enumerator.length).to eq(1) if TEST_PUPPET_DATATYPES # Basic Puppet Data Type in Ruby # # @param msg A message parameter @@ -68,7 +68,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end SOURCE - expect(YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :json).enumerator.length).to eq(1) + expect(YARD::Parser::SourceParser.parse_string(<<~SOURCE, :json).enumerator.length).to eq(1) { "description": "Allows you to backup your database to local file.", "input_method": "stdin", diff --git a/spec/unit/puppet-strings/markdown/base_spec.rb b/spec/unit/puppet-strings/markdown/base_spec.rb index 27850f1a..0dbb1244 100644 --- a/spec/unit/puppet-strings/markdown/base_spec.rb +++ b/spec/unit/puppet-strings/markdown/base_spec.rb @@ -5,7 +5,7 @@ describe PuppetStrings::Markdown::Base do context 'basic class' do before do - YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet) + YARD::Parser::SourceParser.parse_string(<<~SOURCE, :puppet) # An overview # @api private # @summary A simple class. @@ -78,7 +78,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { context 'less basic class' do before do - YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet) + YARD::Parser::SourceParser.parse_string(<<~SOURCE, :puppet) # An overview # It's a longer overview # Ya know? diff --git a/spec/unit/puppet-strings/markdown_spec.rb b/spec/unit/puppet-strings/markdown_spec.rb index bd4154a6..61e92240 100644 --- a/spec/unit/puppet-strings/markdown_spec.rb +++ b/spec/unit/puppet-strings/markdown_spec.rb @@ -165,13 +165,13 @@ def parse_data_type_content end it 'renders only private functions correctly' do - expect(YARD::Parser::SourceParser.parse_string(<<~'PUPPET', :puppet).enumerator.length).to eq(1) + expect(YARD::Parser::SourceParser.parse_string(<<~PUPPET, :puppet).enumerator.length).to eq(1) # @return void # @api private function func_private() {} PUPPET - expect(described_class.generate).to eq(<<~'MARKDOWN') + expect(described_class.generate).to eq(<<~MARKDOWN) # Reference @@ -188,12 +188,12 @@ def parse_data_type_content end it 'renders only public functions correctly' do - expect(YARD::Parser::SourceParser.parse_string(<<~'PUPPET', :puppet).enumerator.length).to eq(1) + expect(YARD::Parser::SourceParser.parse_string(<<~PUPPET, :puppet).enumerator.length).to eq(1) # @return void function func_public() {} PUPPET - expect(described_class.generate).to eq(<<~'MARKDOWN') + expect(described_class.generate).to eq(<<~MARKDOWN) # Reference @@ -222,7 +222,7 @@ def parse_data_type_content end it 'renders both public and private functions correctly' do - expect(YARD::Parser::SourceParser.parse_string(<<~'PUPPET', :puppet).enumerator.length).to eq(2) + expect(YARD::Parser::SourceParser.parse_string(<<~PUPPET, :puppet).enumerator.length).to eq(2) # @return void function func_public() {} @@ -231,7 +231,7 @@ def parse_data_type_content function func_private() {} PUPPET - expect(described_class.generate).to eq(<<~'MARKDOWN') + expect(described_class.generate).to eq(<<~MARKDOWN) # Reference @@ -266,7 +266,7 @@ def parse_data_type_content end it 'renders single-line data types with inline code' do - expect(YARD::Parser::SourceParser.parse_string(<<~'PUPPET', :puppet).enumerator.length).to eq(1) + expect(YARD::Parser::SourceParser.parse_string(<<~PUPPET, :puppet).enumerator.length).to eq(1) # @summary it’s for testing type MyEnum = Enum[a, b] PUPPET @@ -275,7 +275,7 @@ def parse_data_type_content end it 'renders multi-line data types with inline code' do - expect(YARD::Parser::SourceParser.parse_string(<<~'PUPPET', :puppet).enumerator.length).to eq(1) + expect(YARD::Parser::SourceParser.parse_string(<<~PUPPET, :puppet).enumerator.length).to eq(1) # summary Test Type # type Test_module::Test_type = Hash[ @@ -290,7 +290,7 @@ def parse_data_type_content ] PUPPET - expect(described_class.generate).to include(<<~'MARKDOWN') + expect(described_class.generate).to include(<<~MARKDOWN) Alias of ```puppet @@ -306,7 +306,7 @@ def parse_data_type_content end it 'renders single-line default values with inline code' do - expect(YARD::Parser::SourceParser.parse_string(<<~'PUPPET', :puppet).enumerator.length).to eq(1) + expect(YARD::Parser::SourceParser.parse_string(<<~PUPPET, :puppet).enumerator.length).to eq(1) # @summary Test class myclass ( String $os = 'linux', @@ -314,7 +314,7 @@ class myclass ( } PUPPET - expect(described_class.generate).to include(<<~'MARKDOWN') + expect(described_class.generate).to include(<<~MARKDOWN) Default value: `'linux'` MARKDOWN end @@ -322,7 +322,7 @@ class myclass ( it 'renders multi-line default values with a code block' do skip('Broken by https://tickets.puppetlabs.com/browse/PUP-11632') - expect(YARD::Parser::SourceParser.parse_string(<<~'PUPPET', :puppet).enumerator.length).to eq(1) + expect(YARD::Parser::SourceParser.parse_string(<<~PUPPET, :puppet).enumerator.length).to eq(1) # @summary Test class myclass ( String $os = $facts['kernel'] ? { @@ -334,7 +334,7 @@ class myclass ( } PUPPET - expect(described_class.generate).to include(<<~'MARKDOWN') + expect(described_class.generate).to include(<<~MARKDOWN) Default value: ```puppet diff --git a/spec/unit/puppet-strings/yard/code_objects/task_spec.rb b/spec/unit/puppet-strings/yard/code_objects/task_spec.rb index f0edd015..bddc14e3 100644 --- a/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +++ b/spec/unit/puppet-strings/yard/code_objects/task_spec.rb @@ -7,7 +7,7 @@ describe PuppetStrings::Yard::CodeObjects::Task do subject(:spec_subject) { described_class.new(statement) } - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } { "description": "Allows you to backup your database to local file.", "input_method": "stdin", diff --git a/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb index 82ce29c9..6a648804 100644 --- a/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb @@ -10,7 +10,7 @@ end describe 'parsing task metadata with a syntax error' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } { "input_method": "stdin", "parameters": @@ -29,7 +29,7 @@ end describe 'parsing task metadata with a missing description' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } { "input_method": "stdin", "parameters": { @@ -59,7 +59,7 @@ end describe 'parsing task metadata with a description' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } { "description": "Allows you to backup your database to local file.", "input_method": "stdin", @@ -94,7 +94,7 @@ end describe 'parsing task metadata with a missing parameter description' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } { "description": "Allows you to backup your database to local file.", "input_method": "stdin", diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb index 7676bf59..3ac8f5f4 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb @@ -35,7 +35,7 @@ end describe 'parsing a class with a docstring' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo class. # @param param1 First param. # @param param2 Second param. @@ -75,7 +75,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end describe 'parsing a class with a missing parameter' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo class. # @param param1 First param. # @param param2 Second param. @@ -94,7 +94,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end describe 'parsing a class with a missing @param tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo class. # @param param1 First param. # @param param2 Second param. @@ -111,7 +111,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end describe 'parsing a class with a typed parameter that also has a @param tag type which matches' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo class. # @param [Integer] param1 First param. # @param param2 Second param. @@ -133,7 +133,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end describe 'parsing a class with a typed parameter that also has a @param tag type which does not match' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo class. # @param [Boolean] param1 First param. # @param param2 Second param. @@ -155,7 +155,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end describe 'parsing a class with a untyped parameter that also has a @param tag type' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo class. # @param param1 First param. # @param [Boolean] param2 Second param. @@ -178,7 +178,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { describe 'parsing a class with a summary' do context 'when the summary has fewer than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo class. # @summary A short summary. class foo() { @@ -197,7 +197,7 @@ class foo() { end context 'when the summary has more than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo class. # @summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!! class foo() { diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb index b99df55f..e0565b07 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb @@ -36,7 +36,7 @@ describe 'parsing a data type alias with a summary' do context 'when the summary has fewer than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo type. # @summary A short summary. type Testype = String[1] @@ -51,7 +51,7 @@ end context 'when the summary has more than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo type. # @summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!! type Testype = String[1] diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb index e673fa85..ea528ced 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb @@ -35,7 +35,7 @@ end describe 'parsing a defined type with a docstring' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo defined type. # @param name The type name. # @param param1 First param. @@ -83,7 +83,7 @@ end describe 'parsing a defined type with a missing parameter' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo defined type. # @param param1 First param. # @param param2 Second param. @@ -102,7 +102,7 @@ end describe 'parsing a defined type with a missing @param tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo defined type. # @param param1 First param. # @param param2 Second param. @@ -119,7 +119,7 @@ end describe 'parsing a defined type with a typed parameter that also has a @param tag type which matches' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo defined type. # @param [Integer] param1 First param. # @param param2 Second param. @@ -141,7 +141,7 @@ end describe 'parsing a defined type with a typed parameter that also has a @param tag type which does not match' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo defined type. # @param [Boolean] param1 First param. # @param param2 Second param. @@ -161,7 +161,7 @@ end describe 'parsing a defined type with a untyped parameter that also has a @param tag type' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo defined type. # @param param1 First param. # @param [Boolean] param2 Second param. @@ -184,7 +184,7 @@ describe 'parsing a defined type with a summary' do context 'when the summary has fewer than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo defined type. # @summary A short summary. # @param param1 First param. @@ -206,7 +206,7 @@ end context 'when the summary has more than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo defined type. # @summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!! # @param param1 First param. diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb index ba15223f..e4aff040 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb @@ -36,7 +36,7 @@ end describe 'parsing a function with a docstring' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @param param1 First param. # @param param2 Second param. @@ -81,7 +81,7 @@ end describe 'parsing a function with a missing parameter' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @param param1 First param. # @param param2 Second param. @@ -101,7 +101,7 @@ end describe 'parsing a function with a missing @param tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @param param1 First param. # @param param2 Second param. @@ -117,7 +117,7 @@ end describe 'parsing a function with a typed parameter that also has a @param tag type which matches' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @param [Integer] param1 First param. # @param param2 Second param. @@ -138,7 +138,7 @@ end describe 'parsing a function with a typed parameter that also has a @param tag type which does not match' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @param [Boolean] param1 First param. # @param param2 Second param. @@ -159,7 +159,7 @@ end describe 'parsing a function with a untyped parameter that also has a @param tag type' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @param param1 First param. # @param [Boolean] param2 Second param. @@ -180,7 +180,7 @@ end describe 'parsing a function with a missing @return tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @param param1 First param. # @param param2 Second param. @@ -196,7 +196,7 @@ end describe 'parsing a function with a missing @return tag and return type specified in the function definition', if: TEST_FUNCTION_RETURN_TYPE do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. function foo() >> String { notice 'hello world' @@ -217,7 +217,7 @@ end describe 'parsing a function with a non-conflicting return tag and type in function definition', if: TEST_FUNCTION_RETURN_TYPE do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function # @return [String] Hi there function foo() >> String { @@ -231,7 +231,7 @@ end describe 'parsing a function with a conflicting return tag and type in function definition', if: TEST_FUNCTION_RETURN_TYPE do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @return [Integer] this is a lie. function foo() >> Struct[{'a' => Integer[1, 10]}] { @@ -253,7 +253,7 @@ end describe 'parsing a function with return tag without type', if: TEST_FUNCTION_RETURN_TYPE do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @return This is something. function foo() >> Struct[{'a' => Integer[1, 10]}] { @@ -275,7 +275,7 @@ end describe 'parsing a function without a return tag or return type in the function definition' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. function foo() { notice 'hello world' @@ -297,7 +297,7 @@ describe 'parsing a function with a summary' do context 'when the summary has fewer than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @summary A short summary. # @return [String] foo @@ -315,7 +315,7 @@ end context 'when the summary has more than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!! function foo() { diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb index 31d5ce93..b16f773f 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb @@ -31,7 +31,7 @@ def suppress_yard_logging end describe 'parsing an empty data type definition' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::DataTypes.create_type('RubyDataType') do end SOURCE @@ -54,7 +54,7 @@ def suppress_yard_logging end describe 'parsing a data type definition with missing param tags' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example Puppet Data Type in Ruby. Puppet::DataTypes.create_type('RubyDataType') do interface <<~'PUPPET' @@ -98,7 +98,7 @@ def suppress_yard_logging describe 'parsing a data type definition with missing function' do context 'which has parameters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example Puppet Data Type in Ruby. Puppet::DataTypes.create_type('RubyDataType') do interface <<~'PUPPET' @@ -145,7 +145,7 @@ def suppress_yard_logging end context 'which has multiple functions' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example Puppet Data Type in Ruby. Puppet::DataTypes.create_type('RubyDataType') do interface <<~'PUPPET' @@ -193,7 +193,7 @@ def suppress_yard_logging end describe 'parsing a data type definition with extra tags' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example Puppet Data Type in Ruby. # @param msg A message parameter. # @param arg1 Optional String parameter. Defaults to 'param'. @@ -255,7 +255,7 @@ def suppress_yard_logging describe 'parsing a valid data type definition' do # TODO: What about testing for `type_parameters => {}` # e.g. https://github.com/puppetlabs/puppet/blob/main/lib/puppet/datatypes/error.rb - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example Puppet Data Type in Ruby. # # @param msg A message parameter5. @@ -325,7 +325,7 @@ def suppress_yard_logging end context 'with multiple interfaces' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example Puppet Data Type in Ruby. # # @param msg A message parameter5. @@ -389,7 +389,7 @@ def suppress_yard_logging end context 'with missing, partial and addition function parameters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example Puppet Data Type in Ruby. # # @!method func1(foo1, foo2) @@ -506,7 +506,7 @@ def suppress_yard_logging end describe 'parsing an invalid data type definition' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # The msg attribute is missing a comma. # # @param msg A message parameter5. @@ -557,7 +557,7 @@ def suppress_yard_logging describe 'parsing a data type with a summary' do context 'when the summary has fewer than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example Puppet Data Type in Ruby. # # @summary A short summary. @@ -577,7 +577,7 @@ def suppress_yard_logging end context 'when the summary has more than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example Puppet Data Type in Ruby. # # @summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!! diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb index f6830413..1ee28bf5 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb @@ -19,7 +19,7 @@ describe 'parsing 3.x API functions' do describe 'parsing a function with a missing docstring' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Parser::Functions.newfunction(:foo) do |*args| end SOURCE @@ -39,7 +39,7 @@ # # Given that this occurs only in old-style functions, it’s probably not # worth pursuing. - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Parser::Functions.newfunction(:foo, doc: <<~'DOC' An example 3.x function. @param [String] first The first parameter. @@ -90,7 +90,7 @@ # # Given that this occurs only in old-style functions, it’s probably not # worth pursuing. - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } module Puppet::Parser::Functions newfunction(:foo, doc: <<~'DOC' An example 3.x function. @@ -134,7 +134,7 @@ module Puppet::Parser::Functions end describe 'parsing a function with a missing @return tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Parser::Functions.newfunction(:foo, doc: <<~'DOC') do |*args| An example 3.x function. @param [String] first The first parameter. @@ -152,7 +152,7 @@ module Puppet::Parser::Functions describe 'parsing 4.x API functions' do describe 'parsing a function with a missing docstring' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Functions.create_function(:foo) do end SOURCE @@ -163,7 +163,7 @@ module Puppet::Parser::Functions end describe 'parsing a function with a simple docstring' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do end @@ -186,7 +186,7 @@ module Puppet::Parser::Functions end describe 'parsing a function without any dispatches' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param [Integer] param1 The first parameter. @@ -231,7 +231,7 @@ def foo(param1, param2, param3 = nil) end describe 'parsing a function with a single dispatch' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param param1 The first parameter. @@ -283,7 +283,7 @@ def foo(param1, param2, param3 = nil) end describe 'parsing a function using only return_type' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param param1 The first parameter. @@ -315,7 +315,7 @@ def foo(param1, param2, param3 = nil) end describe 'parsing a function with various dispatch parameters.' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param param1 The first parameter. @@ -369,7 +369,7 @@ def foo(param1, param2, param3 = nil) end describe 'parsing a function with an optional repeated param.' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param param The first parameter. @@ -408,7 +408,7 @@ def foo(param1, param2, param3 = nil) end describe 'parsing a function with a block param with one parameter' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param a_block The block parameter. @@ -447,7 +447,7 @@ def foo(param1, param2, param3 = nil) end describe 'parsing a function with a block param with two parameter' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param a_block The block parameter. @@ -487,7 +487,7 @@ def foo(param1, param2, param3 = nil) end describe 'parsing a function with a multiple dispatches' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # The first overload. @@ -577,7 +577,7 @@ def other(b) end describe 'parsing a function with a namespaced name' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:'foo::bar::baz') do # @return [Undef] @@ -593,7 +593,7 @@ def other(b) end describe 'parsing a function with a missing parameter' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param missing A missing parameter. @@ -609,7 +609,7 @@ def other(b) end describe 'parsing a function with a missing @param tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @return [Undef] Returns nothing. @@ -625,7 +625,7 @@ def other(b) end describe 'parsing a function with a typed @param tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param [Integer] param1 The first parameter. @@ -646,7 +646,7 @@ def other(b) end describe 'parsing a function with a typed @param tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. Puppet::Functions.create_function(:foo) do # @param param1 The first parameter. @@ -662,7 +662,7 @@ def other(b) end describe 'parsing a function with a root @param tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. # @param param Nope. Puppet::Functions.create_function(:foo) do @@ -682,7 +682,7 @@ def other(b) end describe 'parsing a function with a root @overload tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. # @overload foo Puppet::Functions.create_function(:foo) do @@ -702,7 +702,7 @@ def other(b) end describe 'parsing a function with a root @return tag' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. # @return [Undef] foo Puppet::Functions.create_function(:foo) do @@ -723,7 +723,7 @@ def other(b) describe 'parsing a function with a summary' do context 'when the summary has fewer than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. # @summary A short summary. Puppet::Functions.create_function(:foo) do @@ -742,7 +742,7 @@ def other(b) end context 'when the summary has more than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # An example 4.x function. # @summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!! Puppet::Functions.create_function(:foo) do diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb index 98b8c751..6202e7cb 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb @@ -18,7 +18,7 @@ end describe 'parsing a provider with a missing description' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.type(:custom).provide :linux do end SOURCE @@ -29,7 +29,7 @@ end describe 'parsing a provider with an invalid docstring assignment' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.type(:custom).provide :linux do @doc = 123 end @@ -41,7 +41,7 @@ end describe 'parsing a provider with a valid docstring assignment' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.type(:custom).provide :linux do @doc = 'An example provider on Linux.' end @@ -71,7 +71,7 @@ end describe 'parsing a provider definition' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.type(:custom).provide :linux do desc 'An example provider on Linux.' confine kernel: 'Linux' @@ -104,7 +104,7 @@ end describe 'parsing a provider definition with a string based name' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.type(:'custom').provide :'linux' do desc 'An example provider on Linux.' end @@ -123,7 +123,7 @@ describe 'parsing a provider with a summary' do context 'when the summary has fewer than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.type(:custom).provide :linux do @doc = '@summary A short summary.' end @@ -138,7 +138,7 @@ end context 'when the summary has more than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.type(:custom).provide :linux do @doc = '@summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!!' end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb index 46d1bf72..4a410ebe 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb @@ -18,7 +18,7 @@ end describe 'parsing a type with a missing description' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::ResourceApi.register_type( name: 'database' ) @@ -30,7 +30,7 @@ end describe 'parsing a type with a valid docstring assignment' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::ResourceApi.register_type( name: 'database', docs: 'An example database server resource type.', @@ -63,7 +63,7 @@ end describe 'parsing a type definition' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # @!puppet.type.param [value1, value2] dynamic_param Documentation for a dynamic parameter. # @!puppet.type.property [foo, bar] dynamic_prop Documentation for a dynamic property. Puppet::ResourceApi.register_type( @@ -179,7 +179,7 @@ describe 'parsing a type with a summary' do context 'when the summary has fewer than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::ResourceApi.register_type( name: 'database', docs: '@summary A short summary.', @@ -195,7 +195,7 @@ end context 'when the summary has more than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::ResourceApi.register_type( name: 'database', docs: '@summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!!', @@ -209,7 +209,7 @@ end describe 'parsing a type with title_patterns' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::ResourceApi.register_type( name: 'database', docs: 'An example database server resource type.', diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/type_extras_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/type_extras_handler_spec.rb index 734e82ba..00a15f08 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/type_extras_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/type_extras_handler_spec.rb @@ -10,7 +10,7 @@ end describe 'parsing source with newproperty' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do desc 'database' end @@ -29,7 +29,7 @@ end describe 'parsing source with newparam' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do desc 'database' end @@ -49,7 +49,7 @@ end describe 'parsing source with ensurable' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do desc 'database' end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb index 15acb91d..b4a16447 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb @@ -18,7 +18,7 @@ end describe 'parsing a type with a missing description' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do end SOURCE @@ -29,7 +29,7 @@ end describe 'parsing a type with an invalid docstring assignment' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do @doc = 123 end @@ -41,7 +41,7 @@ end describe 'parsing a type with a valid docstring assignment' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do @doc = 'An example database server resource type.' end @@ -71,7 +71,7 @@ end describe 'parsing a type with a param with arguments' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do feature :encryption, 'The provider supports encryption.', methods: [:encrypt] @@ -96,7 +96,7 @@ end describe 'parsing a type definition' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # @!puppet.type.param [value1, value2] dynamic_param Documentation for a dynamic parameter. # @!puppet.type.property [foo, bar] dynamic_prop Documentation for a dynamic property. Puppet::Type.newtype(:database) do @@ -220,7 +220,7 @@ end describe 'parsing a valid type with string based name' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:'database') do desc 'An example database server resource type.' ensurable @@ -235,7 +235,7 @@ end describe 'parsing an ensurable type with default ensure values' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do desc 'An example database server resource type.' ensurable @@ -253,7 +253,7 @@ end describe 'parsing a type with a parameter with the name of "name"' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do desc 'An example database server resource type.' newparam(:name) do @@ -272,7 +272,7 @@ end describe 'parsing a type with a check with the name of "onlyif"' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:testexec) do desc 'An example exec type with a check.' newcheck(:onlyif) do @@ -291,7 +291,7 @@ describe 'parsing a type with a summary' do context 'when the summary has fewer than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do @doc = '@summary A short summary.' end @@ -306,7 +306,7 @@ end context 'when the summary has more than 140 characters' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } Puppet::Type.newtype(:database) do @doc = '@summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!!' end diff --git a/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb b/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb index 94b40834..431a58b9 100644 --- a/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb @@ -27,7 +27,7 @@ end describe 'parsing invalid JSON' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } class foo { SOURCE @@ -37,7 +37,7 @@ class foo { end describe 'parsing valid task metadata JSON' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } { "description": "Allows you to backup your database to local file.", "input_method": "stdin", diff --git a/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb b/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb index 5be37e3f..4bc83112 100644 --- a/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb @@ -5,7 +5,7 @@ describe PuppetStrings::Yard::Parsers::JSON::TaskStatement do subject(:spec_subject) { described_class.new(json, source, 'test.json') } - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } { "description": "Allows you to backup your database to local file.", "input_method": "stdin", @@ -45,7 +45,7 @@ end context 'no params' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } { "description": "Allows you to backup your database to local file.", "input_method": "stdin" diff --git a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb index 6b5b1e78..8b64ea71 100644 --- a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb @@ -26,7 +26,7 @@ end describe 'parsing invalid Puppet source code' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } class foo { SOURCE @@ -36,7 +36,7 @@ class foo { end describe 'parsing class definitions' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } notice hello # A simple foo class. # @param param1 First param. @@ -74,7 +74,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end describe 'parsing nested class definitions' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } class foo { class bar { } @@ -96,7 +96,7 @@ class bar { end describe 'parsing defined types' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } notice hello # A simple foo defined type. # @param param1 First param. @@ -136,7 +136,7 @@ class bar { # The parsing code actually checks this and sets a global (Puppet[:tasks]). # Plan parsing will fail if it hasn't yet encountered a file under plans/. let(:file) { 'plans/test.pp' } - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple plan. # @param param1 First param. # @param param2 Second param. @@ -169,7 +169,7 @@ class bar { end describe 'parsing puppet functions', if: TEST_PUPPET_FUNCTIONS do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } notice hello # A simple foo function. # @param param1 First param. @@ -204,7 +204,7 @@ class bar { end describe 'parsing puppet functions with return type in defintion', if: TEST_FUNCTION_RETURN_TYPE do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @return Returns a string function foo() >> String { @@ -222,7 +222,7 @@ class bar { end describe 'parsing puppet functions with complex return types in defintion', if: TEST_FUNCTION_RETURN_TYPE do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo function. # @return Returns a struct with a hash including one key which must be an integer between 1 and 10. function foo() >> Struct[{'a' => Integer[1, 10]}] { @@ -241,7 +241,7 @@ class bar { describe 'parsing type alias definitions', if: TEST_PUPPET_DATATYPES do context 'given a type alias on a single line' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A simple foo type. type Module::Typename = Variant[Stdlib::Windowspath, Stdlib::Unixpath] SOURCE @@ -258,7 +258,7 @@ class bar { end context 'given a type alias over multiple lines' do - let(:source) { <<~'SOURCE' } + let(:source) { <<~SOURCE } # A multiline foo type # with long docs type OptionsWithoutName = Struct[{ diff --git a/spec/unit/puppet-strings/yard/util_spec.rb b/spec/unit/puppet-strings/yard/util_spec.rb index 3c3673b1..1a89f79e 100644 --- a/spec/unit/puppet-strings/yard/util_spec.rb +++ b/spec/unit/puppet-strings/yard/util_spec.rb @@ -18,7 +18,7 @@ end it 'does not affect newlines when %Q notation is used' do - str = <<~'STR' + str = <<~STR %Q{this is a test string} STR From cadcf9d0e082fe74b4ed1260d8984a0d7229e91e Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:24:07 +0100 Subject: [PATCH 41/60] (CONT-812) Correct Style/RedundantRegexpCharacterClass --- lib/puppet-strings/yard/handlers/ruby/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/yard/handlers/ruby/base.rb b/lib/puppet-strings/yard/handlers/ruby/base.rb index 7b263b52..6da9f383 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 = %r{^ Date: Mon, 17 Apr 2023 14:24:48 +0100 Subject: [PATCH 42/60] (CONT-812) Correct Style/RedundantRegexpEscape --- lib/puppet-strings/yard/handlers/ruby/base.rb | 2 +- lib/puppet-strings/yard/util.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet-strings/yard/handlers/ruby/base.rb b/lib/puppet-strings/yard/handlers/ruby/base.rb index 6da9f383..c8e827ca 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 = %r{^ Date: Mon, 17 Apr 2023 14:25:30 +0100 Subject: [PATCH 43/60] (CONT-812) Correct Style/RedundantStringEscape --- spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb index 8b64ea71..7a24797b 100644 --- a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb @@ -235,7 +235,7 @@ class bar { expect(spec_subject.enumerator.size).to eq(1) statement = spec_subject.enumerator.first expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::FunctionStatement) - expect(statement.type).to eq("Struct\[{'a' => Integer[1, 10]}\]") + expect(statement.type).to eq("Struct[{'a' => Integer[1, 10]}]") end end From 35b9aedf85944ab10d0e60f906d70d3b76cadad2 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:26:35 +0100 Subject: [PATCH 44/60] (CONT-812) Correct Style/RegexpLiteral --- lib/puppet-strings/markdown/base.rb | 2 +- lib/puppet-strings/yard/handlers/ruby/base.rb | 2 +- .../yard/parsers/puppet/statement.rb | 4 +- lib/puppet-strings/yard/util.rb | 4 +- lib/puppet/face/strings.rb | 2 +- spec/acceptance/generate_json_spec.rb | 2 +- spec/acceptance/generate_markdown_spec.rb | 2 +- .../running_strings_generate_spec.rb | 2 +- spec/spec_helper_acceptance_local.rb | 2 +- spec/unit/puppet-strings/markdown_spec.rb | 50 +++++++++---------- .../yard/handlers/json/task_handler_spec.rb | 6 +-- .../handlers/puppet/class_handler_spec.rb | 12 ++--- .../puppet/data_type_alias_handler_spec.rb | 6 +-- .../puppet/defined_type_handler_spec.rb | 14 +++--- .../handlers/puppet/function_handler_spec.rb | 22 ++++---- .../handlers/ruby/data_type_handler_spec.rb | 24 ++++----- .../handlers/ruby/function_handler_spec.rb | 22 ++++---- .../handlers/ruby/provider_handler_spec.rb | 6 +-- .../yard/handlers/ruby/rsapi_handler_spec.rb | 6 +-- .../yard/handlers/ruby/type_handler_spec.rb | 6 +-- .../yard/parsers/json/parser_spec.rb | 2 +- .../yard/parsers/puppet/parser_spec.rb | 4 +- 22 files changed, 101 insertions(+), 101 deletions(-) diff --git a/lib/puppet-strings/markdown/base.rb b/lib/puppet-strings/markdown/base.rb index 4f2e0eaf..08a2a7c2 100644 --- a/lib/puppet-strings/markdown/base.rb +++ b/lib/puppet-strings/markdown/base.rb @@ -200,7 +200,7 @@ def word_wrap(text, line_width: 120, break_sequence: "\n") return unless text text.split("\n").map! { |line| - line.length > line_width ? line.gsub(%r{(.{1,#{line_width}})(\s+|$)}, "\\1#{break_sequence}").strip : line + line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1#{break_sequence}").strip : line } * break_sequence end diff --git a/lib/puppet-strings/yard/handlers/ruby/base.rb b/lib/puppet-strings/yard/handlers/ruby/base.rb index c8e827ca..acaf8d73 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 = %r{^ Date: Mon, 17 Apr 2023 14:27:18 +0100 Subject: [PATCH 45/60] (CONT-812) Correct Style/RescueStandardError --- lib/puppet-strings/yard/parsers/json/parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/yard/parsers/json/parser.rb b/lib/puppet-strings/yard/parsers/json/parser.rb index 3fcfcc53..d5b21e7f 100644 --- a/lib/puppet-strings/yard/parsers/json/parser.rb +++ b/lib/puppet-strings/yard/parsers/json/parser.rb @@ -28,7 +28,7 @@ def parse # TODO: this should compare json to a Task metadata json-schema or perform some other hueristics # to determine what type of statement it represents @statements.push(PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, @source, @file)) unless json.empty? - rescue + rescue StandardError log.error "Failed to parse #{@file}: " @statements = [] end From 45b0786337ba160633466284f7ac679c50eed9f9 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:27:53 +0100 Subject: [PATCH 46/60] (CONT-812) Correct Style/SafeNavigation --- lib/puppet-strings/markdown/data_type.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/markdown/data_type.rb b/lib/puppet-strings/markdown/data_type.rb index 46ccab01..8931ca34 100644 --- a/lib/puppet-strings/markdown/data_type.rb +++ b/lib/puppet-strings/markdown/data_type.rb @@ -14,7 +14,7 @@ def initialize(registry) @template = 'data_type.erb' super(registry, 'data type') @alias_of = registry[:alias_of] unless registry[:alias_of].nil? - @functions = @registry[:functions].nil? ? nil : @registry[:functions].map { |func| DataType::Function.new(func) } + @functions = @registry[:functions]&.map { |func| DataType::Function.new(func) } end def render From c663b7bcf2f2159be552e6a05ff60b4dd5b95ecc Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:28:32 +0100 Subject: [PATCH 47/60] (CONT-812) Correct Style/SlicingWithRange --- lib/puppet-strings/yard/code_objects/function.rb | 2 +- lib/puppet-strings/yard/handlers/ruby/base.rb | 2 +- lib/puppet-strings/yard/tags/overload_tag.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet-strings/yard/code_objects/function.rb b/lib/puppet-strings/yard/code_objects/function.rb index 8b13d93c..23d6c679 100644 --- a/lib/puppet-strings/yard/code_objects/function.rb +++ b/lib/puppet-strings/yard/code_objects/function.rb @@ -70,7 +70,7 @@ def signature tag = tags.find { |t| t.name == name } if tags type = tag&.types ? "#{tag.type} " : 'Any ' prefix = (name[0]).to_s if name.start_with?('*', '&') - name = name[1..-1] if prefix + name = name[1..] if prefix default = " = #{default}" if default "#{type}#{prefix}$#{name}#{default}" end.join(', ') diff --git a/lib/puppet-strings/yard/handlers/ruby/base.rb b/lib/puppet-strings/yard/handlers/ruby/base.rb index acaf8d73..81c3c9bf 100644 --- a/lib/puppet-strings/yard/handlers/ruby/base.rb +++ b/lib/puppet-strings/yard/handlers/ruby/base.rb @@ -18,7 +18,7 @@ def node_as_string(node) case node.type when :symbol, :symbol_literal - node.source[1..-1] + node.source[1..] when :label node.source[0..-2] when :dyna_symbol diff --git a/lib/puppet-strings/yard/tags/overload_tag.rb b/lib/puppet-strings/yard/tags/overload_tag.rb index 7826118a..7f9b49d9 100644 --- a/lib/puppet-strings/yard/tags/overload_tag.rb +++ b/lib/puppet-strings/yard/tags/overload_tag.rb @@ -26,7 +26,7 @@ def signature tag = tags.find { |t| t.name == name } if tags type = tag&.types ? "#{tag.type} " : 'Any ' prefix = (name[0]).to_s if name.start_with?('*', '&') - name = name[1..-1] if prefix + name = name[1..] if prefix default = " = #{default}" if default "#{type}#{prefix}$#{name}#{default}" end.join(', ') From 530e86aa7a1f2de66b029f083af076cdc13c150f Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:30:09 +0100 Subject: [PATCH 48/60] (CONT-812) Correct Style/StderrPuts --- lib/puppet-strings/tasks/validate.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet-strings/tasks/validate.rb b/lib/puppet-strings/tasks/validate.rb index 53344442..4e265feb 100644 --- a/lib/puppet-strings/tasks/validate.rb +++ b/lib/puppet-strings/tasks/validate.rb @@ -10,7 +10,7 @@ filename = 'REFERENCE.md' unless File.exist?(filename) - $stderr.puts "#{filename} does not exist" + warn "#{filename} does not exist" exit 1 end @@ -34,7 +34,7 @@ existing = File.read(filename) if generated != existing - $stderr.puts "#{filename} is outdated" + warn "#{filename} is outdated" exit 1 end end From c9198ee915f07a35bb7096984c1be58a80d912da Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:31:30 +0100 Subject: [PATCH 49/60] (CONT-812) Correct Style/StringConcatenation --- lib/puppet-strings/describe.rb | 2 +- lib/puppet-strings/yard/code_objects/function.rb | 2 +- lib/puppet-strings/yard/handlers/ruby/function_handler.rb | 4 ++-- lib/puppet-strings/yard/parsers/puppet/statement.rb | 2 +- lib/puppet-strings/yard/tags/overload_tag.rb | 2 +- spec/spec_helper.rb | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/puppet-strings/describe.rb b/lib/puppet-strings/describe.rb index 99e25cb3..d4f099bc 100644 --- a/lib/puppet-strings/describe.rb +++ b/lib/puppet-strings/describe.rb @@ -59,7 +59,7 @@ def self.list_one_type(type) contentstring = type[:docstring][:text] end_of_line = contentstring.index("\n") # "." gives closer results to old describeb, but breaks for '.k5login' contentstring = contentstring[0..end_of_line] unless end_of_line.nil? - contentstring = contentstring[0..shortento] + ' ...' if contentstring.length > targetlength + contentstring = "#{contentstring[0..shortento]} ..." if contentstring.length > targetlength puts "#{type[:name].to_s.ljust(15)} - #{contentstring}" end diff --git a/lib/puppet-strings/yard/code_objects/function.rb b/lib/puppet-strings/yard/code_objects/function.rb index 23d6c679..33dbaaee 100644 --- a/lib/puppet-strings/yard/code_objects/function.rb +++ b/lib/puppet-strings/yard/code_objects/function.rb @@ -74,7 +74,7 @@ def signature default = " = #{default}" if default "#{type}#{prefix}$#{name}#{default}" end.join(', ') - @name.to_s + '(' + args + ')' + "#{@name}(#{args})" end # Converts the code object to a hash representation. diff --git a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb index 55e87e61..87bb4b2b 100644 --- a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb @@ -316,9 +316,9 @@ def add_param_tag(object, tags, name, file, line, type = nil, default = nil, opt end if repeated - name = '*' + name + name = "*#{name}" elsif block - name = '&' + name + name = "&#{name}" end type ||= tag&.types ? tag.type : 'Any' diff --git a/lib/puppet-strings/yard/parsers/puppet/statement.rb b/lib/puppet-strings/yard/parsers/puppet/statement.rb index a34c4119..2420bb20 100644 --- a/lib/puppet-strings/yard/parsers/puppet/statement.rb +++ b/lib/puppet-strings/yard/parsers/puppet/statement.rb @@ -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 = "#{PuppetStrings::Yard::Util.ast_to_text(type_expr.left_expr)}[" @alias_of << type_expr.keys.map { |key| PuppetStrings::Yard::Util.ast_to_text(key) }.join(', ') @alias_of << ']' else diff --git a/lib/puppet-strings/yard/tags/overload_tag.rb b/lib/puppet-strings/yard/tags/overload_tag.rb index 7f9b49d9..8ae29425 100644 --- a/lib/puppet-strings/yard/tags/overload_tag.rb +++ b/lib/puppet-strings/yard/tags/overload_tag.rb @@ -30,7 +30,7 @@ def signature default = " = #{default}" if default "#{type}#{prefix}$#{name}#{default}" end.join(', ') - @name + '(' + args + ')' + "#{@name}(#{args})" end # Adds a tag to the overload's docstring. diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fe5cdb76..c9ca99ff 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -84,6 +84,6 @@ def lint_markdown(content) end failure_message do |actual| - "expected that #{actual.length > 80 ? actual.slice(0, 80).inspect + '...' : actual.inspect} would have no markdown lint errors but got #{@violations.join("\n")}" + "expected that #{actual.length > 80 ? "#{actual.slice(0, 80).inspect}..." : actual.inspect} would have no markdown lint errors but got #{@violations.join("\n")}" end end From bd9f5f9e101a7ba8aa63eec502b9fddb85092bb0 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:32:15 +0100 Subject: [PATCH 50/60] (CONT-812) Correct Style/StringConcatenation --- lib/puppet-strings/markdown/data_type.rb | 2 +- lib/puppet-strings/tasks/generate.rb | 2 +- lib/puppet-strings/tasks/gh_pages.rb | 10 +++++----- lib/puppet-strings/yard/code_objects/data_type.rb | 4 ++-- lib/puppet-strings/yard/code_objects/function.rb | 4 ++-- .../yard/templates/default/layout/html/setup.rb | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/puppet-strings/markdown/data_type.rb b/lib/puppet-strings/markdown/data_type.rb index 8931ca34..a11239b6 100644 --- a/lib/puppet-strings/markdown/data_type.rb +++ b/lib/puppet-strings/markdown/data_type.rb @@ -8,7 +8,7 @@ class DataType < Base attr_reader :alias_of, :functions group_name 'Data types' - yard_types [:puppet_data_type, :puppet_data_type_alias] + yard_types %i[puppet_data_type puppet_data_type_alias] def initialize(registry) @template = 'data_type.erb' diff --git a/lib/puppet-strings/tasks/generate.rb b/lib/puppet-strings/tasks/generate.rb index c06561bf..6cd856da 100644 --- a/lib/puppet-strings/tasks/generate.rb +++ b/lib/puppet-strings/tasks/generate.rb @@ -37,7 +37,7 @@ def parse_format_option(args, options, format) end # rubocop:enable Style/PreferredHashMethods - [:json, :markdown].each { |format| parse_format_option(args, options, format) } + %i[json markdown].each { |format| parse_format_option(args, options, format) } warn('yard_args behavior is a little dodgy, use at your own risk') if args[:yard_args] options[:yard_args] = args[:yard_args].split if args.key? :yard_args diff --git a/lib/puppet-strings/tasks/gh_pages.rb b/lib/puppet-strings/tasks/gh_pages.rb index d48bdaa7..f921f290 100644 --- a/lib/puppet-strings/tasks/gh_pages.rb +++ b/lib/puppet-strings/tasks/gh_pages.rb @@ -48,11 +48,11 @@ end desc 'Update docs on the gh-pages branch and push to GitHub.' - task update: [ - :checkout, - :'strings:generate', - :configure, - :push, + task update: %i[ + checkout + strings:generate + configure + push ] end end diff --git a/lib/puppet-strings/yard/code_objects/data_type.rb b/lib/puppet-strings/yard/code_objects/data_type.rb index 39f343f3..2c3b8579 100644 --- a/lib/puppet-strings/yard/code_objects/data_type.rb +++ b/lib/puppet-strings/yard/code_objects/data_type.rb @@ -87,14 +87,14 @@ def to_hash hash[:name] = name hash[:file] = file hash[:line] = line - hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring, [:param, :option, :enum, :return, :example]) + hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example]) hash[:defaults] = defaults unless defaults.nil? || defaults.empty? hash[:source] = source unless source.nil? || source.empty? hash[:functions] = functions.map do |func| { name: func.name, signature: func.signature, - docstring: PuppetStrings::Yard::Util.docstring_to_hash(func.docstring, [:param, :option, :enum, :return, :example]) + docstring: PuppetStrings::Yard::Util.docstring_to_hash(func.docstring, %i[param option enum return example]) } end hash diff --git a/lib/puppet-strings/yard/code_objects/function.rb b/lib/puppet-strings/yard/code_objects/function.rb index 33dbaaee..e2f9007e 100644 --- a/lib/puppet-strings/yard/code_objects/function.rb +++ b/lib/puppet-strings/yard/code_objects/function.rb @@ -91,10 +91,10 @@ def to_hash if has_tag? :overload # loop over overloads and append onto the signatures array tags(:overload).each do |o| - hash[:signatures] << { signature: o.signature, docstring: PuppetStrings::Yard::Util.docstring_to_hash(o.docstring, [:param, :option, :enum, :return, :example]) } + 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, [:param, :option, :enum, :return, :example]) } + hash[:signatures] << { signature: 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/templates/default/layout/html/setup.rb b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb index c698c5f8..f8f6d404 100644 --- a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb @@ -6,7 +6,7 @@ def init case object when '_index.html' @page_title = options.title - sections :layout, [:index, [:listing, [:classes, :data_types, :defined_types, :types, :providers, :functions, :tasks, :plans, :files, :objects]]] + sections :layout, [:index, [:listing, %i[classes data_types defined_types types providers functions tasks plans files objects]]] else super end From a5832b1f87013b1afef0fb13e5763376e9b7f733 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:33:14 +0100 Subject: [PATCH 51/60] (CONT-812) Correct Style/SymbolProc --- lib/puppet-strings/markdown.rb | 6 +++--- lib/puppet-strings/yard/code_objects/type.rb | 10 +++++----- .../yard/handlers/ruby/data_type_handler.rb | 4 ++-- .../yard/templates/default/puppet_type/html/setup.rb | 4 ++-- spec/spec_helper.rb | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/puppet-strings/markdown.rb b/lib/puppet-strings/markdown.rb index 32a36f39..6f19882b 100644 --- a/lib/puppet-strings/markdown.rb +++ b/lib/puppet-strings/markdown.rb @@ -40,7 +40,7 @@ def self.generate template = erb(File.join(__dir__, 'markdown', 'templates', 'table_of_contents.erb')) groups.each do |group| group_name = group.group_name - items = group.items.map { |item| item.toc_info } + items = group.items.map(&:toc_info) has_private = items.any? { |item| item[:private] } has_public = items.any? { |item| !item[:private] } @@ -49,10 +49,10 @@ def self.generate # Create actual contents groups.each do |group| - items = group.items.reject { |item| item.private? } + items = group.items.reject(&:private?) unless items.empty? output << "## #{group.group_name}\n\n" - output.append(items.map { |item| item.render }) + output.append(items.map(&:render)) end end diff --git a/lib/puppet-strings/yard/code_objects/type.rb b/lib/puppet-strings/yard/code_objects/type.rb index 1240fba8..0e7c6486 100644 --- a/lib/puppet-strings/yard/code_objects/type.rb +++ b/lib/puppet-strings/yard/code_objects/type.rb @@ -185,11 +185,11 @@ def to_hash hash[:line] = line hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) - hash[:properties] = properties.sort_by { |p| p.name }.map(&:to_hash) if properties && !properties.empty? - hash[:parameters] = parameters.sort_by { |p| p.name }.map(&:to_hash) if parameters && !parameters.empty? - hash[:checks] = checks.sort_by { |c| c.name }.map(&:to_hash) if checks && !checks.empty? - hash[:features] = features.sort_by { |f| f.name }.map(&:to_hash) if features && !features.empty? - hash[:providers] = providers.sort_by { |p| p.name }.map(&:to_hash) if providers && !providers.empty? + hash[:properties] = properties.sort_by(&:name).map(&:to_hash) if properties && !properties.empty? + hash[:parameters] = parameters.sort_by(&:name).map(&:to_hash) if parameters && !parameters.empty? + hash[:checks] = checks.sort_by(&:name).map(&:to_hash) if checks && !checks.empty? + hash[:features] = features.sort_by(&:name).map(&:to_hash) if features && !features.empty? + hash[:providers] = providers.sort_by(&:name).map(&:to_hash) if providers && !providers.empty? hash end diff --git a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb index a826bc92..43688e5e 100644 --- a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb @@ -255,7 +255,7 @@ def extract_functions(object, hash) begin callable_type = Puppet::Pops::Types::TypeParser.singleton.parse(func_type) if callable_type.is_a?(Puppet::Pops::Types::PCallableType) - func_hash[:param_types] = callable_type.param_types.map { |pt| pt.to_s } + func_hash[:param_types] = callable_type.param_types.map(&:to_s) func_hash[:return_type] = callable_type.return_type.to_s else log.warn "The function definition for '#{key}' near #{object.file}:#{object.line} is not a Callable type" @@ -360,7 +360,7 @@ def validate_methods!(object, actual_functions_hash) # Puppet Data Type function invocation. So instead we derive a signature from the method definition. object.meths.each do |meth| params = '' - params += '(' + meth.docstring.tags(:param).map { |t| t.name }.join(', ') + ')' unless meth.docstring.tags(:param).empty? + params += "(#{meth.docstring.tags(:param).map(&:name).join(', ')})" unless meth.docstring.tags(:param).empty? meth.signature = "#{object.name}.#{meth.name}" + params end diff --git a/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb index d3b067e9..28455c65 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb @@ -21,7 +21,7 @@ def properties # # "checks" such as "creates" and "onlyif" are another type of property @parameters = (object.properties || []) + (object.checks || []) - @parameters.sort_by! { |p| p.name } + @parameters.sort_by!(&:name) @tag_title = 'Properties' erb(:parameters) end @@ -30,7 +30,7 @@ def properties # @return [String] Returns the rendered section. def parameters @parameters = object.parameters || [] - @parameters.sort_by! { |p| p.name } + @parameters.sort_by!(&:name) @tag_title = 'Parameters' erb(:parameters) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c9ca99ff..51184813 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -54,7 +54,7 @@ def lint_markdown(content) # Load default mdl ruleset - ruleset = MarkdownLint::RuleSet.new.tap { |r| r.load_default } + ruleset = MarkdownLint::RuleSet.new.tap(&:load_default) # Apply custom style to ruleset rules MarkdownLint::Style.load(File.join(__dir__, 'markdownlint_style.rb'), ruleset.rules) From 058f9e3dbc51eea85e1bc94c473f9e9071c557f7 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:33:49 +0100 Subject: [PATCH 52/60] (CONT-812) Correct Style/TrailingCommaInArguments --- lib/puppet-strings/yard.rb | 2 +- lib/puppet-strings/yard/code_objects/type.rb | 2 +- .../yard/handlers/ruby/function_handler.rb | 14 +++++++------- lib/puppet/face/strings.rb | 4 ++-- .../yard/handlers/puppet/class_handler_spec.rb | 2 +- .../yard/handlers/puppet/function_handler_spec.rb | 2 +- .../yard/handlers/ruby/function_handler_spec.rb | 8 ++++---- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/puppet-strings/yard.rb b/lib/puppet-strings/yard.rb index fe991298..2f9f256c 100644 --- a/lib/puppet-strings/yard.rb +++ b/lib/puppet-strings/yard.rb @@ -61,7 +61,7 @@ def all_objects :puppet_provider, :puppet_function, :puppet_task, - :puppet_plan, + :puppet_plan ) end end diff --git a/lib/puppet-strings/yard/code_objects/type.rb b/lib/puppet-strings/yard/code_objects/type.rb index 0e7c6486..fe6131fd 100644 --- a/lib/puppet-strings/yard/code_objects/type.rb +++ b/lib/puppet-strings/yard/code_objects/type.rb @@ -158,7 +158,7 @@ def parameters provider_param = Parameter.new( 'provider', "The specific backend to use for this `#{name}` resource. You will seldom need " \ - 'to specify this --- Puppet will usually discover the appropriate provider for your platform.', + 'to specify this --- Puppet will usually discover the appropriate provider for your platform.' ) @parameters ||= [] diff --git a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb index 87bb4b2b..79713cd5 100644 --- a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb @@ -39,7 +39,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard is_3x = ['Puppet::Parser::Functions', 'newfunction'].include?(module_name) object = PuppetStrings::Yard::CodeObjects::Function.new( get_name(statement, 'Puppet::Functions.create_function'), - is_3x ? PuppetStrings::Yard::CodeObjects::Function::RUBY_3X : PuppetStrings::Yard::CodeObjects::Function::RUBY_4X, + is_3x ? PuppetStrings::Yard::CodeObjects::Function::RUBY_3X : PuppetStrings::Yard::CodeObjects::Function::RUBY_4X ) object.source = statement register object @@ -185,7 +185,7 @@ def add_overload_tag(object, node) node_as_string(parameters[0]), nil, # TODO: determine default from corresponding Ruby method signature? method_name.include?('optional'), - method_name.include?('repeated'), + method_name.include?('repeated') ) end @@ -216,7 +216,7 @@ def add_overload_tag(object, node) nil, # TODO: determine default from corresponding Ruby method signature? block.method_name.source.include?('optional'), false, # Not repeated - true, # Is block + true # Is block ) end end @@ -244,7 +244,7 @@ def add_method_overload(object, node) param_tags, parameter.source, parameter.file, - parameter.line, + parameter.line ) end @@ -259,7 +259,7 @@ def add_method_overload(object, node) parameter.line, nil, parameter[1].source, - true, + true ) end @@ -275,7 +275,7 @@ def add_method_overload(object, node) nil, nil, false, - true, + true ) end @@ -292,7 +292,7 @@ def add_method_overload(object, node) nil, false, false, - true, + true ) end diff --git a/lib/puppet/face/strings.rb b/lib/puppet/face/strings.rb index e10acb5b..a09e8596 100644 --- a/lib/puppet/face/strings.rb +++ b/lib/puppet/face/strings.rb @@ -28,7 +28,7 @@ PuppetStrings.generate( args.count > 1 ? args[0..-2] : PuppetStrings::DEFAULT_SEARCH_PATTERNS, - build_generate_options(args.last), + build_generate_options(args.last) ) nil end @@ -127,7 +127,7 @@ search_patterns = ['types/**/*.pp', 'lib/**/*.rb'] PuppetStrings.generate( search_patterns, - build_generate_options(options), + build_generate_options(options) ) nil end diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb index ff7474b7..9e12b465 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb @@ -148,7 +148,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { it 'outputs a warning' do expect { spec_subject } .to output( - /\[warn\]: The type of the @param tag for parameter 'param1' does not match the parameter type specification near \(stdin\):5: ignoring in favor of parameter type information./, + /\[warn\]: The type of the @param tag for parameter 'param1' does not match the parameter type specification near \(stdin\):5: ignoring in favor of parameter type information./ ) .to_stdout_from_any_process end diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb index 5a7ef6a8..85cd7f51 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb @@ -152,7 +152,7 @@ it 'outputs a warning' do expect { spec_subject } .to output( - /\[warn\]: The type of the @param tag for parameter 'param1' does not match the parameter type specification near \(stdin\):6: ignoring in favor of parameter type information./, + /\[warn\]: The type of the @param tag for parameter 'param1' does not match the parameter type specification near \(stdin\):6: ignoring in favor of parameter type information./ ) .to_stdout_from_any_process end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb index 33babeff..4e579c4a 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb @@ -639,7 +639,7 @@ def other(b) it 'outputs a warning' do expect { spec_subject } .to output( - /\[warn\]: The @param tag for parameter 'param1' should not contain a type specification near \(stdin\):6: ignoring in favor of dispatch type information\./, + /\[warn\]: The @param tag for parameter 'param1' should not contain a type specification near \(stdin\):6: ignoring in favor of dispatch type information\./ ) .to_stdout_from_any_process end @@ -675,7 +675,7 @@ def other(b) it 'outputs a warning' do expect { spec_subject } .to output( - /\[warn\]: The docstring for Puppet 4.x function 'foo' contains @param tags near \(stdin\):3: parameter documentation should be made on the dispatch call\./, + /\[warn\]: The docstring for Puppet 4.x function 'foo' contains @param tags near \(stdin\):3: parameter documentation should be made on the dispatch call\./ ) .to_stdout_from_any_process end @@ -695,7 +695,7 @@ def other(b) it 'outputs a warning' do expect { spec_subject } .to output( - /\[warn\]: The docstring for Puppet 4.x function 'foo' contains @overload tags near \(stdin\):3: overload tags are automatically generated from the dispatch calls\./, + /\[warn\]: The docstring for Puppet 4.x function 'foo' contains @overload tags near \(stdin\):3: overload tags are automatically generated from the dispatch calls\./ ) .to_stdout_from_any_process end @@ -715,7 +715,7 @@ def other(b) it 'outputs a warning' do expect { spec_subject } .to output( - /\[warn\]: The docstring for Puppet 4.x function 'foo' contains @return tags near \(stdin\):3: return value documentation should be made on the dispatch call\./, + /\[warn\]: The docstring for Puppet 4.x function 'foo' contains @return tags near \(stdin\):3: return value documentation should be made on the dispatch call\./ ) .to_stdout_from_any_process end From 2fb7cf4255b3e4004529ab4f4ecd8afee6b901b3 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:35:09 +0100 Subject: [PATCH 53/60] (CONT-812) Correct Style/TrailingCommaInArrayLiteral --- lib/puppet-strings/markdown.rb | 4 ++-- .../yard/handlers/ruby/function_handler.rb | 2 +- .../yard/templates/default/layout/html/setup.rb | 2 +- puppet-strings.gemspec | 2 +- spec/acceptance/generate_json_spec.rb | 6 +++--- spec/acceptance/running_strings_generate_spec.rb | 12 ++++++------ spec/spec_helper.rb | 2 +- .../puppet-strings/yard/code_objects/task_spec.rb | 2 +- .../yard/handlers/ruby/data_type_handler_spec.rb | 2 +- .../yard/parsers/puppet/parser_spec.rb | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/puppet-strings/markdown.rb b/lib/puppet-strings/markdown.rb index 6f19882b..40122796 100644 --- a/lib/puppet-strings/markdown.rb +++ b/lib/puppet-strings/markdown.rb @@ -23,7 +23,7 @@ def self.groups PuppetStrings::Markdown::Function, PuppetStrings::Markdown::DataType, PuppetStrings::Markdown::PuppetTask, - PuppetStrings::Markdown::PuppetPlan, + PuppetStrings::Markdown::PuppetPlan ] end @@ -33,7 +33,7 @@ def self.generate output = [ "# Reference\n\n", "\n\n", - "## Table of Contents\n\n", + "## Table of Contents\n\n" ] # Create table of contents diff --git a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb index 79713cd5..511b24bc 100644 --- a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb @@ -18,7 +18,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard 'block_param', 'required_block_param', 'optional_block_param', - 'return_type', + 'return_type' ].freeze namespace_only diff --git a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb index f8f6d404..61443c73 100644 --- a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb @@ -124,7 +124,7 @@ def create_menu_lists type: 'method', title: 'Ruby Methods', search_title: 'Method List' - }, + } ] menu_lists.delete_if { |e| YARD::Registry.all(e[:type].intern).empty? } diff --git a/puppet-strings.gemspec b/puppet-strings.gemspec index 049ffa54..33e8f035 100644 --- a/puppet-strings.gemspec +++ b/puppet-strings.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| 'COMMITTERS.md', 'CONTRIBUTING.md', 'LICENSE', - 'README.md', + 'README.md' ] s.files = Dir['CHANGELOG.md', 'README.md', 'LICENSE', 'lib/**/*', 'exe/**/*'] diff --git a/spec/acceptance/generate_json_spec.rb b/spec/acceptance/generate_json_spec.rb index 86015e06..d0ee995f 100644 --- a/spec/acceptance/generate_json_spec.rb +++ b/spec/acceptance/generate_json_spec.rb @@ -34,16 +34,16 @@ 'tag_name' => 'return', 'text' => '', 'types' => ['Any'] - }, + } ] } - }, + } ], 'docstring' => { 'text' => 'This is the function documentation for `function3x`', 'tags' => ['tag_name' => 'return', 'text' => '', 'types' => ['Any']] }, - 'source' => "Puppet::Parser::Functions.newfunction(:function3x, :doc => \"This is the function documentation for `function3x`\") do |args|\nend", + 'source' => "Puppet::Parser::Functions.newfunction(:function3x, :doc => \"This is the function documentation for `function3x`\") do |args|\nend" ], 'puppet_tasks' => [], 'puppet_plans' => [] diff --git a/spec/acceptance/running_strings_generate_spec.rb b/spec/acceptance/running_strings_generate_spec.rb index 3b333f3a..776dfebd 100644 --- a/spec/acceptance/running_strings_generate_spec.rb +++ b/spec/acceptance/running_strings_generate_spec.rb @@ -33,7 +33,7 @@ def expect_file_contain(path, expected_contents) # These tests are failing. Appear to be legitimate failures. '

The first integer to add.

', '

The second integer to add.

', - '

Returns the sum of x and y.

', + '

Returns the sum of x and y.

' ]) end @@ -52,7 +52,7 @@ def expect_file_contain(path, expected_contents) '

Documentation for a dynamic property.

', '

The database server name.

', '

Documentation for a dynamic parameter.

', - '

The provider supports encryption.

', + '

The provider supports encryption.

' ]) end @@ -60,7 +60,7 @@ def expect_file_contain(path, expected_contents) expect_file_contain('doc/puppet_providers_database/linux.html', [ 'The database provider on Linux', 'osfamily — linux', - 'database — /usr/bin/database', + 'database — /usr/bin/database' ]) end @@ -71,7 +71,7 @@ def expect_file_contain(path, expected_contents) '

func1

', '

func1 documentation

', '

param1 func1 documentation

', - '

param2 func1 documentation

', + '

param2 func1 documentation

' ]) end @@ -79,7 +79,7 @@ def expect_file_contain(path, expected_contents) expect_file_contain('doc/puppet_data_type_aliases/Test_3A_3AElephant.html', [ 'Data Type: Test::Elephant', 'types/elephant.pp', - 'A simple elephant type.', + 'A simple elephant type.' ]) end @@ -89,7 +89,7 @@ def expect_file_contain(path, expected_contents) 'a', "—

Option A

\n
", 'b', - "—

Option B

\n
", + "—

Option B

\n
" ]) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 51184813..fc3c86fe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,7 +8,7 @@ SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::Console, - SimpleCov::Formatter::Codecov, + SimpleCov::Formatter::Codecov ] SimpleCov.start do diff --git a/spec/unit/puppet-strings/yard/code_objects/task_spec.rb b/spec/unit/puppet-strings/yard/code_objects/task_spec.rb index bddc14e3..83cb3346 100644 --- a/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +++ b/spec/unit/puppet-strings/yard/code_objects/task_spec.rb @@ -77,7 +77,7 @@ tag_name: 'param', text: 'Path to file you want backup to', types: ['String[1]'] - }, + } ] }, file: 'test.json', diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb index 2018ac2c..12c02233 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb @@ -480,7 +480,7 @@ def suppress_yard_logging { value: '0xFF', expected: 255 }, { value: '0.1', expected: 0.1 }, { value: '31.415e-1', expected: 3.1415 }, - { value: '0.31415e1', expected: 3.1415 }, + { value: '0.31415e1', expected: 3.1415 } ].each do |testcase| describe "parsing a valid data type definition with numeric default #{testcase[:value]}" do let(:source) { <<~SOURCE } diff --git a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb index 5fac499f..deb0dc77 100644 --- a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb @@ -295,7 +295,7 @@ class bar { '1 + 1', 'func()', '$param1.foo(1)', - '$param1.foo($param2 + $param3.bar())', + '$param1.foo($param2 + $param3.bar())' ].each do |value| describe "parsing parameter with #{value} default value" do let(:source) { <<~PUPPET } @@ -319,7 +319,7 @@ class foo ( 'Linux' => 'linux', 'Darwin' => 'darwin', default => $facts['kernel'], - }", + }" ].each do |value| describe "parsing parameter with #{value} default value" do let(:source) { <<~PUPPET } From 71cab16295793466d19dd3c165024bf8c06607f5 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:35:42 +0100 Subject: [PATCH 54/60] (CONT-812) Correct Style/TrailingCommaInHashLiteral --- lib/puppet-strings/describe.rb | 2 +- lib/puppet-strings/tasks/generate.rb | 2 +- lib/puppet-strings/tasks/validate.rb | 2 +- .../yard/templates/default/layout/html/setup.rb | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/puppet-strings/describe.rb b/lib/puppet-strings/describe.rb index d4f099bc..f63b7279 100644 --- a/lib/puppet-strings/describe.rb +++ b/lib/puppet-strings/describe.rb @@ -13,7 +13,7 @@ module PuppetStrings::Describe def self.render(describe_types = [], list = false, _providers = false) document = { defined_types: YARD::Registry.all(:puppet_defined_type).sort_by!(&:name).map!(&:to_hash), - resource_types: YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash), + resource_types: YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash) } if list diff --git a/lib/puppet-strings/tasks/generate.rb b/lib/puppet-strings/tasks/generate.rb index 6cd856da..777ecbb6 100644 --- a/lib/puppet-strings/tasks/generate.rb +++ b/lib/puppet-strings/tasks/generate.rb @@ -13,7 +13,7 @@ options = { debug: args[:debug] == 'true', backtrace: args[:backtrace] == 'true', - markup: args[:markup] || 'markdown', + markup: args[:markup] || 'markdown' } raise('Error: Both JSON and Markdown output have been selected. Please select one.') if args[:json] == 'true' && args[:markdown] == 'true' diff --git a/lib/puppet-strings/tasks/validate.rb b/lib/puppet-strings/tasks/validate.rb index 4e265feb..21251d8c 100644 --- a/lib/puppet-strings/tasks/validate.rb +++ b/lib/puppet-strings/tasks/validate.rb @@ -24,7 +24,7 @@ backtrace: args[:backtrace] == 'true', json: false, markdown: true, - path: file, + path: file } PuppetStrings.generate(patterns, options) diff --git a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb index 61443c73..d29daca7 100644 --- a/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/layout/html/setup.rb @@ -83,12 +83,12 @@ def create_menu_lists { type: 'puppet_data_type', title: 'Data Types', - search_title: 'Data Types', + search_title: 'Data Types' }, { type: 'puppet_defined_type', title: 'Defined Types', - search_title: 'Defined Types', + search_title: 'Defined Types' }, { type: 'puppet_type', From 5ff69026d1d651c638340d86b409044a11b7d428 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:36:21 +0100 Subject: [PATCH 55/60] (CONT-812) Correct Style/WordArray --- .../yard/handlers/ruby/function_handler.rb | 22 +++++++++---------- .../yard/handlers/ruby/provider_handler.rb | 2 +- .../yard/handlers/ruby/rsapi_handler.rb | 2 +- .../unit/puppet-strings/markdown/base_spec.rb | 20 ++++++++--------- .../handlers/puppet/class_handler_spec.rb | 2 +- .../puppet/defined_type_handler_spec.rb | 2 +- .../handlers/puppet/function_handler_spec.rb | 2 +- .../handlers/ruby/data_type_handler_spec.rb | 2 +- .../handlers/ruby/function_handler_spec.rb | 2 +- .../handlers/ruby/provider_handler_spec.rb | 4 ++-- .../yard/handlers/ruby/rsapi_handler_spec.rb | 6 ++--- .../yard/handlers/ruby/type_handler_spec.rb | 14 ++++++------ 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb index 511b24bc..f23c19c9 100644 --- a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb @@ -8,17 +8,17 @@ # Implements the handler for Puppet functions written in Ruby. class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard::Handlers::Ruby::Base # Represents the list of Puppet 4.x function API methods to support. - DISPATCH_METHOD_NAMES = [ - 'param', - 'required_param', - 'optional_param', - 'repeated_param', - 'optional_repeated_param', - 'required_repeated_param', - 'block_param', - 'required_block_param', - 'optional_block_param', - 'return_type' + DISPATCH_METHOD_NAMES = %w[ + param + required_param + optional_param + repeated_param + optional_repeated_param + required_repeated_param + block_param + required_block_param + optional_block_param + return_type ].freeze namespace_only diff --git a/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb b/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb index 1a199a34..8f16f991 100644 --- a/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb @@ -94,7 +94,7 @@ def populate_provider_data(object) object.add_confine(node_as_string(kvp[0]) || kvp[0].source, node_as_string(kvp[1]) || kvp[1].source) end - elsif ['has_feature', 'has_features'].include?(method_name) + elsif %w[has_feature has_features].include?(method_name) # Add the features to the object parameters.each do |parameter| object.add_feature(node_as_string(parameter) || parameter.source) diff --git a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb index afac3995..f18decfa 100644 --- a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb @@ -129,7 +129,7 @@ def populate_type_data(object, schema) schema['attributes'].each do |name, definition| # puts "Processing #{name}: #{definition.inspect}" - if ['parameter', 'namevar'].include? definition['behaviour'] + if %w[parameter namevar].include? definition['behaviour'] object.add_parameter(create_parameter(name, definition)) else object.add_property(create_property(name, definition)) diff --git a/spec/unit/puppet-strings/markdown/base_spec.rb b/spec/unit/puppet-strings/markdown/base_spec.rb index 0dbb1244..f36cb063 100644 --- a/spec/unit/puppet-strings/markdown/base_spec.rb +++ b/spec/unit/puppet-strings/markdown/base_spec.rb @@ -27,11 +27,11 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end end - ['examples', - 'see', - 'since', - 'return_val', - 'return_type'].each do |method| + %w[examples + see + since + return_val + return_type].each do |method| describe "##{method}" do it 'returns nil' do expect(component.method(method.to_sym).call).to be_nil @@ -108,11 +108,11 @@ class klass::yeah( end end - ['summary', - 'see', - 'since', - 'return_val', - 'return_type'].each do |method| + %w[summary + see + since + return_val + return_type].each do |method| describe "##{method}" do it 'returns nil' do expect(component.method(method.to_sym).call).to be_nil diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb index 9e12b465..8a50ef65 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb @@ -54,7 +54,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::Classes.instance) expect(object.name).to eq(:foo) expect(object.statement).not_to be_nil - expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', 'hi']]) + expect(object.parameters).to eq([['param1', nil], ['param2', nil], %w[param3 hi]]) expect(object.docstring).to eq('A simple foo class.') expect(object.docstring.tags.size).to eq(4) tags = object.docstring.tags(:param) diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb index 73157932..82f0c13e 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb @@ -59,7 +59,7 @@ expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::DefinedTypes.instance) expect(object.name).to eq(:foo) expect(object.statement).not_to be_nil - expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', 'hi']]) + expect(object.parameters).to eq([['param1', nil], ['param2', nil], %w[param3 hi]]) expect(object.docstring).to eq('A simple foo defined type.') expect(object.docstring.tags.size).to eq(5) tags = object.docstring.tags(:param) diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb index 85cd7f51..1297993b 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb @@ -55,7 +55,7 @@ expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::Functions.instance(PuppetStrings::Yard::CodeObjects::Function::PUPPET)) expect(object.name).to eq(:foo) expect(object.signature).to eq('foo(Integer $param1, Any $param2, String $param3 = hi)') - expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', 'hi']]) + expect(object.parameters).to eq([['param1', nil], ['param2', nil], %w[param3 hi]]) expect(object.docstring).to eq('A simple foo function.') expect(object.docstring.tags.size).to eq(5) tags = object.docstring.tags(:param) diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb index 12c02233..6462511f 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb @@ -305,7 +305,7 @@ def suppress_yard_logging # Check for default values expect(object.parameters.size).to eq(2) expect(object.parameters[0]).to eq(['msg', nil]) - expect(object.parameters[1]).to eq(['arg1', 'param']) + expect(object.parameters[1]).to eq(%w[arg1 param]) # Check for functions expect(object.functions.size).to eq(1) diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb index 4e579c4a..f08659c0 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb @@ -205,7 +205,7 @@ def foo(param1, param2, param3 = nil) expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::Functions.instance(PuppetStrings::Yard::CodeObjects::Function::RUBY_4X)) expect(object.name).to eq(:foo) expect(object.signature).to eq('foo(Integer $param1, Any $param2, Optional[String] $param3 = undef)') - expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', 'undef']]) + expect(object.parameters).to eq([['param1', nil], ['param2', nil], %w[param3 undef]]) expect(object.docstring).to eq('An example 4.x function.') expect(object.docstring.tags.size).to eq(5) tags = object.docstring.tags(:param) diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb index 4c217f51..01470dd9 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb @@ -97,8 +97,8 @@ expect(tags.size).to eq(1) expect(tags[0].text).to eq('public') expect(object.confines).to eq({ 'kernel' => 'Linux', 'osfamily' => 'RedHat' }) - expect(object.defaults).to eq([[['kernel', 'Linux']], [['osfamily', 'RedHat'], ['operatingsystemmajrelease', '7']]]) - expect(object.features).to eq(['implements_some_feature', 'some_other_feature']) + expect(object.defaults).to eq([[%w[kernel Linux]], [%w[osfamily RedHat], %w[operatingsystemmajrelease 7]]]) + expect(object.features).to eq(%w[implements_some_feature some_other_feature]) expect(object.commands).to eq({ 'foo' => '/usr/bin/foo' }) end end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb index 2fbf6b32..3a14fa4d 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb @@ -122,12 +122,12 @@ tags = object.docstring.tags(:api) expect(tags.size).to eq(1) expect(tags[0].text).to eq('public') - expect(object.properties.map(&:name)).to eq(['dynamic_prop', 'ensure', 'file', 'log_level']) + expect(object.properties.map(&:name)).to eq(%w[dynamic_prop ensure file log_level]) expect(object.properties.size).to eq(4) expect(object.properties[0].name).to eq('dynamic_prop') expect(object.properties[0].docstring).to eq('Documentation for a dynamic property.') expect(object.properties[0].isnamevar).to be(false) - expect(object.properties[0].values).to eq(['foo', 'bar']) + expect(object.properties[0].values).to eq(%w[foo bar]) expect(object.properties[1].name).to eq('ensure') expect(object.properties[1].docstring).to eq('What state the database should be in.') expect(object.properties[1].isnamevar).to be(false) @@ -150,7 +150,7 @@ expect(object.parameters[0].name).to eq('dynamic_param') expect(object.parameters[0].docstring).to eq('Documentation for a dynamic parameter.') expect(object.parameters[0].isnamevar).to be(false) - expect(object.parameters[0].values).to eq(['value1', 'value2']) + expect(object.parameters[0].values).to eq(%w[value1 value2]) expect(object.parameters[1].name).to eq('address') expect(object.parameters[1].docstring).to eq('The database server name.') expect(object.parameters[1].isnamevar).to be(true) diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb index 8e72bbf8..8e226a0c 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb @@ -164,12 +164,12 @@ expect(object.properties[0].name).to eq('dynamic_prop') expect(object.properties[0].docstring).to eq('Documentation for a dynamic property.') expect(object.properties[0].isnamevar).to be(false) - expect(object.properties[0].values).to eq(['foo', 'bar']) + expect(object.properties[0].values).to eq(%w[foo bar]) expect(object.properties[1].name).to eq('ensure') expect(object.properties[1].docstring).to eq('What state the database should be in.') expect(object.properties[1].isnamevar).to be(false) expect(object.properties[1].default).to eq('up') - expect(object.properties[1].values).to eq(['present', 'absent', 'up', 'down']) + expect(object.properties[1].values).to eq(%w[present absent up down]) expect(object.properties[1].aliases).to eq({ 'down' => 'absent', 'up' => 'present' }) expect(object.properties[2].name).to eq('file') expect(object.properties[2].docstring).to eq('The database file to use.') @@ -181,13 +181,13 @@ expect(object.properties[3].docstring).to eq('The log level to use.') expect(object.properties[3].isnamevar).to be(false) expect(object.properties[3].default).to eq('warn') - expect(object.properties[3].values).to eq(['debug', 'warn', 'error']) + expect(object.properties[3].values).to eq(%w[debug warn error]) expect(object.properties[3].aliases).to eq({}) expect(object.parameters.size).to eq(5) expect(object.parameters[0].name).to eq('dynamic_param') expect(object.parameters[0].docstring).to eq('Documentation for a dynamic parameter.') expect(object.parameters[0].isnamevar).to be(false) - expect(object.parameters[0].values).to eq(['value1', 'value2']) + expect(object.parameters[0].values).to eq(%w[value1 value2]) expect(object.parameters[1].name).to eq('address') expect(object.parameters[1].docstring).to eq('The database server name.') expect(object.parameters[1].isnamevar).to be(true) @@ -204,13 +204,13 @@ expect(object.parameters[3].docstring).to eq('Whether or not to encrypt the database.') expect(object.parameters[3].isnamevar).to be(false) expect(object.parameters[3].default).to eq('false') - expect(object.parameters[3].values).to eq(['true', 'false', 'yes', 'no']) + expect(object.parameters[3].values).to eq(%w[true false yes no]) expect(object.parameters[3].aliases).to eq({}) expect(object.parameters[4].name).to eq('backup') expect(object.parameters[4].docstring).to eq('How often to backup the database.') expect(object.parameters[4].isnamevar).to be(false) expect(object.parameters[4].default).to eq('never') - expect(object.parameters[4].values).to eq(['daily', 'monthly', 'never']) + expect(object.parameters[4].values).to eq(%w[daily monthly never]) expect(object.features.size).to eq(2) expect(object.features[0].name).to eq('encryption') expect(object.features[0].docstring).to eq('The provider supports encryption.') @@ -248,7 +248,7 @@ expect(object.properties[0].name).to eq('ensure') expect(object.properties[0].docstring).to eq('The basic property that the resource should be in.') expect(object.properties[0].default).to eq('present') - expect(object.properties[0].values).to eq(['present', 'absent']) + expect(object.properties[0].values).to eq(%w[present absent]) end end From 1ee7abd15c8111c0dc0da080c0e78ba90ec8e098 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 14:37:16 +0100 Subject: [PATCH 56/60] (CONT-812) Correct Style/StringConcatenation --- lib/puppet-strings/markdown/base.rb | 4 ++-- lib/puppet-strings/markdown/resource_type.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet-strings/markdown/base.rb b/lib/puppet-strings/markdown/base.rb index 08a2a7c2..5e5e49b1 100644 --- a/lib/puppet-strings/markdown/base.rb +++ b/lib/puppet-strings/markdown/base.rb @@ -161,7 +161,7 @@ def enums # @return [Array] option tag hashes that have a parent parameter_name def options_for_param(parameter_name) opts_for_p = options.select { |o| o[:parent] == parameter_name } unless options.nil? - opts_for_p unless opts_for_p.nil? || opts_for_p.length.zero? + opts_for_p unless opts_for_p.nil? || opts_for_p.empty? end # @param parameter_name @@ -169,7 +169,7 @@ def options_for_param(parameter_name) # @return [Array] enum tag hashes that have a parent parameter_name def enums_for_param(parameter_name) enums_for_p = enums.select { |e| e[:parent] == parameter_name } unless enums.nil? - enums_for_p unless enums_for_p.nil? || enums_for_p.length.zero? + enums_for_p unless enums_for_p.nil? || enums_for_p.empty? end # @return [Hash] any defaults found for the component diff --git a/lib/puppet-strings/markdown/resource_type.rb b/lib/puppet-strings/markdown/resource_type.rb index f2b9e31a..2daf1c19 100644 --- a/lib/puppet-strings/markdown/resource_type.rb +++ b/lib/puppet-strings/markdown/resource_type.rb @@ -50,7 +50,7 @@ def parameters def regex_in_data_type?(data_type) m = data_type.match(%r{\w+\[/.*/\]}) - m unless m.nil? || m.length.zero? + m unless m.nil? || m.empty? end end end From a2566075c7cf1f67fbebd03d25f7b5a88173dee6 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 16:20:53 +0100 Subject: [PATCH 57/60] (CONT-812) Fix spec failures --- lib/puppet-strings.rb | 2 -- lib/puppet-strings/markdown/resource_type.rb | 2 +- lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb | 2 -- lib/puppet-strings/yard/handlers/ruby/type_base.rb | 2 ++ lib/puppet-strings/yard/parsers/puppet/parser.rb | 2 -- 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/puppet-strings.rb b/lib/puppet-strings.rb index d96a7cdd..614a3bc1 100644 --- a/lib/puppet-strings.rb +++ b/lib/puppet-strings.rb @@ -1,5 +1,3 @@ -# rubocop:disable Naming/FileName - # frozen_string_literal: true # The root module for Puppet Strings. diff --git a/lib/puppet-strings/markdown/resource_type.rb b/lib/puppet-strings/markdown/resource_type.rb index 2daf1c19..a25ff7e0 100644 --- a/lib/puppet-strings/markdown/resource_type.rb +++ b/lib/puppet-strings/markdown/resource_type.rb @@ -50,7 +50,7 @@ def parameters def regex_in_data_type?(data_type) m = data_type.match(%r{\w+\[/.*/\]}) - m unless m.nil? || m.empty? + m unless m.nil? || m.to_a.empty? end end end diff --git a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb index 43688e5e..7268d466 100644 --- a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -# rubocop:disable Naming/MethodName - require 'puppet-strings/yard/handlers/helpers' require 'puppet-strings/yard/handlers/ruby/base' require 'puppet-strings/yard/code_objects' diff --git a/lib/puppet-strings/yard/handlers/ruby/type_base.rb b/lib/puppet-strings/yard/handlers/ruby/type_base.rb index 450ac60c..9e1fba87 100644 --- a/lib/puppet-strings/yard/handlers/ruby/type_base.rb +++ b/lib/puppet-strings/yard/handlers/ruby/type_base.rb @@ -116,10 +116,12 @@ def set_values(node, object) next unless node_as_string(kvp[0]) == 'parent' if kvp[1].source == 'Puppet::Parameter::Boolean' + # rubocop:disable Performance/InefficientHashSearch object.add('true') unless object.values.include? 'true' object.add('false') unless object.values.include? 'false' object.add('yes') unless object.values.include? 'yes' object.add('no') unless object.values.include? 'no' + # rubocop:enable Performance/InefficientHashSearch end break end diff --git a/lib/puppet-strings/yard/parsers/puppet/parser.rb b/lib/puppet-strings/yard/parsers/puppet/parser.rb index 46587cb8..a3cadf73 100644 --- a/lib/puppet-strings/yard/parsers/puppet/parser.rb +++ b/lib/puppet-strings/yard/parsers/puppet/parser.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -# rubocop:disable Naming/MethodName - require 'puppet' require 'puppet/pops' require 'puppet-strings/yard/parsers/puppet/statement' From 5b44c36bd65864aeeace125fb34f55581bba4e7d Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 16:24:28 +0100 Subject: [PATCH 58/60] (CONT-812) Clean up redundant files --- COMMITTERS.md | 185 ----------------------------- HISTORY.md | 218 ---------------------------------- codecov.yml | 3 - misc/ANNOUNCEMENT_TEMPLATE.md | 40 ------- 4 files changed, 446 deletions(-) delete mode 100644 COMMITTERS.md delete mode 100644 HISTORY.md delete mode 100644 codecov.yml delete mode 100644 misc/ANNOUNCEMENT_TEMPLATE.md diff --git a/COMMITTERS.md b/COMMITTERS.md deleted file mode 100644 index f0513bf5..00000000 --- a/COMMITTERS.md +++ /dev/null @@ -1,185 +0,0 @@ -Committing changes to Strings -==== - -We would like to make it easier for community members to contribute to strings -using pull requests, even if it makes the task of reviewing and committing -these changes a little harder. Pull requests are only ever based on a single -branch. As a result contributors should target their changes at the main branch. -This makes the process of contributing a little easier for the contributor since -they don't need to concern themselves with the question, "What branch do I base my changes -on?" This is already called out in the [CONTRIBUTING.md](http://goo.gl/XRH2J). - -Therefore, it is the responsibility of the committer to re-base the change set -on the appropriate branch which should receive the contribution. - -It is also the responsibility of the committer to review the change set in an -effort to make sure the end users must opt-in to new behavior that is -incompatible with previous behavior. We employ the use of [feature -flags](http://stackoverflow.com/questions/7707383/what-is-a-feature-flag) as -the primary way to achieve this user opt-in behavior. Finally, it is the -responsibility of the committer to make sure the `main` branch -is clean and working at all times. Clean means that dead code is not -allowed, everything needs to be usable in some manner at all points in time. - -The rest of this document addresses the concerns of the committer. This -document will help guide the committer decide which branch to base, or re-base -a contribution on top of. This document also describes our branch management -strategy, which is closely related to the decision of what branch to commit -changes into. - -Terminology -==== - -Many of these terms have more than one meaning. For the purposes of this -document, the following terms refer to specific things. - -**contributor** - A person who makes a change to strings and submits a change -set in the form of a pull request. - -**change set** - A set of discrete patches which combined together form a -contribution. A change set takes the form of Git commits and is submitted to -strings in the form of a pull request. - -**committer** - A person responsible for reviewing a pull request and then -making the decision what base branch to merge the change set into. - -**base branch** - A branch in Git that contains an active history of changes -and will eventually be released using semantic version guidelines. The branch -named `main` will always exist as a base branch. - -**main branch** - The branch where new functionality that and bug fixes are -merged. - -**security** - Where critical security fixes are merged. These change sets -will then be merged into release branches independently from one another. (i.e. -no merging up). Please do not submit pull requests against the security branch -and instead report all security related issues to security@puppet.com as -per our security policy published at -[https://puppet.com/security/](https://puppet.com/security/). - -Committer Guide -==== - -This section provides a guide to follow while committing change sets to strings -base branches. - -How to decide what release(s) should be patched ---- - -This section provides a guide to help a committer decide the specific base -branch that a change set should be merged into. - -The latest minor release of a major release is the only base branch that should -be patched. These patches will be merged into `main` if they contain new -functionality and if they fix a critical bug. Older minor releases in a major release -do not get patched. - -Before the switch to [semantic versions](http://semver.org/) committers did not -have to think about the difference between minor and major releases. -Committing to the latest minor release of a major release is a policy intended -to limit the number of active base branches that must be managed. - -Security patches are handled as a special case. Security patches may be -applied to earlier minor releases of a major release, but the patches should -first be merged into the `security` branch. Security patches should be merged -by Puppet Labs staff members. Pull requests should not be submitted with the -security branch as the base branch. Please send all security related -information or patches to security@puppet.com as per our [Security -Policy](https://puppet.com/security/). - -The CI systems are configured to run against `main`. Over time, this branch -will refer to different versions, but its name will remain fixed to avoid having -to update CI jobs and tasks as new versions are released. - -Code review checklist ---- - -This section aims to provide a checklist of things to look for when reviewing a -pull request and determining if the change set should be merged into a base -branch: - - * All tests pass - * Are there any platform gotchas? (Does a change make an assumption about - platform specific behavior that is incompatible with other platforms? e.g. - Windows paths vs. POSIX paths.) - * Is the change backwards compatible? (It should be) - * Are there YARD docs for API changes? - * Does the change set also require documentation changes? If so is the - documentation being kept up to date? - * Does the change set include clean code? (software code that is formatted - correctly and in an organized manner so that another coder can easily read - or modify it.) HINT: `git diff main --check` - * Does the change set conform to the contributing guide? - -Commit citizen guidelines: ---- - -This section aims to provide guidelines for being a good commit citizen by -paying attention to our automated build tools. - - * Don’t push on a broken build. (A broken build is defined as a failing job - in [Puppet Strings](https://travis-ci.com/github/puppetlabs/puppet-strings) - page.) - * Watch the build until your changes have gone through green - * Update the ticket status and target version. The target version field in - our issue tracker should be updated to be the next release of Puppet. For - example, if the most recent release of Puppet is 3.1.1 and you merge a - backwards compatible change set into main, then the target version should - be 3.2.0 in the issue tracker.) - * Ensure the pull request is closed (Hint: amend your merge commit to contain - the string `closes #123` where 123 is the pull request number and github - will automatically close the pull request when the branch is pushed.) - -Example Procedure -==== - -This section helps a committer rebase and merge a contribution into the base branch. - -Suppose a contributor submits a pull request based on main. The change set -fixes a bug reported against strings 0.1.0 which is the most recently released -version of strings. - -First, the committer pulls down the branch using the `hub` gem. This tool -automates the process of adding the remote repository and creating a local -branch to track the remote branch. - - $ hub checkout https://github.com/puppetlabs/puppet-strings/pull/123 - Branch jeffmccune-pdoc-34_fix_foo_error set up to track remote branch pdoc-34-fix_foo_error from jeffmccune. - Switched to a new branch 'jeffmccune-pdoc-34_fix_foo_error' - -It's possible that more changes have been merged into main since the pull -request was submitted. In this case it may be necessary to rebase the branch -that contains the changes: - - $ git rebase upstream/main - -After the branch has been checked out and rebased, the committer should ensure that -the code review check list has been completed. - -Now that we have a topic branch containing the change set based on the most recent -`main` branch, the committer merges in: - - $ git checkout main - Switched to branch 'main' - $ git merge --no-ff --log jeffmccune-pdoc-34_fix_foo_error - Merge made by the 'recursive' strategy. - foo | 0 - 1 file changed, 0 insertions(+), 0 deletions(-) - create mode 100644 foo - -Once the change set has been merged into one base branch, the change set should -not be modified in order to keep the history clean, avoid "double" commits, and -preserve the usefulness of `git branch --contains`. If there are any merge -conflicts, they are to be resolved in the merge commit itself and not by -re-writing (rebasing) the patches for one base branch, but not another. - -Once the change set has been merged into `main`, the committer pushes. -Please note, the checklist should be complete at this point. It's helpful to make -sure your local branches are up to date to avoid one of the branches failing to fast -forward while the other succeeds. - - $ git push origin main:main - -That's it! The committer then updates the pull request, updates the issue in -our issue tracker, and keeps an eye on the [build -status](http://jenkins.puppetlabs.com). diff --git a/HISTORY.md b/HISTORY.md deleted file mode 100644 index 57364a8f..00000000 --- a/HISTORY.md +++ /dev/null @@ -1,218 +0,0 @@ -# Previous Changes - -## [2.0.0](https://github.com/puppetlabs/puppet-strings/tree/2.0.0) (2018-05-11) - -[Full Changelog](https://github.com/puppetlabs/puppet-strings/compare/1.2.1...2.0.0) - -### Changed - -- bump required ruby and puppet versions [\#178](https://github.com/puppetlabs/puppet-strings/pull/178) ([eputnam](https://github.com/eputnam)) - -### Added - -- \(PDOC-238\) add generated message to markdown [\#175](https://github.com/puppetlabs/puppet-strings/pull/175) ([eputnam](https://github.com/eputnam)) -- \(PDOC-228\) puppet plan support [\#168](https://github.com/puppetlabs/puppet-strings/pull/168) ([eputnam](https://github.com/eputnam)) -- \(PDOC-206\) support for tasks [\#161](https://github.com/puppetlabs/puppet-strings/pull/161) ([eputnam](https://github.com/eputnam)) - -### Fixed - -- \(PDOC-36\) fix hack for README urls [\#176](https://github.com/puppetlabs/puppet-strings/pull/176) ([eputnam](https://github.com/eputnam)) -- \(PDOC-240\) add handling for :array node type in rsapi\_handler [\#174](https://github.com/puppetlabs/puppet-strings/pull/174) ([eputnam](https://github.com/eputnam)) -- \(PDOC-159\) server urls fix [\#173](https://github.com/puppetlabs/puppet-strings/pull/173) ([eputnam](https://github.com/eputnam)) -- \(maint\) display Plans in markdown table of contents [\#171](https://github.com/puppetlabs/puppet-strings/pull/171) ([eputnam](https://github.com/eputnam)) -- \(PDOC-233\) markdown whitespace fixes [\#170](https://github.com/puppetlabs/puppet-strings/pull/170) ([JohnLyman](https://github.com/JohnLyman)) -- \(PDOC-229\) fix error with return\_type and @return [\#169](https://github.com/puppetlabs/puppet-strings/pull/169) ([eputnam](https://github.com/eputnam)) -- \(PDOC-36\) hack to fix README links in generated HTML [\#167](https://github.com/puppetlabs/puppet-strings/pull/167) ([eputnam](https://github.com/eputnam)) -- \(PDOC-192\) remove warning for title/name [\#166](https://github.com/puppetlabs/puppet-strings/pull/166) ([eputnam](https://github.com/eputnam)) -- \(maint\) add condition for misleading warning [\#155](https://github.com/puppetlabs/puppet-strings/pull/155) ([eputnam](https://github.com/eputnam)) - -## [1.2.1](https://github.com/puppetlabs/puppet-strings/tree/1.2.1) (2018-03-01) - -[Full Changelog](https://github.com/puppetlabs/puppet-strings/compare/1.2.0...1.2.1) - -### Fixed - -- (PDOC-224) Handle --emit-json(-stdout) again [\#162](https://github.com/puppetlabs/puppet-strings/pull/162) ([ekohl](https://github.com/ekohl)) - -## [1.2.0](https://github.com/puppetlabs/puppet-strings/tree/1.2.0) (2018-02-26) - -[Full Changelog](https://github.com/puppetlabs/puppet-strings/compare/1.1.1...1.2.0) - -### Added - -- \(PDOC-184\) generate markdown [\#156](https://github.com/puppetlabs/puppet-strings/pull/156) ([eputnam](https://github.com/eputnam)) -- \(PDK-437\) Add support for Resource API types [\#153](https://github.com/puppetlabs/puppet-strings/pull/153) ([DavidS](https://github.com/DavidS)) - -### Fixed - -- Fix return type matching for Puppet functions [\#159](https://github.com/puppetlabs/puppet-strings/pull/159) ([pegasd](https://github.com/pegasd)) -- Add rgen as a runtime dependency [\#149](https://github.com/puppetlabs/puppet-strings/pull/149) ([rnelson0](https://github.com/rnelson0)) - -## 2017-10-20 - Release 1.1.1 - -### BugFixes -- Remove timestamps from footer of generated HTML pages ([GeoffWilliams](https://github.com/GeoffWilliams)) -- Fix argument handling for `rake strings::generate` ([hashar](https://github.com/hashar)) - -### Other -- Fixed Markdown formatting issues in CHANGELOG ([maju6406](https://github.com/maju6406)) -- Fixed typo in README ([hfm](https://github.com/hfm)) -- Fixed Markdown formatting issues in README ([gguillotte](https://github.com/gguillotte)) -- Update Travis CI configurations for Ruby and Puppet versions ([ghoneycutt](https://github.com/ghoneycutt)) - -## 2017-03-20 - Release 1.1.0 - -### Summary - -This release adds a new `summary` tag which can be used to add a short description to classes, functions, types, and providers. In addition, `@param` tags can now include type information in Puppet 4 code without warnings being issued. - -All related tickets can be found under the [PDOC](https://tickets.puppetlabs.com/browse/PDOC) JIRA project with the fix version of [1.1.0](https://tickets.puppetlabs.com/issues/?filter=25603). - -### Features -- The `summary` tag can be added to any code that puppet-strings supports. The recommended length limit for a summary is 140 characters. Warnings will be issued for strings longer than this limit. -- Puppet 4 parameter types can now be explicitly documented. Previously, this was not allowed because Puppet 4 parameter types can be automatically determined without extra documentation. However, users may desire to do so anyway for consistency. Strings will emit a warning if the documented type does not match the actual type. In such an event, the incorrect documented type will be ignored in favor of the real one. - -## 2016-11-28 - Release 1.0.0 - -### Summary - -This release fixes up minor bugs from the 0.99.0 release and modifies the JSON schema for Puppet functions. - -All related tickets can be found under the [PDOC](https://tickets.puppetlabs.com/browse/PDOC) JIRA project with the fix version of [1.0.0](https://tickets.puppetlabs.com/issues/?filter=23607). - -### Features -- The JSON schema for Puppet functions has been altered to include a new 'signatures' top-level key **(PDOC-125)** - - Includes information about all function signatures (overloads). Existing overload key format has been preserved. -- Reworked README for enhanced clarity **(PDOC-133)** - -### BugFixes -- Fixed an issue where the search box in the code navigator overlapped list items below it **(PDOC-93)** -- Strings can now handle multiple `defaultfor` calls in Puppet providers **(PDOC-95)** -- Fixed an issue preventing the generated \_index.html file from being uploaded to GitHub pages via the gh_pages task **(PDOC-120)** -- Fixed several issues with String's handling of Puppet 3.x and 4.x function return types **(PDOC-135)**, **(PDOC-136)** -- Fixed an issue where String's didn't properly parse overloads if no summary description was provided **(PDOC-129)** -- Strings now correctly handles Puppet 3.x functions when the `newfunction` call is on a newline **(PDOC-122)** -- Fixed an issue where certain Ruby string constructs were incompletely stripped from some docstrings **(PDOC-126)** -- Hanging indents from type feature descriptions are now properly stripped **(PDOC-127)** - -## 2016-10-10 - Release 0.99.0 - -### Summary - -This release includes a complete rewrite of strings, fixing many bugs from previous versions and generally improving the user experience. This release is intended to be the last stop before the strings major version 1.0 is released, and nearly all of the functionality of the major release is included. - -All related tickets can be found under the [PDOC][PDOC JIRA] JIRA project with the fix version of [0.99.0](https://tickets.puppetlabs.com/issues/?filter=22705). - -### Features -- Complete overhaul, including code cleanup, bug fixes and new functionality **(PDOC-63)** - - Documentation has been split into sections based on type: puppet 3x API functions, puppet 4x API functions, ruby classes, puppet language functions, types, and providers - - New JSON schema organized to reflect the separation of types - - Support for custom functions written in the puppet language - - Support for puppet function overloads via the create_function 4.x API - - YARD bumped to latest version, 0.9.5 -- Markdown is now the default format for parsing docstring text **(PDOC-86)** - - Note: this means Markdown text in YARD comments and tags, not a change in the output of strings -- New commandline options: --emit-json and --emit-json-stdout to generate JSON documentation **(PDOC-84)** -- Runtime dependency on Puppet has been removed, allowing strings to function in Puppet Enterprise 3.8 **(PDOC-80)** - - Note that the gem still requires puppet. We recommend that the strings gem be installed with puppet, as suggested in the [README](https://github.com/puppetlabs/puppet-strings/blob/main/README.md#installing-puppet-strings) -- New gemspec requirement on Ruby version 1.9.3, the oldest supported Ruby version - -### BugFixes - -- Prevents a blizzard of errors when documenting Puppet Core source and some puppet modules **(PDOC-63)** - - As this is a complete rewrite, many known and unknown bugs from the original code were fixed along the way -- Allow strings to be installed in PE 3.8 without overwriting existing puppet and facter installations with newer gems - -## 2016-03-30 - Release 0.4.0 - -### Summary - -This release adds JSON output support for strings, fixes a major bug that prevented strings from working with the 4.4.0 release of puppet, and is the last version of strings that will be released as a module. - -All related tickets can be found under the [PDOC][PDOC JIRA] JIRA project with the fix version of [0.4.0](https://tickets.puppetlabs.com/issues/?filter=18810). - -### Features -- Support for JSON output **(PDOC-23)** - - Strings now has the ability to produce a JSON representation of a given puppet module - - The details of the JSON schema can be found [here](https://github.com/puppetlabs/puppet-strings/blob/main/json_dom.md) - - For details on how to generate JSON, see the [README](https://github.com/puppetlabs/puppet-strings/blob/main/README.md#running-puppet-strings) -- Migrate to ruby gems as a distribution method **(PDOC-28)** - - This is the last release of strings that will be available as a puppet module - - The 0.4.0 release will be released concurrently as a ruby gem - - After this release, all updates will only be available via the gem - -### Bugfixes - -- Fix issue that prevented strings from running with Puppet 4.4.0 **(PDOC-75)** - -## 2015-09-22 - Release 0.3.1 - -### Summary - -This is a minor bug fix release. - -All related tickets can be found under the [PDOC][PDOC JIRA] JIRA project with the fix version of [0.3.1](https://tickets.puppetlabs.com/issues/?filter=15530). - -### Bugfixes - -- Prevent strings from printing unnecessary quotes in error messages **(PDOC-57)** -- Issue correct type check warnings for defined types **(PDOC-56)** -- Allow providers, types, and defines to have the same name **(PDOC-54)** - -## 2015-09-21 - Release 0.3.0 - -### Summary - -This release includes support for Puppet Types and Providers, as well as -type checking Puppet 4x functions and defined types. - -All related tickets can be found under the [PDOC][PDOC JIRA] JIRA project with -the fix version of [0.3.0](https://tickets.puppetlabs.com/issues/?filter=15529). - -#### Features - -- Support for Puppet Types and Providers **(PDOC-35)** -- Type check Puppet 4x functions and defined types where possible and warn the user when types don't match. - - Type check defined types **(PDOC-21)** - - Type check Puppet 4x functions **(PDOC-38)** **(PDOC-19)** **(PDOC-37)** - - Output type info in generated HTML **(PDOC-19)** -- Improved warnings and logging. - - Create a consistent style for warnings. **(PDOC-49)** - - All warnings get printed on stderr. - - Yard warnings are redirected to a log file **(PDOC-38)** - - Prevent duplicate warnings **(PDOC-38)** -- Improved README installation and usage instructions. - - Installation instructions using Puppet **(PDOC-33)** - - -#### Bugfixes - -- Fix markdown list processing **(PDOC-30)** -- Fix namespacing for nested classes and defined types **(PDOC-20)** - - -## 2015-03-17 - Release 0.2.0 - -### Summary - -This release includes improvements to the HTML output generated by strings and a few bug fixes. -All related tickets can be found under the [PDOC][PDOC JIRA] JIRA project with the fix version of [0.2.0](https://tickets.puppetlabs.com/issues/?filter=13760). - -[PDOC JIRA]: https://tickets.puppetlabs.com/browse/PDOC - -#### Features -- Custom YARD templates for classes and defined types **(PDOC-17)** - - Improved HMTL output that is more appropriate for Puppet code (especially for parameters) - - Support for the explicit list of YARD tags we will be supporting initially (@param, @return, @since, @example) - - Our own custom YARD templates which can be easily extended and tweaked - -- Custom YARD templates for 3.x and 4.x functions **(PDOC-24)** - - Improved HMTL output that is more appropriate for listing several functions on one webpage in addition to being more consistent with the HTML produced for classes and defined types. - - Support for the explicit list of YARD tags we will be supporting initially (@param, @return, @since, @example) - - Our own custom YARD templates which can be easily extended and tweaked -- Addition of RubCop Travis CI job to ensure code quality and consistency **(PDOC-8)** - -#### Bugfixes -- Puppet namespaces are no longer mangled for nested classes and defined types **(PDOC-25)** -- Strings is now compatible with the renaming of the Puppetx/puppetx namespace to PuppetX/puppet_x **(PDOC-26)** -- Strings will no longer crash when documenting 3x functions with less than two arguments passed into newfunction **(PDOC-27)** diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index fd43b715..00000000 --- a/codecov.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -# disable comments, info can be gotten from the pr status updates, and the comment editing spams the hipchat notifications -comment: false diff --git a/misc/ANNOUNCEMENT_TEMPLATE.md b/misc/ANNOUNCEMENT_TEMPLATE.md deleted file mode 100644 index c395ec73..00000000 --- a/misc/ANNOUNCEMENT_TEMPLATE.md +++ /dev/null @@ -1,40 +0,0 @@ -Send out announcements for major new feature releases, and high-impact bugfixes to , , , , and the puppet internal mailing lists and . - -Before sending, do check that all links are still valid. Feel free to adjust the text to match better with the circumstances of the release, or add other news that are relevant at the time. If you make changes, consider committing them here, for the benefit of future-you. - -The github rendering of the markdown seems to copy&paste acceptably into Google Inbox. - -The [CHANGELOG](https://github.com/puppetlabs/puppet-strings/blob/main/CHANGELOG.md) is a good starting point for finding enhancements and bug-fixes. - ---- - -Subject: [ANN] Puppet Strings vX.Y.Z Release - -Hi all, - -We're pleased to announce that version X.Y.Z of the Puppet Strings is being released today. - -Puppet Strings provides a simple way to extract source documentation into useful docs. It is provided as a Ruby gem to be referenced within modules. See the [README](https://github.com/puppetlabs/puppet-strings#installing-puppet-strings) for documentation on how to install and use it. - - -The new release of Puppet Strings provides the following enhancements: - -* A -* B -* C - -The new release also contains the following notable bugfixes: - -* D -* E -* F - -See the [CHANGELOG](https://github.com/puppetlabs/puppet-strings/blob/main/CHANGELOG.md) for a full list of changes - -We encourage all module developers to review puppet-strings and use it when creating modules. - -Please let us know of your experiences with Puppet Strings, either here, on [Slack](https://slack.puppet.com/) (#forge-modules), or on the [github repo](https://github.com/puppetlabs/puppet-strings). - - -Thanks, -YOUR NAME From 0e077a3c3fa03e1bd68beec36e91985c0a76850c Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 16:35:42 +0100 Subject: [PATCH 59/60] (CONT-812) Remove Puppet 5 check for plans --- lib/puppet-strings/yard/parsers/puppet/parser.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/puppet-strings/yard/parsers/puppet/parser.rb b/lib/puppet-strings/yard/parsers/puppet/parser.rb index a3cadf73..98f4e302 100644 --- a/lib/puppet-strings/yard/parsers/puppet/parser.rb +++ b/lib/puppet-strings/yard/parsers/puppet/parser.rb @@ -22,10 +22,6 @@ def initialize(source, filename) # rubocop:disable Lint/MissingSuper # @return [void] def parse begin - if @file.to_s.match?(%r{^plans|/plans/}) && Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0').negative? - log.warn "Skipping #{@file}: Puppet Plans require Puppet 5 or greater." - return - end Puppet[:tasks] = true if Puppet.settings.include?(:tasks) @statements ||= (@visitor.visit(::Puppet::Pops::Parser::Parser.new.parse_string(source)) || []).compact rescue ::Puppet::ParseError => e From fc22265046fbd04e3f86df3e773f6828591896e3 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Mon, 17 Apr 2023 16:56:27 +0100 Subject: [PATCH 60/60] (CONT-812) Ensure that @alias_of is mutable --- lib/puppet-strings/yard/parsers/puppet/statement.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet-strings/yard/parsers/puppet/statement.rb b/lib/puppet-strings/yard/parsers/puppet/statement.rb index 2420bb20..07102494 100644 --- a/lib/puppet-strings/yard/parsers/puppet/statement.rb +++ b/lib/puppet-strings/yard/parsers/puppet/statement.rb @@ -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 = +"#{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