theforeman/foreman

View on GitHub
app/controllers/smart_proxies_controller.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Class SmartProxiesController has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class SmartProxiesController < ApplicationController
  include Foreman::Controller::AutoCompleteSearch
  include Foreman::Controller::Parameters::SmartProxy

  before_action :find_resource, :only => [:show, :edit, :update, :refresh, :ping, :tftp_server, :destroy, :log_pane, :failed_modules, :errors_card, :modules_card, :expire_logs]
Severity: Minor
Found in app/controllers/smart_proxies_controller.rb - About 2 hrs to fix

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

      def expire_logs
        from = (params[:from].to_i rescue 0) || 0
        if from >= 0
          logger.debug "Expired smart-proxy logs, new timestamp is #{from}"
          @smart_proxy.expired_logs = from.to_s
    Severity: Minor
    Found in app/controllers/smart_proxies_controller.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 refresh has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def refresh
        old_features = @smart_proxy.feature_details
        if @smart_proxy.refresh.blank? && @smart_proxy.save
          msg = (@smart_proxy.reload.feature_details == old_features) ? _("No changes found when refreshing features from %s.") : _("Successfully refreshed features from %s.")
          process_success :object => @smart_proxy, :success_msg => msg % @smart_proxy.name
    Severity: Minor
    Found in app/controllers/smart_proxies_controller.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

    There are no issues that match your filters.

    Category
    Status