Initial rubocop support for recipes.

Per the mailing list thread, introducing Rubocop as a replacement for Tailor.
Assuming Jenkins likes this, more pedantic patches will follow to make Rubocop
happy. So far this is just spacing issues and adding UTF-8 headers, but more
work will need to be done to remove all of the changes for the .rubocop-todo.yml

Change-Id: I590ac5ec03ce6a00dd73027d6798e36105a32af1
This commit is contained in:
Matt Ray 2014-01-08 13:31:08 -06:00
parent 3f739f7a78
commit 018d125a51
11 changed files with 77 additions and 37 deletions

View File

@ -1,9 +1,9 @@
source 'https://rubygems.org'
gem 'chef', '~> 11.4.4'
gem 'chef', '~> 11.8'
gem 'json', '<= 1.7.7' # chef 11 dependency
gem 'berkshelf', '~> 2.0.10'
gem 'chefspec', '~> 3.0.2'
gem 'chefspec', '~> 3.1.4'
gem 'foodcritic', '~> 3.0.3'
gem 'strainer'
gem 'rubocop'
gem 'rubocop', '>= 0.16.0'

View File

@ -37,28 +37,41 @@ GEM
celluloid-io (0.14.1)
celluloid (>= 0.14.1)
nio4r (>= 0.4.5)
chef (11.4.4)
erubis
highline (>= 1.6.9)
chef (11.8.2)
chef-zero (~> 1.6, >= 1.6.2)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
highline (~> 1.6, >= 1.6.9)
json (>= 1.4.4, <= 1.7.7)
mixlib-authentication (>= 1.3.0)
mixlib-cli (~> 1.3.0)
mixlib-config (>= 1.1.2)
mixlib-log (>= 1.3.0)
mixlib-shellout
mime-types (~> 1.16)
mixlib-authentication (~> 1.3)
mixlib-cli (~> 1.3)
mixlib-config (~> 2.0)
mixlib-log (~> 1.3)
mixlib-shellout (~> 1.2)
net-ssh (~> 2.6)
net-ssh-multi (~> 1.1.0)
ohai (>= 0.6.0)
ohai (~> 6.0)
pry (~> 0.9)
puma (~> 1.6)
rest-client (>= 1.0.4, < 1.7.0)
yajl-ruby (~> 1.1)
chefspec (3.0.2)
chef-zero (1.7.2)
hashie (~> 2.0)
json
mixlib-log (~> 1.3)
moneta (< 0.7.0)
rack
chefspec (3.1.4)
chef (~> 11.0)
fauxhai (~> 2.0)
i18n (>= 0.6.9, < 1.0.0)
rspec (~> 2.14)
chozo (0.6.1)
activesupport (>= 3.2.0)
hashie (>= 2.0.2)
multi_json (>= 1.3.0)
coderay (1.1.0)
diff-lcs (1.2.5)
erubis (2.7.0)
faraday (0.8.8)
@ -92,14 +105,16 @@ GEM
logging (1.8.1)
little-plugger (>= 1.1.3)
multi_json (>= 1.3.6)
mime-types (2.0)
method_source (0.8.2)
mime-types (1.25.1)
minitar (0.5.4)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.3.0)
mixlib-cli (1.4.0)
mixlib-config (2.1.0)
mixlib-log (1.6.0)
mixlib-shellout (1.3.0)
moneta (0.6.0)
multi_json (1.8.2)
multipart-post (1.2.0)
net-http-persistent (2.9)
@ -120,13 +135,19 @@ GEM
mixlib-shellout
systemu (~> 2.5.2)
yajl-ruby
parser (2.0.0)
parser (2.1.2)
ast (~> 1.1)
slop (~> 3.4, >= 3.4.5)
polyglot (0.3.3)
powerpack (0.0.9)
pry (0.9.12.4)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
puma (1.6.3)
rack (~> 1.2)
rack (1.5.2)
rainbow (1.1.4)
rainbow (1.99.1)
rake (10.1.1)
rbzip2 (0.2.0)
rest-client (1.6.7)
@ -160,8 +181,8 @@ GEM
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.4)
rubocop (0.15.0)
parser (~> 2.0)
rubocop (0.16.0)
parser (~> 2.1)
powerpack (~> 0.0.6)
rainbow (>= 1.1.4)
rubyntlm (0.1.1)
@ -205,9 +226,9 @@ PLATFORMS
DEPENDENCIES
berkshelf (~> 2.0.10)
chef (~> 11.4.4)
chefspec (~> 3.0.2)
chef (~> 11.8)
chefspec (~> 3.1.4)
foodcritic (~> 3.0.3)
json (<= 1.7.7)
rubocop
rubocop (>= 0.16.0)
strainer

