theforeman/foreman

View on GitHub
app/controllers/application_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Class ApplicationController has 40 methods (exceeds 20 allowed). Consider refactoring.
Open

class ApplicationController < ActionController::Base
  include ApplicationShared

  include Foreman::Controller::Flash
  include Foreman::Controller::Authorize
Severity: Minor
Found in app/controllers/application_controller.rb - About 5 hrs to fix

    File application_controller.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class ApplicationController < ActionController::Base
      include ApplicationShared
    
      include Foreman::Controller::Flash
      include Foreman::Controller::Authorize
    Severity: Minor
    Found in app/controllers/application_controller.rb - About 3 hrs to fix

      Method process_error has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def process_error(hash = {})
          hash[:object] ||= instance_variable_get("@#{controller_name.singularize}")
          if hash[:render].blank? && hash[:redirect].blank?
            case action_name
            when "create" then hash[:render] = "new"
      Severity: Minor
      Found in app/controllers/application_controller.rb - About 2 hrs 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 setup_search_options has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def setup_search_options
          @original_search_parameter = params[:search]
          params[:search] ||= ""
          params.each do |param, value|
            if param =~ /(\w+)_id$/
      Severity: Minor
      Found in app/controllers/application_controller.rb - About 2 hrs 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 taxonomy_scope has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def taxonomy_scope
          if params[controller_name.singularize.to_sym]
            @organization = Organization.find_by_id(params[controller_name.singularize.to_sym][:organization_id])
            @location     = Location.find_by_id(params[controller_name.singularize.to_sym][:location_id])
          end
      Severity: Minor
      Found in app/controllers/application_controller.rb - About 1 hr 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 process_success has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def process_success(hash = {})
          hash[:object]                 ||= instance_variable_get("@#{controller_name.singularize}")
          hash[:object_name]            ||= hash[:object].to_s
          unless hash[:success_msg]
            hash[:success_msg] = case action_name
      Severity: Minor
      Found in app/controllers/application_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 resource_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def resource_path(type)
          return '' if type.nil?
      
          path = type.pluralize.underscore + "_path"
          prefix, suffix = path.split('/', 2)
      Severity: Minor
      Found in app/controllers/application_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

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

        def sti_clean_up(e)
          require_login rescue false
          Foreman::Logging.exception("Action failed", e) unless User.current&.admin?
          @unknown_class_name = e.message.match(/subclass: '(.*)'\./)[1]
          @parent_class = e.message.match(/overwrite (.*)\.inheritance_column/)[1].constantize
      Severity: Minor
      Found in app/controllers/application_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

      There are no issues that match your filters.

      Category
      Status