Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Fix foodcritic and rubocop #182

Merged
merged 7 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,19 @@ LineLength:
Enabled: false
MethodLength:
Max: 30
Exclude:
- "libraries/helper.rb"
Style/NumericLiteralPrefix:
Enabled: false
Metrics/ModuleLength:
Exclude:
- "libraries/helper.rb"
Metrics/AbcSize:
Exclude:
- "libraries/helper.rb"
Metrics/CyclomaticComplexity:
Exclude:
- "libraries/helper.rb"
Metrics/PerceivedComplexity:
Exclude:
- "libraries/helper.rb"
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env rake
# frozen_string_literal: true

# Style tests. Rubocop and Foodcritic
Expand Down Expand Up @@ -59,7 +58,7 @@ end
task unit: ['unit:rspec']

desc 'Run all tests on Travis'
task travis: %w(style unit)
task travis: %w[style unit]

# Default
task default: ['style', 'unit', 'integration:kitchen:all']
1 change: 0 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
default['stash']['url'] = nil
default['stash']['checksum'] = nil


# Data bag where credentials and other sensitive data could be stored (optional)
default['stash']['data_bag_name'] = 'stash'
default['stash']['data_bag_item'] = 'stash'
Expand Down
302 changes: 149 additions & 153 deletions libraries/helper.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libraries/stash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def merge_stash_settings
end

def handle_old_stash_attributes!
backup_attrs = %w(backup_path baseurl password user cron)
backup_attrs = %w[backup_path baseurl password user cron]
show_warn = false
backup_attrs.each do |attr|
next if node['stash']['backup_client'][attr].nil?
Expand Down
4 changes: 3 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
name 'stash'
maintainer 'Brian Flad'
maintainer_email '[email protected]'
license 'Apache 2.0'
license 'Apache-2.0'
description 'Installs/Configures Atlassian Stash'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '4.5.1'
chef_version '>= 11' if respond_to?(:chef_version)

recipe 'stash', 'Installs/Configures Atlassian Stash'
recipe 'stash::apache2', 'Installs/Configures Apache 2 proxy for Stash'
recipe 'stash::backup_client', 'Installs/Configures Atlassian Stash Backup Client'
Expand Down
4 changes: 1 addition & 3 deletions providers/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
use_inline_resources

action :deploy do
g = git new_resource.destination do
git new_resource.destination do
repository "ssh://git@#{node['stash']['ssh']['hostname']}:#{node['stash']['ssh']['port']}/#{new_resource.project}/#{new_resource.repository}.git"
revision new_resource.revision
user new_resource.user
group new_resource.group
action new_resource.deploy_action
ssh_wrapper "#{node['stash']['install_path']}/#{new_resource.deploy_key}_ssh_wrapper.sh"
end

new_resource.updated_by_last_action(g.updated?)
end
4 changes: 0 additions & 4 deletions providers/deploy_key.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

use_inline_resources

# rubocop:disable Metrics/BlockLength
action :create do
key_path = "#{node['stash']['install_path']}/#{new_resource.alias}_ssh_key.pem"
wrapper_path = "#{node['stash']['install_path']}/#{new_resource.alias}_ssh_wrapper.sh"
Expand All @@ -29,7 +27,5 @@
mode 0500
variables(:key_path => key_path)
end

new_resource.updated_by_last_action(true)
end
# rubocop:enable Metrics/BlockLength
3 changes: 0 additions & 3 deletions providers/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def whyrun_supported?
converge_by("Enable #{@new_resource}") do
enable(server, user, hook_opts)
end
new_resource.updated_by_last_action(true)
end
end

Expand All @@ -39,7 +38,6 @@ def whyrun_supported?
converge_by("Configure #{@new_resource}") do
configure(server, user, hook_opts, settings)
end
new_resource.updated_by_last_action(true)
end
end

Expand All @@ -56,7 +54,6 @@ def whyrun_supported?
converge_by("Disable #{@new_resource}") do
disable(server, user, hook_opts)
end
new_resource.updated_by_last_action(true)
end
end