View File

@ -1,7 +1,8 @@
# Strainerfile
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/Gemfile
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/attributes/
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/metadata.rb
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/Gemfile
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/recipes/
# rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK
# may want to add rubocop check for Berksfile and Gemfile
knife test: bundle exec knife cookbook test $COOKBOOK

View File

@ -16,7 +16,11 @@ To run the tests:
### Attribute Rules ###
There is a [.rubocop.yml](attributes/.rubocop.yml) specific to `attributes`, with the rationale for ignored styles within the file.
Since there are slight style differences between the coding of attributes, recipes and metadata files there are specific `.rubocop.yml` files for each of:
[Gemfile and metadata.rb](.rubocop.yml)
[attributes/*.rb](attributes/.rubocop.yml)
[recipes/.rubocop.yml](recipes/.rubocop.yml)
## Knife ##

15
recipes/.rubocop-todo.yml Normal file
View File

@ -0,0 +1,15 @@
# This configuration was generated by `rubocop --auto-gen-config`.
# The point is for the user to remove these configuration records
# one by one as the offences are removed from the code base.
CollectionMethods:
Enabled: false
Documentation:
Enabled: false
HashSyntax:
Enabled: false
StringLiterals:
Enabled: false

3
recipes/.rubocop.yml Normal file
View File

@ -0,0 +1,3 @@
# embedded attributes make for long lines
LineLength:
Enabled: false

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
# Recipe:: api

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -69,4 +70,3 @@ directory node["openstack"]["block-storage"]["lock_path"] do
owner node["openstack"]["block-storage"]["user"]
mode 00700
end

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
# Recipe:: identity_registration

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
# Recipe:: scheduler
@ -42,8 +43,7 @@ end
service "cinder-scheduler" do
service_name platform_options["cinder_scheduler_service"]
supports :status => true, :restart => true
action [ :enable, :start ]
action [:enable, :start]
subscribes :restart, "template[/etc/cinder/cinder.conf]"
end
@ -53,7 +53,7 @@ audit_log = node["openstack"]["block-storage"]["cron"]["audit_logfile"]
if node["openstack"]["metering"]
scheduler_role = node["openstack"]["block-storage"]["scheduler_role"]
results = search(:node, "roles:#{scheduler_role}")
cron_node = results.collect{|a| a.name}.sort[0]
cron_node = results.collect { |a| a.name }.sort[0]
Chef::Log.debug("Volume audit cron node: #{cron_node}")
cron "cinder-volume-usage-audit" do

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
# Recipe:: volume
@ -32,7 +33,6 @@ platform_options = node["openstack"]["block-storage"]["platform"]
platform_options["cinder_volume_packages"].each do |pkg|
package pkg do
options platform_options["package_overrides"]
action :upgrade
end
end
@ -47,7 +47,6 @@ end
platform_options["cinder_iscsitarget_packages"].each do |pkg|
package pkg do
options platform_options["package_overrides"]
action :upgrade
end
end
@ -83,7 +82,6 @@ when "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver"
platform_options["cinder_nfs_packages"].each do |pkg|
package pkg do
options platform_options["package_overrides"]
action :upgrade
end
end
@ -107,8 +105,7 @@ when "cinder.volume.drivers.lvm.LVMISCSIDriver"
service "cinder-group-active" do
service_name "cinder-group-active"
supports :status => true, :restart => true
action [ :enable, :start ]
action [:enable, :start]
end
template "/etc/init.d/cinder-group-active" do
@ -125,21 +122,18 @@ end
service "cinder-volume" do
service_name platform_options["cinder_volume_service"]
supports :status => true, :restart => true
action [ :enable, :start ]
action [:enable, :start]
subscribes :restart, "template[/etc/cinder/cinder.conf]"
end
service "iscsitarget" do
service_name platform_options["cinder_iscsitarget_service"]
supports :status => true, :restart => true
action :enable
end
template "/etc/tgt/targets.conf" do
source "targets.conf.erb"
mode 00600
notifies :restart, "service[iscsitarget]", :immediately
end