From 1abca4705f876e62ba0439710003cfd8c0ee155b Mon Sep 17 00:00:00 2001 From: Hailee Kenney Date: Wed, 8 Oct 2014 13:35:14 -0700 Subject: [PATCH] (PDOC-8) Add rubocop to travis job In order to ensure long term code quality, add a rubocop check to the travis job which runs when a pull request is submitted. Do this by adding a rake task for rubocop and setting up travis to run both the spec rake task and the rubocop one. Additionally, make a few changes to the .rubocop.yml file so it will stop complaining about incorrect namespaces. --- .rubocop.yml | 12 ++++++------ .travis.yml | 12 ++++++------ Gemfile | 2 +- Rakefile | 6 ++++++ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8764883..8466b96 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -65,7 +65,7 @@ Style/RedundantSelf: Enabled: false # DISABLED - not useful -Style/MethodLength: +Metrics/MethodLength: Enabled: false # DISABLED - not useful @@ -143,7 +143,7 @@ Style/AlignHash: Style/AlignParameters: Enabled: false -Style/BlockNesting: +Metrics/BlockNesting: Enabled: false Style/AsciiComments: @@ -176,7 +176,7 @@ Style/ClassAndModuleChildren: Style/ClassCheck: Enabled: false -Style/ClassLength: +Metrics/ClassLength: Enabled: false Style/ClassMethods: @@ -264,7 +264,7 @@ Style/ColonMethodCall: Style/CommentAnnotation: Enabled: false -Style/CyclomaticComplexity: +Metrics/CyclomaticComplexity: Enabled: false Style/ConstantName: @@ -316,7 +316,7 @@ Style/EmptyLinesAroundBody: Style/EmptyLiteral: Enabled: false -Style/LineLength: +Metrics/LineLength: Enabled: false Style/MethodCallParentheses: @@ -472,7 +472,7 @@ Style/RegexpLiteral: Lint/UnderscorePrefixedVariableName: Enabled: false -Style/ParameterLists: +Metrics/ParameterLists: Enabled: false Lint/RequireParentheses: diff --git a/.travis.yml b/.travis.yml index f73e076..a6204b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,17 @@ language: ruby bundler_args: --without development -script: "bundle exec rake spec SPEC_OPTS='--color --format documentation'" +script: + - "bundle exec rake $CHECK" notifications: email: false rvm: - 1.9.3 - 2.0.0 - 2.1.0 - - ruby-head + env: - - PUPPET_VERSION=3.6.2 - - PUPPET_VERSION=3.7.1 + - "CHECK=spec SPEC_OPTS='--color --format documentation'" + - "CHECK=rubocop" + matrix: fast_finish: true - allow_failures: - - rvm: ruby-head diff --git a/Gemfile b/Gemfile index 6825907..b37a722 100644 --- a/Gemfile +++ b/Gemfile @@ -21,10 +21,10 @@ group :test do gem 'serverspec' gem 'beaker' gem 'beaker-rspec' + gem 'rubocop' end group :development do gem 'pry' gem 'pry-debugger' - gem 'rubocop' end diff --git a/Rakefile b/Rakefile index e648b48..3bda0b1 100644 --- a/Rakefile +++ b/Rakefile @@ -22,3 +22,9 @@ task :acceptance do sh "puppet module build spec/unit/puppet/examples/test" sh "BEAKER_set=#{ENV["platform"]} rspec spec/acceptance/*.rb" end + +task(:rubocop) do + require 'rubocop' + cli = RuboCop::CLI.new + cli.run(%w(-D -f s)) +end