Expand Down
4 changes: 1 addition & 3 deletions providers/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def whyrun_supported?
converge_by("Creating #{@new_resource}") do
create(server, user, repo_opts)
end
new_resource.updated_by_last_action(true)
end
end

Expand All @@ -36,7 +35,6 @@ def whyrun_supported?
converge_by("Deleting #{@new_resource}") do
delete(server, user, repo_opts)
end
new_resource.updated_by_last_action(true)
end
end

Expand Down Expand Up @@ -68,7 +66,7 @@ def repo_uri(repo_opts)
def exists?(server, user, repo_opts)
uri = stash_uri(server, repo_uri(repo_opts))

response = stash_get(uri, user, %w(200 404))
response = stash_get(uri, user, %w[200 404])
response.code == '200'
end

Expand Down
4 changes: 2 additions & 2 deletions recipes/apache2.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

begin
node.set['apache']['listen_ports'] = node['apache']['listen_ports'] + [node['stash']['apache2']['port']] unless node['apache']['listen_ports'].include?(node['stash']['apache2']['port'])
node.set['apache']['listen_ports'] = node['apache']['listen_ports'] + [node['stash']['apache2']['ssl']['port']] unless node['apache']['listen_ports'].include?(node['stash']['apache2']['ssl']['port'])
node.normal['apache']['listen_ports'] = node['apache']['listen_ports'] + [node['stash']['apache2']['port']] unless node['apache']['listen_ports'].include?(node['stash']['apache2']['port'])
node.normal['apache']['listen_ports'] = node['apache']['listen_ports'] + [node['stash']['apache2']['ssl']['port']] unless node['apache']['listen_ports'].include?(node['stash']['apache2']['ssl']['port'])
rescue NoMethodError
node.default['apache']['listen'] |= [
"*:#{node['stash']['apache2']['port']}",
Expand Down
6 changes: 3 additions & 3 deletions recipes/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
port settings['database']['port'].to_s
data_dir node['mysql']['data_dir'] if node['mysql']['data_dir']
initial_root_password node['mysql']['server_root_password']
action %i(create start)
action %i[create start]
end

database_connection[:username] = 'root'
Expand All @@ -48,7 +48,7 @@
host '%'
password settings['database']['password']
database_name settings['database']['name']
action %i(create grant)
action %i[create grant]
end
when 'postgresql'
include_recipe 'postgresql::server'
Expand All @@ -67,6 +67,6 @@
connection database_connection
password settings['database']['password']
database_name settings['database']['name']
action %i(create grant)
action %i[create grant]
end
end
2 changes: 1 addition & 1 deletion recipes/linux_standalone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
comment 'Stash Service Account'
home node['stash']['home_path']
shell '/bin/bash'
supports :manage_home => true
manage_home true
system true
action :create
end
Expand Down
2 changes: 1 addition & 1 deletion recipes/service_init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if node['stash']['product'] == 'bitbucket'
service 'stash' do
supports :status => true, :restart => true
action %i(stop disable)
action %i[stop disable]
end

file '/etc/init.d/stash' do
Expand Down
6 changes: 1 addition & 5 deletions resources/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

actions :deploy
default_action :deploy

attribute :destination, :kind_of => String, :name_attribute => true

Expand All @@ -12,8 +13,3 @@
attribute :group, :kind_of => String, :default => nil
attribute :revision, :kind_of => String, :default => 'HEAD'
attribute :user, :kind_of => String, :default => nil

def initialize(*args)
super
@action = :deploy
end
6 changes: 1 addition & 5 deletions resources/deploy_key.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# frozen_string_literal: true

actions :create
default_action :create

attribute :alias, :kind_of => String, :name_attribute => true

attribute :key, :kind_of => String, :required => true

attribute :owner, :kind_of => String, :default => nil

def initialize(*args)
super
@action = :create
end