theforeman/foreman_salt

View on GitHub

Showing 40 of 40 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def reject
      @proxy = find_proxy(:edit_smart_proxies_salt_keys)
      key = SmartProxies::SaltKeys.find(@proxy, params[:salt_key_id])
      if key.reject
        process_success(success_redirect: hash_for_smart_proxy_salt_keys_path(state: params[:state], expire_cache: true),
Severity: Major
Found in app/controllers/foreman_salt/salt_keys_controller.rb and 2 other locations - About 55 mins to fix
app/controllers/foreman_salt/salt_keys_controller.rb on lines 15..22
app/controllers/foreman_salt/salt_keys_controller.rb on lines 37..44

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def accept
      @proxy = find_proxy(:edit_smart_proxies_salt_keys)
      key = SmartProxies::SaltKeys.find(@proxy, params[:salt_key_id])
      if key.accept
        process_success(success_redirect: hash_for_smart_proxy_salt_keys_path(state: params[:state], expire_cache: true),
Severity: Major
Found in app/controllers/foreman_salt/salt_keys_controller.rb and 2 other locations - About 55 mins to fix
app/controllers/foreman_salt/salt_keys_controller.rb on lines 26..33
app/controllers/foreman_salt/salt_keys_controller.rb on lines 37..44

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method load_ajax_vars has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def load_ajax_vars
      @minion = Host::Base.authorized(:view_hosts, Host).find_by(id: params[:host_id])
      if @minion
        unless @minion.is_a?(Host::Managed)
          @minion      = @minion.becomes(Host::Managed)
Severity: Minor
Found in app/controllers/foreman_salt/minions_controller.rb - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method node has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def node
      enc = {}
      env = @minion.salt_environment.blank? ? 'base' : @minion.salt_environment.name
      enc['classes'] = @minion.salt_modules_for_enc

Severity: Minor
Found in app/controllers/foreman_salt/minions_controller.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Concerns
    module SaltModuleParameters
      extend ActiveSupport::Concern

      class_methods do
Severity: Minor
Found in app/controllers/foreman_salt/concerns/salt_module_parameters.rb and 1 other location - About 45 mins to fix
app/controllers/foreman_salt/concerns/salt_environment_parameters.rb on lines 2..16

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Concerns
    module SaltEnvironmentParameters
      extend ActiveSupport::Concern

      class_methods do
app/controllers/foreman_salt/concerns/salt_module_parameters.rb on lines 2..16

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method salt_modules_in_host_environment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def salt_modules_in_host_environment
        return unless salt_modules.any?

        if salt_environment
          errors.add(:base, _('Salt states must be in the environment of the host')) unless (salt_modules - salt_environment.salt_modules).empty?
Severity: Minor
Found in app/models/foreman_salt/concerns/host_managed_extensions.rb - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def_param_group :salt_attributes do
          param :hostgroup, Hash, required: true, action_aware: true do
            param :salt_environment_id, :number, desc: N_('Salt environment ID')
            param :salt_proxy_id, :number, desc: N_('Salt master/smart proxy ID')
            param :salt_state_ids, Array, desc: N_('Array of Salt state IDs')
app/controllers/foreman_salt/api/v2/salt_minions_controller.rb on lines 19..24

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def_param_group :minion do
          param :minion, Hash, required: true, action_aware: true do
            param :salt_environment_id, :number, desc: N_('Salt environment ID')
            param :salt_proxy_id, :number, desc: N_('ID of Salt Proxy')
            param :salt_state_ids, Array, desc: N_('Array of State ids')
Severity: Minor
Found in app/controllers/foreman_salt/api/v2/salt_minions_controller.rb and 1 other location - About 35 mins to fix
app/controllers/foreman_salt/api/v2/salt_hostgroups_controller.rb on lines 15..20

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method derive_salt_grains has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def derive_salt_grains(use_autosign: false)
        grains = {}
        begin
          Rails.logger.info('Derive Salt Grains from host_params and autosign_key')
          grains[autosign_grain_name] = salt_autosign_key if use_autosign && !salt_autosign_key.nil?
Severity: Minor
Found in app/models/foreman_salt/concerns/host_managed_extensions.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method load_vars_for_ajax has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def load_vars_for_ajax
          return unless @host

          @obj                    = @host
          @salt_environment       = @host.salt_environment if @host
Severity: Minor
Found in app/controllers/foreman_salt/concerns/hosts_controller_extensions.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def autosign_remove(name)
      parse(delete("autosign/#{CGI.escape(name)}"))
    rescue RestClient::ResourceNotFound
      true # entry doesn't exists anyway
    rescue StandardError => e
Severity: Minor
Found in app/lib/proxy_api/salt.rb and 1 other location - About 20 mins to fix
app/lib/proxy_api/salt.rb on lines 34..40

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def create
      setup

      if @api.autosign_create(params[:id])
        process_success(success_redirect: hash_for_smart_proxy_salt_autosign_index_path, success_msg: _("Autosign created for #{params[:id]}"),
Severity: Minor
Found in app/controllers/foreman_salt/salt_autosign_controller.rb and 1 other location - About 20 mins to fix
app/controllers/foreman_salt/salt_autosign_controller.rb on lines 24..31

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def destroy
      setup

      if @api.autosign_remove(params[:id])
        process_success(success_redirect: hash_for_smart_proxy_salt_autosign_index_path, success_msg: _("Autosign deleted for #{params[:id]}"),
Severity: Minor
Found in app/controllers/foreman_salt/salt_autosign_controller.rb and 1 other location - About 20 mins to fix
app/controllers/foreman_salt/salt_autosign_controller.rb on lines 13..20

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def autosign_remove_key(key)
      parse(delete("autosign_key/#{CGI.escape(key)}"))
    rescue RestClient::ResourceNotFound
      true # entry doesn't exists anyway
    rescue StandardError => e
Severity: Minor
Found in app/lib/proxy_api/salt.rb and 1 other location - About 20 mins to fix
app/lib/proxy_api/salt.rb on lines 20..26

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if params[:hostgroup][:salt_environment_id].present?
          @salt_environment = ::ForemanSalt::SaltEnvironment.friendly.find(params[:hostgroup][:salt_environment_id])
          load_vars_for_ajax
          render partial: 'foreman_salt/salt_modules/host_tab_pane'
        else
app/controllers/foreman_salt/minions_controller.rb on lines 31..36

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      if params[:host][:salt_environment_id].present?
        @salt_environment = ::ForemanSalt::SaltEnvironment.friendly.find(params[:host][:salt_environment_id])
        load_ajax_vars
        render partial: 'foreman_salt/salt_modules/host_tab_pane'
      else
Severity: Minor
Found in app/controllers/foreman_salt/minions_controller.rb and 1 other location - About 15 mins to fix
app/controllers/foreman_salt/concerns/hostgroups_controller_extensions.rb on lines 30..35

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      def accept
        proxy = SmartProxy.find(smart_proxy_id)
        Rails.cache.delete("saltkeys_#{proxy.id}") if Rails.env.production?
        ProxyAPI::Salt.new(url: proxy.url).key_accept name
Severity: Minor
Found in app/services/foreman_salt/smart_proxies/salt_keys.rb and 2 other locations - About 15 mins to fix
app/services/foreman_salt/smart_proxies/salt_keys.rb on lines 40..43
app/services/foreman_salt/smart_proxies/salt_keys.rb on lines 46..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      def delete
        proxy = SmartProxy.find(smart_proxy_id)
        Rails.cache.delete("saltkeys_#{proxy.id}") if Rails.env.production?
        ProxyAPI::Salt.new(url: proxy.url).key_delete name
Severity: Minor
Found in app/services/foreman_salt/smart_proxies/salt_keys.rb and 2 other locations - About 15 mins to fix
app/services/foreman_salt/smart_proxies/salt_keys.rb on lines 34..37
app/services/foreman_salt/smart_proxies/salt_keys.rb on lines 40..43

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      def reject
        proxy = SmartProxy.find(smart_proxy_id)
        Rails.cache.delete("saltkeys_#{proxy.id}") if Rails.env.production?
        ProxyAPI::Salt.new(url: proxy.url).key_reject name
Severity: Minor
Found in app/services/foreman_salt/smart_proxies/salt_keys.rb and 2 other locations - About 15 mins to fix
app/services/foreman_salt/smart_proxies/salt_keys.rb on lines 34..37
app/services/foreman_salt/smart_proxies/salt_keys.rb on lines 46..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language