From b334252ead556c29885366075fc43c298d97138c Mon Sep 17 00:00:00 2001 From: Cookstyle Bot Date: Mon, 17 Jan 2022 13:32:22 -0800 Subject: [PATCH] Cookstyle Bot Auto Corrections with Cookstyle 7.30.1 This change is automatically generated by the Cookstyle Bot using the latest version of Cookstyle (7.30.1). Adopting changes suggested by Cookstyle improves cookbook readability, avoids common coding mistakes, and eases upgrades to newer versions of the Chef Infra Client. ### Style/Encoding - **/Berksfile:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/Gemfile:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/Guardfile:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/Rakefile:2**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/attributes/default.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/attributes/hardening.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/metadata.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/recipes/default.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/recipes/hardening.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/spec/default_spec.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/spec/hardening_spec.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/spec/spec_helper.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) ### Chef/Modernize/LegacyBerksfileSource - **/Berksfile:3**: Do not use legacy Berksfile community sources. Use Chef Supermarket instead. (https://docs.chef.io/workstation/cookstyle/chef_modernize_legacyberksfilesource) ### Style/RegexpLiteral - **/Guardfile:5**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:9**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:10**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:11**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:12**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:17**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:18**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:23**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:24**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:25**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:26**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:27**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:28**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:29**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) ### Chef/Style/CommentFormat - **/attributes/default.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/attributes/default.rb:6**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/attributes/default.rb:7**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/attributes/hardening.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/attributes/hardening.rb:6**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/attributes/hardening.rb:7**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/recipes/default.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/recipes/default.rb:6**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/recipes/hardening.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/recipes/hardening.rb:6**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/spec/default_spec.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/spec/hardening_spec.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/spec/spec_helper.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) ### Style/TrailingCommaInArrayLiteral - **/attributes/hardening.rb:51**: Put a comma after the last item of a multiline array. (https://rubystyle.guide#no-trailing-array-commas) - **/spec/hardening_spec.rb:26**: Put a comma after the last item of a multiline array. (https://rubystyle.guide#no-trailing-array-commas) ### Chef/Sharing/InvalidLicenseString - **/metadata.rb:5**: Cookbook metadata.rb does not use a SPDX compliant license string or "all rights reserved". See https://spdx.org/licenses/ for a complete list of license identifiers. (https://docs.chef.io/workstation/cookstyle/chef_sharing_invalidlicensestring) ### Chef/RedundantCode/LongDescriptionMetadata - **/metadata.rb:7**: The long_description metadata.rb method is not used and is unnecessary in cookbooks. (https://docs.chef.io/workstation/cookstyle/chef_redundantcode_longdescriptionmetadata) ### Chef/RedundantCode/RecipeMetadata - **/metadata.rb:12**: The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the cookbook's README.md file instead. (https://docs.chef.io/workstation/cookstyle/chef_redundantcode_recipemetadata) - **/metadata.rb:13**: The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the cookbook's README.md file instead. (https://docs.chef.io/workstation/cookstyle/chef_redundantcode_recipemetadata) ### Chef/Style/IncludeRecipeWithParentheses - **/recipes/default.rb:21**: There is no need to wrap the recipe in parentheses when using the include_recipe helper (https://docs.chef.io/workstation/cookstyle/#includerecipewithparentheses) ### Chef/Style/UnnecessaryPlatformCaseStatement - **/recipes/hardening.rb:22**: Use the platform?() and platform_family?() helpers instead of a case statement that only includes a single when statement. (https://docs.chef.io/workstation/cookstyle/chef_style_unnecessaryplatformcasestatement) ### Layout/DotPosition - **/spec/hardening_spec.rb:48**: Place the . on the next line, together with the method name. (https://rubystyle.guide#consistent-multi-line-chains) - **/spec/hardening_spec.rb:51**: Place the . on the next line, together with the method name. (https://rubystyle.guide#consistent-multi-line-chains) ### Layout/TrailingEmptyLines - **/spec/spec_helper.rb:24**: 1 trailing blank lines detected. (https://rubystyle.guide#newline-eof) ### Chef/Deprecations/ChefSpecCoverageReport - **/spec/spec_helper.rb:25**: Don't use the deprecated ChefSpec coverage report functionality in your specs. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_chefspeccoveragereport) Signed-off-by: Cookstyle --- Berksfile | 4 +--- Gemfile | 2 -- Guardfile | 30 ++++++++++++++---------------- Rakefile | 2 -- attributes/default.rb | 7 +++---- attributes/hardening.rb | 9 ++++----- metadata.rb | 7 +------ recipes/default.rb | 7 +++---- recipes/hardening.rb | 8 +++----- spec/default_spec.rb | 3 +-- spec/hardening_spec.rb | 13 ++++++------- spec/spec_helper.rb | 4 +--- 12 files changed, 37 insertions(+), 59 deletions(-) diff --git a/Berksfile b/Berksfile index 3058cc9..a79b764 100644 --- a/Berksfile +++ b/Berksfile @@ -1,6 +1,4 @@ -# encoding: utf-8 - -source 'https://supermarket.getchef.com' +source 'https://supermarket.chef.io' metadata diff --git a/Gemfile b/Gemfile index ccefd38..85f9a42 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,3 @@ -# encoding: utf-8 - source 'https://rubygems.org' gem 'berkshelf', '~> 5.3' diff --git a/Guardfile b/Guardfile index fa6820b..37174d7 100644 --- a/Guardfile +++ b/Guardfile @@ -1,30 +1,28 @@ -# encoding: utf-8 - guard :rubocop do watch(/.+\.rb$/) - watch(/(?:.+\/)?\.rubocop\.yml$/) { |m| File.dirname(m[0]) } + watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } end guard :foodcritic, cookbook_paths: '.', cli: '-f any --tags ~FC023' do - watch(/attributes\/.+\.rb$/) - watch(/providers\/.+\.rb$/) - watch(/recipes\/.+\.rb$/) - watch(/resources\/.+\.rb$/) + watch(%r{attributes/.+\.rb$}) + watch(%r{providers/.+\.rb$}) + watch(%r{recipes/.+\.rb$}) + watch(%r{resources/.+\.rb$}) watch(/metadata.rb/) end guard :rspec do - watch(/^spec\/.+_spec\.rb$/) - watch(/^(recipes)\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{^(recipes)/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { 'spec' } end guard :kitchen, all_on_start: false do - watch(/test\/.+/) - watch(/^recipes\/(.+)\.rb$/) - watch(/^attributes\/(.+)\.rb$/) - watch(/^files\/(.+)/) - watch(/^templates\/(.+)/) - watch(/^providers\/(.+)\.rb/) - watch(/^resources\/(.+)\.rb/) + watch(%r{test/.+}) + watch(%r{^recipes/(.+)\.rb$}) + watch(%r{^attributes/(.+)\.rb$}) + watch(%r{^files/(.+)}) + watch(%r{^templates/(.+)}) + watch(%r{^providers/(.+)\.rb}) + watch(%r{^resources/(.+)\.rb}) end diff --git a/Rakefile b/Rakefile index ed8f074..264f8ce 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,4 @@ #!/usr/bin/env rake -# encoding: utf-8 - require 'foodcritic' require 'rspec/core/rake_task' require 'rubocop/rake_task' diff --git a/attributes/default.rb b/attributes/default.rb index e776894..82f52ff 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,10 +1,9 @@ -# encoding: utf-8 # -# Cookbook Name:: postgres-hardening +# Cookbook:: postgres-hardening # Attributes:: default # -# Copyright 2014, Christoph Hartmann -# Copyright 2014, Deutsche Telekom AG +# Copyright:: 2014, Christoph Hartmann +# Copyright:: 2014, Deutsche Telekom AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/attributes/hardening.rb b/attributes/hardening.rb index 23ddc9a..42d09ba 100644 --- a/attributes/hardening.rb +++ b/attributes/hardening.rb @@ -1,10 +1,9 @@ -# encoding: utf-8 # -# Cookbook Name:: postgres-hardening +# Cookbook:: postgres-hardening # Attributes:: default # -# Copyright 2014, Christoph Hartmann -# Copyright 2014, Deutsche Telekom AG +# Copyright:: 2014, Christoph Hartmann +# Copyright:: 2014, Deutsche Telekom AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -48,5 +47,5 @@ # all others are md5 now { type: 'local', db: 'all', user: 'all', addr: nil, method: 'md5' }, { type: 'host', db: 'all', user: 'all', addr: '127.0.0.1/32', method: 'md5' }, - { type: 'host', db: 'all', user: 'all', addr: '::1/128', method: 'md5' } + { type: 'host', db: 'all', user: 'all', addr: '::1/128', method: 'md5' }, ] diff --git a/metadata.rb b/metadata.rb index a080e95..a26bb36 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,17 +1,12 @@ -# encoding: utf-8 name 'postgres-hardening' maintainer 'Christoph Hartmann' maintainer_email 'chris@lollyrock.com' -license 'Apache v2.0' +license 'Apache-2.0' description 'Installs and configures a secure posgres server' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '2.0.0' depends 'postgresql', '>= 6.0.0' -recipe 'postgresql-hardening::default', 'calls hardening recipe' -recipe 'postgresql-hardening::hardening', 'add hardening configuration postgresql server' - supports 'amazon' supports 'redhat' supports 'centos' diff --git a/recipes/default.rb b/recipes/default.rb index d4832be..6ff3952 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,9 +1,8 @@ -# encoding: utf-8 # -# Cookbook Name: postgres-hardening +# Cookbook:: Name: postgres-hardening # Recipe: default # -# Copyright 2014, Deutsche Telekom AG +# Copyright:: 2014, Deutsche Telekom AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,4 +17,4 @@ # limitations under the License. # -include_recipe('postgres-hardening::hardening') +include_recipe 'postgres-hardening::hardening' diff --git a/recipes/hardening.rb b/recipes/hardening.rb index e90bdf4..afa94c4 100644 --- a/recipes/hardening.rb +++ b/recipes/hardening.rb @@ -1,9 +1,8 @@ -# encoding: utf-8 # -# Cookbook Name: postgres-hardening +# Cookbook:: Name: postgres-hardening # Recipe: hardening.rb # -# Copyright 2014, Deutsche Telekom AG +# Copyright:: 2014, Deutsche Telekom AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,8 +18,7 @@ # # ensure, that you have postgresql::server in your runlist -case node['platform_family'] -when 'debian' +if platform_family?('debian') ['', node['postgresql']['version']].each do |dir| directory File.join('/var/lib/postgresql/', dir) do mode '0700' diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 1224e30..0bfb70b 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -1,6 +1,5 @@ -# encoding: utf-8 # -# Copyright 2015, Hardening Framework Team +# Copyright:: 2015, Hardening Framework Team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spec/hardening_spec.rb b/spec/hardening_spec.rb index c555ab1..3023c7e 100644 --- a/spec/hardening_spec.rb +++ b/spec/hardening_spec.rb @@ -1,6 +1,5 @@ -# encoding: utf-8 # -# Copyright 2015, Hardening Framework Team +# Copyright:: 2015, Hardening Framework Team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,7 +22,7 @@ { os_name: 'ubuntu', os_version: '12.04', postgres_version: '9.3' }, { os_name: 'ubuntu', os_version: '14.04', postgres_version: '9.3' }, { os_name: 'debian', os_version: '6.0.5', postgres_version: '9.3' }, - { os_name: 'debian', os_version: '7.5', postgres_version: '9.3' } + { os_name: 'debian', os_version: '7.5', postgres_version: '9.3' }, ] platforms.each do |platform| @@ -45,11 +44,11 @@ stub_command("ls -l /var/lib/postgresql/#{@postgres_version}/main/server.crt |grep /etc/ssl/certs/ssl-cert-snakeoil.pem").and_return(true) stub_command("ls -l /var/lib/postgresql/#{@postgres_version}/main/server.key |grep /etc/ssl/private/ssl-cert-snakeoil.key").and_return(true) - expect(chef_run).to create_directory('/var/lib/postgresql/'). - with(mode: '0700') + expect(chef_run).to create_directory('/var/lib/postgresql/') + .with(mode: '0700') - expect(chef_run).to create_directory("/var/lib/postgresql/#{@postgres_version}"). - with(mode: '0700') + expect(chef_run).to create_directory("/var/lib/postgresql/#{@postgres_version}") + .with(mode: '0700') end it 'deletes links if commands return true' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index efd8dd4..f2ba466 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,5 @@ -# encoding: utf-8 # -# Copyright 2015, Hardening Framework Team +# Copyright:: 2015, Hardening Framework Team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,4 +21,3 @@ # coverage report Coveralls.wear! -at_exit { ChefSpec::Coverage.report! }