aeolusproject/conductor

View on GitHub

Showing 368 of 368 total issues

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

  def multi_destroy
    deleted = []
    not_deleted = []
    not_deleted_perms = []

Severity: Minor
Found in src/app/controllers/deployables_controller.rb - About 4 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 load_events has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def load_events
    @source_type = params[:source_type].nil? ? "" : params[:source_type]
    @pool_select = params[:pool_select].nil? ? "" : params[:pool_select]
    @provider_select =
      params[:provider_select].nil? ? "" : params[:provider_select]
Severity: Major
Found in src/app/controllers/logs_controller.rb - About 3 hrs to fix

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

    require 'viewstate.rb'
    require 'util/conductor'
    require 'will_paginate/array'
    
    class ApplicationController < ActionController::Base
    Severity: Minor
    Found in src/app/controllers/application_controller.rb - About 3 hrs to fix

      Method index has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          clear_breadcrumbs
          save_breadcrumb(pools_path(:viewstate => viewstate_id))
      
          # This is primarily relevant to filter_view, but we check @details_tab in other places:
      Severity: Minor
      Found in src/app/controllers/pools_controller.rb - About 3 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 match_hardware_profile_property has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.match_hardware_profile_property(front_end_property, back_end_property)
          # if the front_end_property is nil, we don't care about it, so everything matches:
          return true if front_end_property.nil? || front_end_property.value.to_s.empty?
          # if the back_end_property is nil, it only matches if front-end is also nil:
          return false if back_end_property.nil? || back_end_property.value.to_s.empty?
      Severity: Minor
      Found in src/app/models/hardware_profile.rb - About 3 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 update_quota has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_quota(state_from, state_to, an_instance)
          pool = an_instance.pool
          pool_family = pool.pool_family
          user = an_instance.owner
          provider_account = an_instance.provider_account
      Severity: Minor
      Found in src/app/models/instance_observer.rb - About 3 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 validate_hwp has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_hwp
          case name
          when MEMORY
            unless unit == UNIT_MB
              errors.add(:unit, "Memory must be specified in MB")
      Severity: Minor
      Found in src/app/models/hardware_profile_property.rb - About 3 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 transmit_event has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        def transmit_event
          # Extract just the old values from change_hash
          old_values = {}
          change_hash.each_pair do |k,v|
            old_values[k] = v[0]
      Severity: Minor
      Found in src/app/models/event.rb - About 3 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

      Class ProviderAccount has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class ProviderAccount < ActiveRecord::Base
      
        class << self
          include CommonFilterMethods
        end
      Severity: Minor
      Found in src/app/models/provider_account.rb - About 3 hrs to fix

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

          def self.up
            return if Role.all.empty?
            Role.transaction do
              role = Role.find_or_initialize_by_name(ROLE_NAME)
              role.update_attributes({:name => ROLE_NAME, :scope => BasePermissionObject.name, :assign_to_owner => ROLE_DEF[0]})
        src/db/migrate/20111104121803_add_hwp_global_user_role.rb on lines 31..61

        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 114.

        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

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

          def self.up
            return if Role.all.empty?
            Role.transaction do
              role = Role.find_or_initialize_by_name(ROLE_NAME)
              role.update_attributes({:name => ROLE_NAME, :scope => BasePermissionObject.name, :assign_to_owner => ROLE_DEF[0]})
        Severity: Major
        Found in src/db/migrate/20111104121803_add_hwp_global_user_role.rb and 1 other location - About 3 hrs to fix
        src/db/migrate/20111104122143_add_catalog_global_user_role.rb on lines 31..61

        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 114.

        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

        File views.js has 297 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        Conductor.Views = Conductor.Views || {}
        
        
        Conductor.Views.PoolsIndex = Backbone.View.extend({
          el: '#content',
        Severity: Minor
        Found in src/app/assets/javascripts/backbone/views.js - About 3 hrs to fix

          Method sortable_table_header has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

            def sortable_table_header(fields=[])
              columns = fields.collect do |field|
                if field[:sortable]==true or field[:sortable].nil?
                  order_dir = params[:order_dir] ? params[:order_dir] : 'desc'
                  if field[:sort_attr].to_s.eql?(params[:order_field])
          Severity: Minor
          Found in src/app/helpers/application_helper.rb - About 3 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 _fast_gettext_old_format_m has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def _fast_gettext_old_format_m(args)
                if args.kind_of?(Hash)
                  dup.gsub(INTERPOLATION_PATTERN_WITH_ESCAPE) do |match|
                    if match == '%%'
                      '%'
          Severity: Minor
          Found in src/lib/fix_string_interpolate.rb - About 3 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 index has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def index
              clear_breadcrumbs
              save_breadcrumb(pools_path(:viewstate => viewstate_id))
          
              # This is primarily relevant to filter_view, but we check @details_tab in other places:
          Severity: Major
          Found in src/app/controllers/pools_controller.rb - About 3 hrs to fix

            File provider_account.rb has 292 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class ProviderAccount < ActiveRecord::Base
            
              class << self
                include CommonFilterMethods
              end
            Severity: Minor
            Found in src/app/models/provider_account.rb - About 3 hrs to fix

              File logs_controller.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class LogsController < ApplicationController
                before_filter :require_user
              
                def index
                  clear_breadcrumbs
              Severity: Minor
              Found in src/app/controllers/logs_controller.rb - About 2 hrs to fix

                Method generate_graph has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                  def generate_graph
                    @group = params[:group].nil? ? "" : params[:group]
                
                    start_code = (@source_type == 'Deployment' ? 'first_running' : 'running')
                    end_code = (@source_type == 'Deployment' ? 'all_stopped' : 'stopped')
                Severity: Minor
                Found in src/app/controllers/logs_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 get_image_details has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                  def get_image_details
                    deployable_xml = DeployableXML.new(xml)
                    uuids = deployable_xml.image_uuids
                    images = []
                    missing_images = []
                Severity: Minor
                Found in src/app/models/deployable.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 show has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                  def show
                    @pool = Pool.find(params[:id])
                    @title = @pool.name
                    save_breadcrumb(pool_path(@pool, :viewstate => viewstate_id), @pool.name)
                    require_privilege(Alberich::Privilege::VIEW, @pool)
                Severity: Minor
                Found in src/app/controllers/pools_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

                Severity
                Category
                Status
                Source
                Language