From d2d9cd81ec8efe514917712491d9a82303c26e0d Mon Sep 17 00:00:00 2001 From: Mark Vanderwiel Date: Fri, 29 May 2015 12:18:53 -0500 Subject: [PATCH] Cleanup minor rubocop offenses Cleaned up all the minor rubocop issues, the ones left relate to complex logic and what I think is a bug in rubocop for nested vs compact modules/class definitions. Change-Id: Ib326cac0e09df628189e290807513bad59df0b76 --- .rubocop_todo.yml | 41 +--------------------------------------- metadata.rb | 12 ++++++------ recipes/agent-compute.rb | 2 +- recipes/api.rb | 2 +- recipes/collector.rb | 4 ++-- recipes/common.rb | 10 +++++----- spec/client_spec.rb | 1 - spec/common_spec.rb | 8 +++----- 8 files changed, 19 insertions(+), 61 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 333c430..2b644ed 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,50 +1,11 @@ # This configuration was generated by `rubocop --auto-gen-config` -# on 2015-02-27 14:10:04 -0600 using RuboCop version 0.29.1. +# on 2015-05-29 12:18:25 -0500 using RuboCop version 0.29.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 2 -# Cop supports --auto-correct. -Lint/DeprecatedClassMethods: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Lint/StringConversionInInterpolation: - Enabled: false - # Offense count: 3 # Configuration parameters: EnforcedStyle, SupportedStyles. Style/ClassAndModuleChildren: Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/EmptyLinesAroundBlockBody: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/FirstParameterIndentation: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Enabled: false - -# Offense count: 10 -# Cop supports --auto-correct. -Style/SingleSpaceBeforeFirstArg: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/StringLiteralsInInterpolation: - Enabled: false diff --git a/metadata.rb b/metadata.rb index 450015f..50de4e4 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,10 +1,10 @@ -name 'openstack-telemetry' -maintainer 'openstack-chef' +name 'openstack-telemetry' +maintainer 'openstack-chef' maintainer_email 'opscode-chef-openstack@googlegroups.com' -license 'Apache 2.0' -description 'The OpenStack Metering service Ceilometer.' +license 'Apache 2.0' +description 'The OpenStack Metering service Ceilometer.' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '11.0.0' +version '11.0.0' recipe 'openstack-telemetry::agent-central', 'Installs agent central service.' recipe 'openstack-telemetry::agent-compute', 'Installs agent compute service.' @@ -17,7 +17,7 @@ recipe 'openstack-telemetry::alarm-notifier', 'Installs the alarm notifier servi recipe 'openstack-telemetry::common', 'Common metering configuration.' recipe 'openstack-telemetry::identity_registration', 'Registers the endpoints, tenant and user for metering service with Keystone' -%w{ ubuntu suse }.each do |os| +%w(ubuntu suse).each do |os| supports os end diff --git a/recipes/agent-compute.rb b/recipes/agent-compute.rb index 7889534..d368af6 100644 --- a/recipes/agent-compute.rb +++ b/recipes/agent-compute.rb @@ -35,7 +35,7 @@ if node['platform'] == 'ubuntu' init_script = '/etc/init/ceilometer-agent-compute.conf' execute 'fix init script' do command "cp #{init_script}.dpkg-new #{init_script}" - not_if { ::File.exists?(init_script) } + not_if { ::File.exist?(init_script) } end end diff --git a/recipes/api.rb b/recipes/api.rb index 82dfe63..49bd527 100644 --- a/recipes/api.rb +++ b/recipes/api.rb @@ -25,7 +25,7 @@ include_recipe 'openstack-telemetry::common' directory ::File.dirname(node['openstack']['telemetry']['api']['auth']['cache_dir']) do owner node['openstack']['telemetry']['user'] group node['openstack']['telemetry']['group'] - mode 00700 + mode 00700 end platform = node['openstack']['telemetry']['platform'] diff --git a/recipes/collector.rb b/recipes/collector.rb index afa96eb..8ae838d 100644 --- a/recipes/collector.rb +++ b/recipes/collector.rb @@ -22,7 +22,7 @@ include_recipe 'openstack-telemetry::common' -conf_switch = "--config-file #{node["openstack"]["telemetry"]["conf"]}" +conf_switch = "--config-file #{node['openstack']['telemetry']['conf']}" execute 'database migration' do command "ceilometer-dbsync #{conf_switch}" @@ -43,7 +43,7 @@ if node['platform'] == 'ubuntu' init_script = '/etc/init/ceilometer-collector.conf' execute 'fix init script' do command "cp #{init_script}.dpkg-new #{init_script}" - not_if { ::File.exists?(init_script) } + not_if { ::File.exist?(init_script) } end end diff --git a/recipes/common.rb b/recipes/common.rb index e241f96..94743d1 100644 --- a/recipes/common.rb +++ b/recipes/common.rb @@ -71,14 +71,14 @@ identity_uri = identity_uri_transform(identity_admin_endpoint) Chef::Log.debug("openstack-telemetry::common:service_user|#{service_user}") Chef::Log.debug("openstack-telemetry::common:service_tenant|#{service_tenant}") -Chef::Log.debug("openstack-telemetry::common:identity_endpoint|#{identity_endpoint.to_s}") +Chef::Log.debug("openstack-telemetry::common:identity_endpoint|#{identity_endpoint}") metering_secret = get_secret 'openstack_metering_secret' directory node['openstack']['telemetry']['conf_dir'] do owner node['openstack']['telemetry']['user'] group node['openstack']['telemetry']['group'] - mode 00750 + mode 00750 action :create end @@ -89,9 +89,9 @@ end template node['openstack']['telemetry']['conf'] do source 'ceilometer.conf.erb' - owner node['openstack']['telemetry']['user'] - group node['openstack']['telemetry']['group'] - mode 00640 + owner node['openstack']['telemetry']['user'] + group node['openstack']['telemetry']['group'] + mode 00640 variables( auth_uri: auth_uri, diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 0485e3c..97177f3 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -4,7 +4,6 @@ require_relative 'spec_helper' describe 'openstack-telemetry::client' do describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } let(:node) { runner.node } let(:chef_run) { runner.converge(described_recipe) } diff --git a/spec/common_spec.rb b/spec/common_spec.rb index 4f04768..c8aefe1 100644 --- a/spec/common_spec.rb +++ b/spec/common_spec.rb @@ -58,13 +58,13 @@ describe 'openstack-telemetry::common' do it 'has default values' do node.set['openstack']['telemetry']['syslog']['use'] = true - [%r(^os_auth_url = http://127.0.0.1:5000/v2.0$), + [%r{^os_auth_url = http://127.0.0.1:5000/v2.0$}, /^os_tenant_name = service$/, /^os_password = ceilometer-pass$/, /^os_username = ceilometer$/, /^verbose = true$/, /^debug = false$/, - %r(^log_config = /etc/openstack/logging.conf$), + %r{^log_config = /etc/openstack/logging.conf$}, /^glance_registry_host = 127.0.0.1$/, /^periodic_interval = 600$/].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) @@ -334,8 +334,7 @@ describe 'openstack-telemetry::common' do it 'has bind_port set' do node.set['openstack']['endpoints']['telemetry-api-bind']['port'] = '9999' - expect(chef_run).to render_file(file.name).with_content( - /^port = 9999$/) + expect(chef_run).to render_file(file.name).with_content(/^port = 9999$/) end it 'has vmware section' do @@ -357,7 +356,6 @@ describe 'openstack-telemetry::common' do .with_section_content('notification', /^store_events = false$/) end end - end end end