Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Lint to default to Puppet Approved criteria #80

Merged
merged 1 commit into from
May 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions lib/puppetlabs_spec_helper/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,21 @@ def revision(scm, target, ref)
FileUtils.rm_rf("pkg/")
end

desc "Check puppet manifests with puppet-lint"
task :lint do
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.relative = true
PuppetLint.configuration.disable_class_inherits_from_params_class
PuppetLint.configuration.ignore_paths ||= []
PuppetLint.configuration.ignore_paths << "spec/fixtures/**/*.pp"
PuppetLint.configuration.ignore_paths << "pkg/**/*.pp"
PuppetLint.configuration.ignore_paths << "vendor/**/*.pp"
require 'puppet-lint/tasks/puppet-lint'
# Must clear as it will not override the existing puppet-lint rake task since we require to import for
# the PuppetLint::RakeTask
Rake::Task[:lint].clear
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't believe that you need to clear the :lint task here, as this would be the only :lint defined at this point in time.

The reason I had to do it in my module Rakefile was because I was overriding this task. Once the ignore_paths have been set, they cannot be changed. As mentioned, only the first :lint task will be the one run by Rake, so if you wish to change ignore_paths, then you have to ensure that there is one task.

For reference, my module uses this code:

# necessary to ensure default :lint doesn't exist, else ignore_paths won't work
Rake::Task[:lint].clear

PuppetLint.configuration.relative = true
PuppetLint.configuration.disable_class_inherits_from_params_class
PuppetLint::RakeTask.new :lint do |config|
  config.ignore_paths = ['contrib/**/*.pp', 'tests/**/*.pp', 'spec/**/*.pp', 'pkg/**/*.pp']
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If notice that we are not just creating the rake task but using the PuppetLint::RakeTask class which upon import will define a lint Rake task.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, you've removed task :lint, and replaced it with PuppetLint::RakeTask.new(:lint), which is fine (and the same thing my example does).

My point is that there are no tasks defined prior to calling Rake::Task[:lint].clear, making that line unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require 'puppet-lint/tasks/puppet-lint' creates the task by default. Since we have to require it prior to creating the Task via PuppetLint::RakeTask.new you have to clear it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also fixed in 1.1.1

# Relative is not able to be set within the context of PuppetLint::RakeTask
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, this is fixed in rodjek/puppet-lint@c033c37 (to be 1.1.1).

PuppetLint.configuration.relative = true
PuppetLint::RakeTask.new(:lint) do |config|
config.fail_on_warnings = true
config.disable_checks = [
'80chars',
'class_inherits_from_params_class',
'class_parameter_defaults',
'documentation',
'single_quote_string_with_variables']
config.ignore_paths = ["tests/**/*.pp", "vendor/**/*.pp","examples/**/*.pp" "spec/**/*.pp", "pkg/**/*.pp"]
end

require 'puppet-syntax/tasks/puppet-syntax'
Expand Down