Uploaded image for project: 'Puppet Development Kit'
  1. Puppet Development Kit
  2. PDK-654

`pdk validate ruby` ignores .rubocop.yml and includes files in `spec/fixtures`

    XMLWordPrintable

    Details

    • Template:
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      Prior to this fix, running pdk validate without any targets caused the subsequent rubocop call to ignore the rubycop.yml excludes due to the fact that we passed in a list of files from a globbed list. This has been fixed and the ruby validator will now honor the excludes in the rubocop.yml.
      Show
      Prior to this fix, running pdk validate without any targets caused the subsequent rubocop call to ignore the rubycop.yml excludes due to the fact that we passed in a list of files from a globbed list. This has been fixed and the ruby validator will now honor the excludes in the rubocop.yml.
    • QA Risk Assessment:
      Needs Assessment

      Description

      Fixtures downloaded as part of the unit tests (in `spec/fixtures/`) are getting caught up in the Ruby validation tests. It seems that the PDK call to `rubocop` is passing in a full list of all .rb files, instead of using the generated `.rubocop.yml` file, which correctly excludes files from `spec/fixtures`. I've tested that this works on fresh modules created with PDK as well as one I've converted to use the PDK.

      This is especially annoying as it is picking up the numerous violations from the `puppetlabs/apt` module.

      For now, I can just nuke `spec/fixtures` as a work around when running validation tests, but that's definitely a workaround and likely not the intended workflow.

      Snippet from the debug output from `pdk validate ruby --debug`:

      pdk (DEBUG): Execution of '[MODULE_ROOT]/bin/rubocop --format json [MODULE_ROOT]/lib/puppet/type/EXAMPLE_TYPE.rb [MODULE_ROOT]/spec/fixtures/modules/apt/lib/puppet_x/apt_key/patch_openuri.rb [MODULE_ROOT]/spec/fixtures/modules/apt/lib/puppet/type/apt_key.rb [MODULE_ROOT]/spec/fixtures/modules/apt/lib/puppet/provider/apt_key/apt_key.rb [MODULE_ROOT]/spec/fixtures/modules/apt/lib/facter/apt_update_last_success.rb [MODULE_ROOT]/spec/fixtures/modules/apt/lib/facter/apt_reboot_required.rb [MODULE_ROOT]/spec/fixtures/modules/apt/lib/facter/apt_updates.rb [MODULE_ROOT]/spec/fixtures/modules/apt/tasks/init.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/spec_helper_acceptance.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/spec_helper.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/unit/puppet/type/apt_key_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/unit/facter/apt_update_last_success_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/unit/facter/apt_reboot_required_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/unit/facter/apt_updates_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/unit/facter/apt_has_updates_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/unit/facter/apt_package_updates_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/unit/facter/apt_security_updates_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/unit/facter/apt_package_security_updates_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/defines/key_compat_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/defines/source_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/defines/setting_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/defines/ppa_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/defines/source_compat_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/defines/key_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/defines/pin_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/defines/conf_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/classes/apt_backports_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/classes/apt_update_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/classes/apt_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/acceptance/apt_key_provider_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/acceptance/init_task_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/acceptance/apt_spec.rb [MODULE_ROOT]/spec/fixtures/modules/apt/spec/acceptance/class_spec.rb [MODULE_ROOT]/spec/spec_helper.rb [MODULE_ROOT]/spec/classes/init_spec.rb complete (duration: 0.687284496s; exit code: 1)
      convention: rubocop: spec/fixtures/modules/apt/lib/puppet_x/apt_key/patch_openuri.rb:5:8: Use compact module/class definition instead of nested style.
      warning: rubocop: spec/fixtures/modules/apt/lib/puppet_x/apt_key/patch_openuri.rb:19:23: Assignment in condition - you probably meant to use `==`.
      convention: rubocop: spec/fixtures/modules/apt/lib/puppet/type/apt_key.rb:51:15: Use `%r` around regular expression.
      

      Relevant section from `.rubocop.yml`:

      AllCops:
        TargetRubyVersion: '2.1'
        Include:
        - "./**/*.rb"
        Exclude:
        - bin/*
        - ".vendor/**/*"
        - Gemfile
        - Rakefile
        - pkg/**/*
        - spec/fixtures/**/*
        - vendor/**/*
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tim.sharpe Tim Sharpe
              Reporter:
              brwyatt Bryan Wyatt
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support