diff --git a/.rubocop.yml b/.rubocop.yml index 54684b10..43ceff52 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,7 @@ inherit_from: .rubocop_todo.yml require: - rubocop-rails - rubocop-capybara + - rubocop-performance AllCops: TargetRubyVersion: 3.2 diff --git a/Gemfile b/Gemfile index a170ffe6..5c032038 100644 --- a/Gemfile +++ b/Gemfile @@ -67,6 +67,7 @@ group :linter do gem 'rubocop-rails', '~> 2.21.1' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-capybara', '~> 2.19.0' + gem 'rubocop-performance', '~> 1.19.0' end group :release do diff --git a/Gemfile.lock b/Gemfile.lock index 8f9e24ba..b64fd160 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -355,6 +355,9 @@ GEM parser (>= 3.2.1.0) rubocop-capybara (2.19.0) rubocop (~> 1.41) + rubocop-performance (1.19.1) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) rubocop-rails (2.21.1) activesupport (>= 4.2.0) rack (>= 1.1) @@ -481,6 +484,7 @@ DEPENDENCIES rspec-openapi rubocop (~> 1.56.3) rubocop-capybara (~> 2.19.0) + rubocop-performance (~> 1.19.0) rubocop-rails (~> 2.21.1) rubocop-rake (~> 0.6.0) ruby-saml diff --git a/app/models/hiera_data.rb b/app/models/hiera_data.rb index e7658476..82e255ea 100644 --- a/app/models/hiera_data.rb +++ b/app/models/hiera_data.rb @@ -69,7 +69,7 @@ def search_key(hierarchy_name, key, facts: nil) search_results[path] = { file_present: file.exist?, file_writable: file.writable?, - key_present: file.keys.include?(key), + key_present: file.keys.include?(key), # rubocop:disable Performance/InefficientHashSearch replaced_from_git: file.replaced_from_git?, value: file.content_for_key(key) } diff --git a/app/models/hiera_data/hierarchy.rb b/app/models/hiera_data/hierarchy.rb index 004a8e03..d532dc20 100644 --- a/app/models/hiera_data/hierarchy.rb +++ b/app/models/hiera_data/hierarchy.rb @@ -23,7 +23,7 @@ def name end def lookup_function - @lookup_function ||= LOOKUP_FUNCTIONS.find { |f| raw_hash.keys.include?(f) } + @lookup_function ||= LOOKUP_FUNCTIONS.find { |f| raw_hash.keys.include?(f) } # rubocop:disable Performance/InefficientHashSearch end def backend