From 3e46bf2c8b47cd1c9175c4989b382490fd9cf842 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 13 Nov 2020 09:57:56 -0800 Subject: [PATCH] Resolve chefstyle warnings Disable the eval cop where we're doing unavoidable things Signed-off-by: Tim Smith --- bin/chef-vault | 2 +- chef-vault.gemspec | 2 +- lib/chef/knife/mixin/helper.rb | 4 ++-- lib/chef/knife/vault_admins.rb | 2 +- lib/chef/knife/vault_base.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/chef-vault b/bin/chef-vault index ca2481d..b037b8c 100755 --- a/bin/chef-vault +++ b/bin/chef-vault @@ -79,7 +79,7 @@ options_config.each do |option, config| end options_config.each do |option, config| - options[option] = options[option] ? options[option] : config[:default] + options[option] = options[option] || config[:default] end require "rubygems" unless defined?(Gem) diff --git a/chef-vault.gemspec b/chef-vault.gemspec index ad031f5..32f59b5 100644 --- a/chef-vault.gemspec +++ b/chef-vault.gemspec @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -$:.push File.expand_path("../lib", __FILE__) +$:.push File.expand_path("lib", __dir__) require "chef-vault/version" Gem::Specification.new do |s| diff --git a/lib/chef/knife/mixin/helper.rb b/lib/chef/knife/mixin/helper.rb index c60daa4..a9464b9 100644 --- a/lib/chef/knife/mixin/helper.rb +++ b/lib/chef/knife/mixin/helper.rb @@ -49,8 +49,8 @@ def values_from_json(json) # Raises `InvalidValue` if any of the json's values contain non-printable characters. def validate_json(json) begin - evaled_json = eval(json) - rescue SyntaxError => e + evaled_json = eval(json) # rubocop: disable Security/Eval + rescue SyntaxError raise ChefVault::Exceptions::InvalidValue, "#{json} is not valid JSON!" end diff --git a/lib/chef/knife/vault_admins.rb b/lib/chef/knife/vault_admins.rb index 4cfae37..df0b758 100644 --- a/lib/chef/knife/vault_admins.rb +++ b/lib/chef/knife/vault_admins.rb @@ -26,7 +26,7 @@ def admins vault_admins = Chef::Config[:knife][:vault_admins] admin_array = [Chef::Config[:node_name]] - if !vault_admins.kind_of?(Array) + unless vault_admins.is_a?(Array) ui.warn("Vault admin must be an array") end diff --git a/lib/chef/knife/vault_base.rb b/lib/chef/knife/vault_base.rb index ae9fd47..5a0d950 100644 --- a/lib/chef/knife/vault_base.rb +++ b/lib/chef/knife/vault_base.rb @@ -23,7 +23,7 @@ def self.included(includer) includer.class_eval do deps do require "chef/search/query" - require File.expand_path("../mixin/helper", __FILE__) + require File.expand_path("mixin/helper", __dir__) include ChefVault::Mixin::Helper end