[PDK-1070] PDK validate doesn't seem to honor rubocop excludes Created: 2018/07/10  Updated: 2019/02/25  Resolved: 2019/02/25

Status: Closed
Project: Puppet Development Kit
Component/s: None
Affects Version/s: PDK 1.6.0
Fix Version/s: None

Type: Bug Priority: Normal
Reporter: Glenn Sarti Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 10 - 1803
PDK - 1.6.0.0


Issue Links:
Relates
relates to MODULES-7047 windows : pdk convert the module Resolved
relates to PDK-654 `pdk validate ruby` ignores .rubocop.... Closed
Template:
Acceptance Criteria:
  • pdk validate should raise violations the same as a raw call to rubocop would
Method Found: Needs Assessment
Release Notes: Not Needed
Release Notes Summary: Duplicate
QA Risk Assessment: Needs Assessment

 Description   

The pdk validate command is throwing rubocop errors for files that are excluded via the rubocop.yml configuration file. Running rubocop separately finds no errors, as expected. This appears to be a bug in the PDK.



 Comments   
Comment by Glenn Sarti [ 2018/07/10 ]

This is after pdk convert on the windows module

https://github.com/puppetlabs/puppetlabs-windows/commit/286ab4d7141d8de7113dc89f0366ef7527b91c3f

Raw Rubocop

C:\Source\puppetlabs-windows [modules-7047-pdkify +2 ~7 -0 !]> be rubocop
Inspecting 3 files
C.C
 
Offenses:
 
spec/acceptance/can_install_spec.rb:6:25: C: Style/GlobalVars: Do not introduce global variables.
    pkg_dir = File.join($proj_root, 'pkg')
                        ^^^^^^^^^^
spec/acceptance/can_install_spec.rb:11:15: C: Style/GlobalVars: Do not introduce global variables.
    Dir.chdir($proj_root) do
              ^^^^^^^^^^
spec/acceptance/can_install_spec.rb:12:7: C: Style/CommandLiteral: Use backticks around command string.
      %x( puppet module build )
      ^^^^^^^^^^^^^^^^^^^^^^^^^
spec/acceptance/can_install_spec.rb:12:10: C: Layout/SpaceInsidePercentLiteralDelimiters: Do not use spaces inside percent literal delimiters.
      %x( puppet module build )
         ^
spec/acceptance/can_install_spec.rb:12:30: C: Layout/SpaceInsidePercentLiteralDelimiters: Do not use spaces inside percent literal delimiters.
      %x( puppet module build )
                             ^
spec/acceptance/can_install_spec.rb:17:11: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    raise "Failed to build the Windows module locally" if @module_tarball.nil?
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/acceptance/can_install_spec.rb:17:59: C: RSpec/InstanceVariable: Use let instead of an instance variable.
    raise "Failed to build the Windows module locally" if @module_tarball.nil?
                                                          ^^^^^^^^^^^^^^^
spec/acceptance/can_install_spec.rb:25:20: C: RSpec/InstanceVariable: Use let instead of an instance variable.
      scp_to host, @module_tarball, tmp_path
                   ^^^^^^^^^^^^^^^
spec/acceptance/can_install_spec.rb:31:23: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      on(host, puppet("module list")) do |result|
                      ^^^^^^^^^^^^^
spec/acceptance/can_install_spec.rb:32:40: C: Style/RegexpLiteral: Use %r around regular expression.
        expect(result.stdout).to match(/puppetlabs-windows/)
                                       ^^^^^^^^^^^^^^^^^^^^
spec/acceptance/can_install_spec.rb:36:23: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      on(host, puppet("module list")) do |result|
                      ^^^^^^^^^^^^^
spec/acceptance/can_install_spec.rb:37:9: C: RSpec/NotToNot: Prefer not_to over to_not.
        expect(result.stderr).to_not match(/Missing dependency/)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/acceptance/can_install_spec.rb:37:44: C: Style/RegexpLiteral: Use %r around regular expression.
        expect(result.stderr).to_not match(/Missing dependency/)
                                           ^^^^^^^^^^^^^^^^^^^^
spec/spec_helper_acceptance.rb:7:1: C: Style/GlobalVars: Do not introduce global variables.
$proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
^^^^^^^^^^
 
3 files inspected, 14 offenses detected

pdk validate (Note the 'pkg/..' violations)

