Skip to content

Commit

Permalink
[lint] add rubocop run in the lint code
Browse files Browse the repository at this point in the history
Also:
* delete the unused Vagrantfile
* fix a bunch of warnings and convention messages from rubocop

We fail only on warnings or worse from rubocop.
  • Loading branch information
LeoCavaille committed May 18, 2015
1 parent 2d9cfff commit 4653764
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 101 deletions.
25 changes: 25 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# We allow longer lines in our style
Metrics/LineLength:
Max: 150

# TODO/FIXME:
# At some point, we might just want to do the changes and get rid of those

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 128

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 17

# Offense count: 2
Style/Documentation:
Enabled: false

# Offense count: 1
# Configuration parameters: Methods.
Style/SingleLineBlockParams:
Enabled: false
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source "https://rubygems.org"
source 'https://rubygems.org'

gem 'addressable'
gem 'colorize'
gem 'httparty'
gem 'rake'
gem 'rubocop'
38 changes: 22 additions & 16 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# encoding: utf-8

require 'rake/clean'
require 'rubocop/rake_task'

# Flavored Travis CI jobs
require './ci/apache'
Expand Down Expand Up @@ -53,17 +54,17 @@ end

desc 'Setup a development environment for the Agent'
task 'setup_env' do
`mkdir -p venv`
`wget -O venv/virtualenv.py https://raw.github.com/pypa/virtualenv/1.11.6/virtualenv.py`
`python venv/virtualenv.py --no-site-packages --no-pip --no-setuptools venv/`
`wget -O venv/ez_setup.py https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py`
`venv/bin/python venv/ez_setup.py`
`wget -O venv/get-pip.py https://raw.github.com/pypa/pip/master/contrib/get-pip.py`
`venv/bin/python venv/get-pip.py`
`venv/bin/pip install -r requirements.txt`
# These deps are not really needed, so we ignore failures
ENV['PIP_COMMAND'] = 'venv/bin/pip'
`./utils/pip-allow-failures.sh requirements-opt.txt`
`mkdir -p venv`
`wget -O venv/virtualenv.py https://raw.github.com/pypa/virtualenv/1.11.6/virtualenv.py`
`python venv/virtualenv.py --no-site-packages --no-pip --no-setuptools venv/`
`wget -O venv/ez_setup.py https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py`
`venv/bin/python venv/ez_setup.py`
`wget -O venv/get-pip.py https://raw.github.com/pypa/pip/master/contrib/get-pip.py`
`venv/bin/python venv/get-pip.py`
`venv/bin/pip install -r requirements.txt`
# These deps are not really needed, so we ignore failures
ENV['PIP_COMMAND'] = 'venv/bin/pip'
`./utils/pip-allow-failures.sh requirements-opt.txt`
end

namespace :test do
Expand Down Expand Up @@ -91,8 +92,13 @@ namespace :test do
task 'coverage' => 'ci:default:coverage'
end

RuboCop::RakeTask.new(:rubocop) do |t|
t.patterns = ['ci/**/*.rb', 'Gemfile', 'Rakefile']
end

desc 'Lint the code through pylint'
task 'lint' => 'ci:default:lint'
task 'lint' => ['ci:default:lint'] do
end

desc 'Run the Agent locally'
task 'run' do
Expand All @@ -101,12 +107,12 @@ end

namespace :ci do
desc 'Run integration tests'
task :run, :flavor do |t, args|
puts "Assuming you are running these tests locally" unless ENV['TRAVIS']
task :run, :flavor do |_, args|
puts 'Assuming you are running these tests locally' unless ENV['TRAVIS']
flavor = args[:flavor] || ENV['TRAVIS_FLAVOR'] || 'default'
flavors = flavor.split(',')
flavors.each { |f| Rake::Task["ci:#{f}:execute"].invoke}
flavors.each { |f| Rake::Task["ci:#{f}:execute"].invoke }
end
end

task :default => [:test]
task default: ['lint', 'ci:run']
76 changes: 0 additions & 76 deletions Vagrantfile

