aeolusproject/conductor

View on GitHub
src/app/controllers/hardware_profiles_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

File hardware_profiles_controller.rb has 353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class HardwareProfilesController < ApplicationController
  before_filter :require_user
  before_filter :load_hardware_profiles, :only => [:index, :show]
  before_filter :setup_new_hardware_profile, :only => [:new]
  before_filter :setup_hardware_profile, :only => [:new, :create, :matching_provider_hardware_profiles, :edit, :update]
Severity: Minor
Found in src/app/controllers/hardware_profiles_controller.rb - About 4 hrs to fix

    Method update_cost has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def update_cost
        redirect_to hardware_profiles_path unless params[:id]
    
        @hardware_profile = HardwareProfile.find(params[:id])
        require_privilege(Alberich::Privilege::MODIFY, @hardware_profile)
    Severity: Minor
    Found in src/app/controllers/hardware_profiles_controller.rb - About 1 hr to fix

      Method update_cost has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_cost
          redirect_to hardware_profiles_path unless params[:id]
      
          @hardware_profile = HardwareProfile.find(params[:id])
          require_privilege(Alberich::Privilege::MODIFY, @hardware_profile)
      Severity: Minor
      Found in src/app/controllers/hardware_profiles_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 destroy has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def destroy
          @hardware_profile = HardwareProfile.find(params[:id])
          require_privilege(Alberich::Privilege::MODIFY, @hardware_profile)
      
          if @hardware_profile.provider_hardware_profile?
      Severity: Minor
      Found in src/app/controllers/hardware_profiles_controller.rb - About 1 hr to fix

        Method show has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def show
            @hardware_profile = HardwareProfile.find(Array(params[:id]).first)
            require_privilege(Alberich::Privilege::VIEW, @hardware_profile)
            @title = if @hardware_profile.provider_hardware_profile?
                       _('%s (Provider)') % @hardware_profile.name
        Severity: Minor
        Found in src/app/controllers/hardware_profiles_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 load_hardware_profiles has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def load_hardware_profiles
            sort_order = sort_direction
            sort_field = sort_column(HardwareProfile, 'name')
            if sort_field == "name"
              @hardware_profiles = HardwareProfile.where('provider_id IS NULL', {}).
        Severity: Minor
        Found in src/app/controllers/hardware_profiles_controller.rb - About 1 hr to fix

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

            def multi_destroy
              deleted=[]
              not_deleted=[]
          
              HardwareProfile.find(params[:hardware_profile_selected]).each do |hwp|
          Severity: Minor
          Found in src/app/controllers/hardware_profiles_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