[PDK-1202] The Rakefile config for puppet-lint still displays warnings for disabled checks (though the exit status is 0) unless .puppet-lint.rc also disables the checks Created: 2018/10/17  Updated: 2019/01/24  Resolved: 2018/12/17

Status: Resolved
Project: Puppet Development Kit
Component/s: None
Affects Version/s: None
Fix Version/s: PDK 1.9.0

Type: Bug Priority: Normal
Reporter: Rob Nelson Assignee: Tim Sharpe
Resolution: Fixed Votes: 0
Labels: resolved-issue-added
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Method Found: Needs Assessment
Release Notes: Bug Fix
Release Notes Summary: This fixes a bug in PDK that did not honor the puppet-lint configurations specified in the Rakefile, since PDK doesn't call the rake command and executes puppet-lint directly. With this fix, the Rakefile configuration options for puppet-lint set up in the default template config and .sync.yml will be honored by PDK when calling puppet-lint.
QA Risk Assessment: Needs Assessment

 Description   

I do not use the 140chars or arrow_alignment puppet-lint checks. I have configured the PDK templates to ignore those checks per https://github.com/puppetlabs/pdk-templates#rakefile. There is no .puppet-lint.rc file. These checks still generate warnings:

[rn7284@chi-build06 controlrepo:production±]$ grep Rakefile -A3 .sync.yml
Rakefile:
  default_disabled_lint_checks:
    - '140chars'
    - 'arrow_alignment' 
[rn7284@chi-build06 controlrepo:production±]$ grep Lint Rakefile
PuppetLint.configuration.send('disable_relative')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.send('disable_arrow_alignment')
[rn7284@chi-build06 controlrepo:production±]$ cat .puppet-lint.rc
cat: .puppet-lint.rc: No such file or directory
[rn7284@chi-build06 controlrepo:production±]$ pdk validate
pdk (INFO): Running all available validators...
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2
[✔] Checking metadata syntax (metadata.json tasks/*.json).
[✔] Checking module metadata style (metadata.json).
[✔] Checking Puppet manifest syntax (**/**.pp).
[✔] Checking Puppet manifest style (**/*.pp).
[✔] Checking Ruby code style (**/**.rb).
info: task-metadata-lint: ./: Target does not contain any files to validate (tasks/*.json).
warning: puppet-lint: dist/eyaml/manifests/init.pp:43:12: indentation of => is not properly aligned (expected in column 14, but found it in column 12)
warning: puppet-lint: dist/eyaml/manifests/init.pp:51:11: indentation of => is not properly aligned (expected in column 12, but found it in column 11)
warning: puppet-lint: dist/eyaml/manifests/init.pp:52:11: indentation of => is not properly aligned (expected in column 12, but found it in column 11)
<...>

Only when I create a .puppet-lint.rc file do the warnings disappear:

[rn7284@chi-build06 controlrepo:production]$ cat .puppet-lint.rc
--no-arrow_alignment-check
--no-140chars-check
[rn7284@chi-build06 controlrepo:production]$ pdk validate
pdk (INFO): Running all available validators...
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2
[✔] Checking metadata syntax (metadata.json tasks/*.json).
[✔] Checking module metadata style (metadata.json).
[✔] Checking Puppet manifest syntax (**/**.pp).
[✔] Checking Puppet manifest style (**/*.pp).
[✔] Checking Ruby code style (**/**.rb).
info: task-metadata-lint: ./: Target does not contain any files to validate (tasks/*.json).
[rn7284@chi-build06 controlrepo:production]$ 

The Rakefile settings ONLY affect the rake task lint, and do not affect either pdk validate or calling puppet-lint directly:

[rn7284@chi-build06 controlrepo:production]$ rm .puppet-lint.rc
[rn7284@chi-build06 controlrepo:production±]$ pdk bundle exec puppet-lint dist/profile/manifests/base/linux.pp
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2
WARNING: indentation of => is not properly aligned (expected in column 23, but found it in column 14) on line 97
WARNING: indentation of => is not properly aligned (expected in column 23, but found it in column 16) on line 98
WARNING: indentation of => is not properly aligned (expected in column 23, but found it in column 16) on line 99
WARNING: indentation of => is not properly aligned (expected in column 23, but found it in column 16) on line 100
WARNING: indentation of => is not properly aligned (expected in column 23, but found it in column 16) on line 101
WARNING: indentation of => is not properly aligned (expected in column 23, but found it in column 17) on line 102
WARNING: indentation of => is not properly aligned (expected in column 14, but found it in column 12) on line 122
WARNING: indentation of => is not properly aligned (expected in column 14, but found it in column 12) on line 123
WARNING: indentation of => is not properly aligned (expected in column 14, but found it in column 13) on line 124
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 176
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 178
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 12) on line 179
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 187
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 12) on line 188
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 13) on line 191
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 194
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 12) on line 195[rn7284@chi-build06 controlrepo:production±]$ pdk bundle exec rake lint
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2
 
 
[rn7284@chi-build06 controlrepo:production±]$ 

I expect to only have to configure the disabled checks in one place, and it was suggested on slack that this current behavior is unintended.



 Comments   
Comment by Bryan Jen [ 2018/11/14 ]

Rob Nelson Thanks for the bug report. This is because PDK doesn't use the Rake task for linting puppet, we call puppet-lint directly. Since that is documented in the templates as a way to configure your linter, we will honor that and fix it in a future version of PDK.

Comment by Bryan Jen [ 2018/11/14 ]

In the meantime, the workaround for this bug is to manually maintain the puppet-lint rc file.

Comment by Mikhail [ 2018/12/18 ]

Hello. I've tried to use this feature, but it seems to not work.

.sync.yml:
Rakefile:
  default_disabled_lint_checks:
    - selector_inside_resource
    - relative
 
.puppet-lint.rc:
 

Looks like this does nothing

Comment by Tim Sharpe [ 2018/12/18 ]

Hi Mikhail,

That part of the template change relies on a currently unreleased change in PDK itself and will be part of the next PDK release. If you really want to use it now you can grab the latest nightly build of PDK (with the usual understanding that nightly build are not as rigourously tested as release builds and so some things might not work as expected).

Comment by Mikhail [ 2018/12/18 ]

Thank you, we'll wait for release, I guess =)

Generated at Sat Jul 20 13:32:07 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.