This file was deleted.

2 changes: 1 addition & 1 deletion ci/activemq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def activemq_rootdir
end

namespace :ci do
namespace :my_new_flavor do |flavor|
namespace :activemq do |flavor|
task before_install: ['ci:common:before_install']

task install: ['ci:common:install'] do
Expand Down
5 changes: 3 additions & 2 deletions ci/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def section(name)
puts ''
end

# helper class to wait for TCP/HTTP services to boot
class Wait
DEFAULT_TIMEOUT = 10

Expand Down Expand Up @@ -158,12 +159,12 @@ def self.for(smth, max_timeout = DEFAULT_TIMEOUT)
task :run_tests, :flavor do |t, attr|
flavors = attr[:flavor]
filter = ENV['NOSE_FILTER'] || '1'
if flavors.include? 'default' || flavors.include? 'checks_mock'
if flavors.include?('default') || flavors.include?('checks_mock')
nose = "(not requires) and #{filter}"
else
nose = "(requires in #{flavors}) and #{filter}"
end
if flavors.include? 'default' || flavors.include? 'core_integration'
if flavors.include?('default') || flavors.include?('core_integration')
tests_directory = 'tests/core'
else
tests_directory = 'tests/checks'
Expand Down
2 changes: 1 addition & 1 deletion ci/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

task before_script: ['ci:common:before_script']

task :lint do
task lint: ['rubocop'] do
sh %(flake8)
end

Expand Down
2 changes: 1 addition & 1 deletion ci/resources/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def push_url(branch = 'master')

def fold(message = nil)
@fold_count ||= 0
@fold_count += 1
@fold_count += 1

puts `echo #{message}` if message
yield
Expand Down
2 changes: 1 addition & 1 deletion ci/resources/cache/aws4_signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def signing_key
end

def recursive_hmac(*args)
args.reduce { |key, data| OpenSSL::HMAC.digest('sha256', key, data) }
args.reduce { |k, d| OpenSSL::HMAC.digest('sha256', k, d) }
end
end
end
3 changes: 2 additions & 1 deletion ci/riak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def riak_rootdir
sh %(chmod a+x $VOLATILE_DIR/kerl)
sh %($VOLATILE_DIR/kerl build git git://github.com/basho/otp.git OTP_R16B02 R16B02)
sh %($VOLATILE_DIR/kerl install R16B02 $VOLATILE_DIR/erlang/R16B02)
sh %(curl -o $VOLATILE_DIR/riak.tar.gz http://s3.amazonaws.com/downloads.basho.com/riak/#{riak_version[0..2]}/#{riak_version}/riak-#{riak_version}.tar.gz)
sh %(curl -o $VOLATILE_DIR/riak.tar.gz\
http://s3.amazonaws.com/downloads.basho.com/riak/#{riak_version[0..2]}/#{riak_version}/riak-#{riak_version}.tar.gz)
sh %(mkdir -p $VOLATILE_DIR/riak)
sh %(tar zxvf $VOLATILE_DIR/riak.tar.gz -C $VOLATILE_DIR/riak --strip-components=1)
sh %(cd $VOLATILE_DIR/riak\
Expand Down
3 changes: 2 additions & 1 deletion ci/sysstat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def sysstat_rootdir
sh %(tar Jxf $VOLATILE_DIR/sysstat-#{sysstat_version}.tar.xz\
-C $VOLATILE_DIR/sysstat --strip-components=1)
sh %(cd $VOLATILE_DIR/sysstat\
&& conf_dir=#{sysstat_rootdir}/etc/sysconfig sa_dir=#{sysstat_rootdir}/var/log/sa ./configure --prefix=#{sysstat_rootdir} --disable-man-group\
&& conf_dir=#{sysstat_rootdir}/etc/sysconfig sa_dir=#{sysstat_rootdir}/var/log/sa\
./configure --prefix=#{sysstat_rootdir} --disable-man-group\
&& make\
&& make install)
end
Expand Down

0 comments on commit 4653764

Please sign in to comment.