From 78e94a5585b585eafc3ae4a04c21277b03916113 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 9 Dec 2016 10:30:06 +0100 Subject: [PATCH] Add rubocop --- .rubocop.yml | 24 ++++++++++++++++++++++++ Gemfile | 13 ++++++++++++- Rakefile | 10 ++++------ 3 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..ef9dbef --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,24 @@ +require: rubocop-rspec +AllCops: + TargetRubyVersion: 1.9 + Include: + - ./**/*.rb + Exclude: + - vendor/**/* + - .vendor/**/* + - pkg/**/* + - spec/fixtures/**/* + +# We don't use rspec in this way +RSpec/DescribeClass: + Enabled: False + +RSpec/ImplicitExpect: + Enabled: False + +# Example length is not necessarily an indicator of code quality +RSpec/ExampleLength: + Enabled: False + +RSpec/NamedSubject: + Enabled: False diff --git a/Gemfile b/Gemfile index e828ebf..1a181b0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,21 @@ source 'https://rubygems.org' gem 'puppet', ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : '>= 2.7' -gem 'rspec-puppet', '~> 2.0' +gem 'rspec-puppet', '>= 2.0' gem 'puppetlabs_spec_helper', '>= 0.1.0' gem 'puppet-lint', '>= 1' gem 'facter', '>= 1.7.0' gem 'rspec-puppet-facts', :require => false gem 'puppet-lint-strict_indent-check' +gem 'puppet-lint-absolute_classname-check' +gem 'puppet-lint-leading_zero-check' +gem 'puppet-lint-trailing_comma-check' +gem 'puppet-lint-version_comparison-check' +gem 'puppet-lint-classes_and_types_beginning_with_digits-check' +gem 'puppet-lint-unquoted_string-check' +gem 'puppet-lint-variable_contains_upcase' + +gem 'metadata-json-lint' + +gem 'rubocop-rspec', '~> 1.6', :require => false if RUBY_VERSION >= '2.3.0' diff --git a/Rakefile b/Rakefile index b3824f9..b2f0451 100644 --- a/Rakefile +++ b/Rakefile @@ -2,12 +2,10 @@ require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' -if not ENV['SPEC_OPTS'] - ENV['SPEC_OPTS'] = '--format documentation' -end +ENV['SPEC_OPTS'] = '--format documentation' unless ENV['SPEC_OPTS'] -PuppetSyntax.exclude_paths = [ "vendor/**/*.*" ] -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] +PuppetSyntax.exclude_paths = ['vendor/**/*.*'] +PuppetLint.configuration.ignore_paths = %w(spec/**/*.pp pkg/**/*.pp vendor/**/*.pp) # Alternative configuration until https://github.com/rodjek/puppet-lint/pull/397 gets merged Rake::Task[:lint].clear @@ -15,4 +13,4 @@ PuppetLint::RakeTask.new :lint do |config| config.ignore_paths = PuppetLint.configuration.ignore_paths end -task :all => [ :validate, :lint, :spec ] +task :all => [:validate, :lint, :spec, :rubocop] -- GitLab