From 0ed440715cf07f1b65c633e61edfc308deaf5530 Mon Sep 17 00:00:00 2001 From: Cookstyle Bot Date: Mon, 17 Jan 2022 13:31:47 -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/spec_helper.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/spec/unit/recipes/default_spec.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) - **/spec/unit/recipes/hardening_spec.rb:1**: Unnecessary utf-8 encoding comment. (https://rubystyle.guide#utf-8) ### Style/RegexpLiteral - **/Guardfile:7**: 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:13**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:14**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:19**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:20**: 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) - **/Guardfile:30**: Use `%r` around regular expression. (https://rubystyle.guide#percent-r) - **/Guardfile:31**: 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) - **/metadata.rb:3**: 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/default.rb:7**: 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) - **/recipes/hardening.rb:7**: 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) ### Layout/CaseIndentation - **/attributes/default.rb:32**: Indent `when` as deep as `case`. (https://rubystyle.guide#indent-when-to-case) ### Style/ConditionalAssignment - **/attributes/default.rb:32**: Use the return of the conditional for variable assignment and comparison. ### Layout/IndentationWidth - **/attributes/default.rb:33**: Use 2 (not -41) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/attributes/default.rb:35**: Use 2 (not -41) spaces for indentation. (https://rubystyle.guide#spaces-indentation) ### Layout/ElseAlignment - **/attributes/default.rb:34**: Align `else` with `when`. ### Chef/Sharing/InvalidLicenseString - **/metadata.rb:21**: 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:23**: 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:28**: 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:29**: 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:22**: There is no need to wrap the recipe in parentheses when using the include_recipe helper (https://docs.chef.io/workstation/cookstyle/#includerecipewithparentheses) ### Layout/TrailingEmptyLines - **/spec/spec_helper.rb:23**: 1 trailing blank lines detected. (https://rubystyle.guide#newline-eof) ### Chef/Deprecations/ChefSpecCoverageReport - **/spec/spec_helper.rb:24**: Don't use the deprecated ChefSpec coverage report functionality in your specs. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_chefspeccoveragereport) ### Layout/DotPosition - **/spec/unit/recipes/hardening_spec.rb:11**: Place the . on the next line, together with the method name. (https://rubystyle.guide#consistent-multi-line-chains) - **/spec/unit/recipes/hardening_spec.rb:20**: Place the . on the next line, together with the method name. (https://rubystyle.guide#consistent-multi-line-chains) - **/spec/unit/recipes/hardening_spec.rb:28**: Place the . on the next line, together with the method name. (https://rubystyle.guide#consistent-multi-line-chains) Signed-off-by: Cookstyle --- Berksfile | 2 -- Gemfile | 2 -- Guardfile | 30 ++++++++++++++--------------- Rakefile | 2 -- attributes/default.rb | 19 +++++++++--------- attributes/hardening.rb | 7 +++---- metadata.rb | 9 ++------- recipes/default.rb | 9 ++++----- recipes/hardening.rb | 7 +++---- spec/spec_helper.rb | 4 +--- spec/unit/recipes/default_spec.rb | 2 -- spec/unit/recipes/hardening_spec.rb | 14 ++++++-------- 12 files changed, 42 insertions(+), 65 deletions(-) diff --git a/Berksfile b/Berksfile index 28636ed..dc77aab 100644 --- a/Berksfile +++ b/Berksfile @@ -1,5 +1,3 @@ -# encoding: utf-8 - source 'https://supermarket.chef.io' metadata diff --git a/Gemfile b/Gemfile index 6d10a84..96628c5 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 a595726..87002a9 100644 --- a/Guardfile +++ b/Guardfile @@ -1,32 +1,30 @@ -# encoding: utf-8 - # Guardfile 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 86dc5c9..895e92e 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 515c221..55acf33 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,10 +1,9 @@ -# encoding: utf-8 # -# Cookbook Name:: mysql-hardening +# Cookbook:: mysql-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. @@ -29,11 +28,11 @@ # path configuration default['mysql-hardening']['user'] = 'mysql' -case platform_family -when 'rhel', 'fedora' - default['mysql-hardening']['mysql-conf'] = '/etc/my.cnf' -else - default['mysql-hardening']['mysql-conf'] = '/etc/mysql/my.cnf' -end +default['mysql-hardening']['mysql-conf'] = case platform_family + when 'rhel', 'fedora' + '/etc/my.cnf' + else + '/etc/mysql/my.cnf' + end default['mysql-hardening']['hardening-conf'] = '/etc/mysql/conf.d/hardening.cnf' diff --git a/attributes/hardening.rb b/attributes/hardening.rb index eb3be02..5dd9dac 100644 --- a/attributes/hardening.rb +++ b/attributes/hardening.rb @@ -1,10 +1,9 @@ -# encoding: utf-8 # -# Cookbook Name:: mysql-hardening +# Cookbook:: mysql-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/metadata.rb b/metadata.rb index 7637018..3746b65 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,6 +1,5 @@ -# encoding: utf-8 # -# 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,16 +17,12 @@ name 'mysql-hardening' maintainer 'Christoph Hartmann' maintainer_email 'chris@lollyrock.com' -license 'Apache v2.0' +license 'Apache-2.0' description 'Installs and configures a secure mysql server' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '1.2.1' depends 'mysql', '~>5.0' -recipe 'mysql-hardening::default', 'installs a hardened mysql server' -recipe 'mysql-hardening::server', 'installs a hardened mysql server' - supports 'amazon' supports 'redhat' supports 'centos' diff --git a/recipes/default.rb b/recipes/default.rb index 451d434..f85ef24 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,10 +1,9 @@ -# encoding: utf-8 # -# Cookbook Name: mysql-hardening +# Cookbook:: Name: mysql-hardening # Recipe: default # -# Copyright 2014, Deutsche Telekom AG -# Copyright 2016, Christoph Hartmann +# Copyright:: 2014, Deutsche Telekom AG +# Copyright:: 2016, Christoph Hartmann # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,4 +18,4 @@ # limitations under the License. # -include_recipe('mysql-hardening::hardening') +include_recipe 'mysql-hardening::hardening' diff --git a/recipes/hardening.rb b/recipes/hardening.rb index 662b834..707ae92 100644 --- a/recipes/hardening.rb +++ b/recipes/hardening.rb @@ -1,10 +1,9 @@ -# encoding: utf-8 # -# Cookbook Name: mysql-hardening +# Cookbook:: Name: mysql-hardening # Recipe: hardening.rb # -# Copyright 2014, Deutsche Telekom AG -# Copyright 2016, Christoph Hartmann +# Copyright:: 2014, Deutsche Telekom AG +# Copyright:: 2016, Christoph Hartmann # # 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/spec_helper.rb b/spec/spec_helper.rb index b200451..f4470d0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,5 @@ -# encoding: utf-8 # -# 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. @@ -21,4 +20,3 @@ # coverage report Coveralls.wear! -at_exit { ChefSpec::Coverage.report! } diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index a69e9e0..ab129a9 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -1,5 +1,3 @@ -# encoding: utf-8 - require 'spec_helper' describe 'mysql-hardening::default' do diff --git a/spec/unit/recipes/hardening_spec.rb b/spec/unit/recipes/hardening_spec.rb index ab3d337..80b3e51 100644 --- a/spec/unit/recipes/hardening_spec.rb +++ b/spec/unit/recipes/hardening_spec.rb @@ -1,5 +1,3 @@ -# encoding: utf-8 - require 'spec_helper' describe 'mysql-hardening::hardening' do @@ -8,8 +6,8 @@ end it 'should create a my.cnf file and protect it' do - expect(chef_run).to create_file(chef_run.node['mysql-hardening']['mysql-conf']). - with( + expect(chef_run).to create_file(chef_run.node['mysql-hardening']['mysql-conf']) + .with( mode: '600', owner: 'root', group: 'root' @@ -17,16 +15,16 @@ end it 'should create a hardening.cnf with the hardening configuration from a template' do - expect(chef_run).to create_template(chef_run.node['mysql-hardening']['hardening-conf']). - with( + expect(chef_run).to create_template(chef_run.node['mysql-hardening']['hardening-conf']) + .with( owner: chef_run.node['mysql-hardening']['user'], mode: '750' ) end it 'should create the data directory and ensure permission' do - expect(chef_run).to create_directory(chef_run.node['mysql']['data_dir']). - with( + expect(chef_run).to create_directory(chef_run.node['mysql']['data_dir']) + .with( owner: chef_run.node['mysql-hardening']['user'], mode: '755' )