C:\Source\puppetlabs-windows [modules-7047-pdkify +2 ~7 -0 !]> pdk validate
pdk (INFO): Running all available validators...
pdk (INFO): Using Ruby 2.1.9
pdk (INFO): Using Puppet 4.10.11
[*] Checking metadata syntax (metadata.json tasks/*.json).
[*] Checking module metadata style (metadata.json).
[X] Checking Ruby code style (**/**.rb).
info: task-metadata-lint: ./: Target does not contain any files to validate (tasks/*.json).
info: puppet-syntax: ./: Target does not contain any files to validate (**/**.pp).
info: puppet-lint: ./: Target does not contain any files to validate (**/*.pp).
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:5:3: RSpec/BeforeAfterAll: Beware of using `before(:all)` as it may cause state to leak between tests. If you are using `rspec-rails`, and `use_transactional_fixtures` is enabled, then records created in `before(:all)` are not automatically rolled back.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:6:25: Style/GlobalVars: Do not introduce global variables.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:11:15: Style/GlobalVars: Do not introduce global variables.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:12:7: Style/CommandLiteral: Use backticks around command string.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:12:10: Layout/SpaceInsidePercentLiteralDelimiters: Do not use spaces inside percent literal delimiters.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:12:30: Layout/SpaceInsidePercentLiteralDelimiters: Do not use spaces inside percent literal delimiters.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:17:11: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:17:59: RSpec/InstanceVariable: Use `let` instead of an instance variable.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:25:20: RSpec/InstanceVariable: Use `let` instead of an instance variable.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:27:1: Layout/EmptyLines: Extra blank line detected.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:28:1: Layout/IndentationConsistency: Inconsistent indentation detected.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:28:14: Style/Semicolon: Do not use semicolons to terminate expressions.
warning: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:28:16: Lint/Debugger: Remove debugger entry point `binding.pry`.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:29:1: Layout/IndentationConsistency: Inconsistent indentation detected.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:29:6: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:35:23: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:36:40: Style/RegexpLiteral: Use `%r` around regular expression.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:40:23: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:41:9: RSpec/NotToNot: Prefer `not_to` over `to_not`.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/acceptance/can_install_spec.rb:41:44: Style/RegexpLiteral: Use `%r` around regular expression.
convention: rubocop: pkg/puppetlabs-windows-5.0.0/spec/spec_helper_acceptance.rb:7:1: Style/GlobalVars: Do not introduce global variables.
convention: rubocop: spec/acceptance/can_install_spec.rb:6:25: Style/GlobalVars: Do not introduce global variables.
convention: rubocop: spec/acceptance/can_install_spec.rb:11:15: Style/GlobalVars: Do not introduce global variables.
convention: rubocop: spec/acceptance/can_install_spec.rb:12:7: Style/CommandLiteral: Use backticks around command string.
convention: rubocop: spec/acceptance/can_install_spec.rb:12:10: Layout/SpaceInsidePercentLiteralDelimiters: Do not use spaces inside percent literal delimiters.
convention: rubocop: spec/acceptance/can_install_spec.rb:12:30: Layout/SpaceInsidePercentLiteralDelimiters: Do not use spaces inside percent literal delimiters.
convention: rubocop: spec/acceptance/can_install_spec.rb:17:11: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
convention: rubocop: spec/acceptance/can_install_spec.rb:17:59: RSpec/InstanceVariable: Use `let` instead of an instance variable.
convention: rubocop: spec/acceptance/can_install_spec.rb:25:20: RSpec/InstanceVariable: Use `let` instead of an instance variable.
convention: rubocop: spec/acceptance/can_install_spec.rb:31:23: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
convention: rubocop: spec/acceptance/can_install_spec.rb:32:40: Style/RegexpLiteral: Use `%r` around regular expression.
convention: rubocop: spec/acceptance/can_install_spec.rb:36:23: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
convention: rubocop: spec/acceptance/can_install_spec.rb:37:9: RSpec/NotToNot: Prefer `not_to` over `to_not`.
convention: rubocop: spec/acceptance/can_install_spec.rb:37:44: Style/RegexpLiteral: Use `%r` around regular expression.
convention: rubocop: spec/spec_helper_acceptance.rb:7:1: Style/GlobalVars: Do not introduce global variables.

RUbocop.yml

---
require: rubocop-rspec
AllCops:
  DisplayCopNames: true
  TargetRubyVersion: '2.1'
  Include:
  - "./**/*.rb"
  Exclude:
  - bin/*
  - ".vendor/**/*"
  - "**/Gemfile"
  - "**/Rakefile"
  - pkg/**/*
  - spec/fixtures/**/*
  - vendor/**/*
  - "**/Puppetfile"
  - "**/Vagrantfile"
  - "**/Guardfile"
Metrics/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.
...

Comment by Tim Sharpe [ 2019/02/25 ]

I missed this one when collecting all the PDK-654 duplicates.

Generated at Thu Nov 14 01:26:39 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.