dice-cyfronet/atmosphere

View on GitHub

Showing 37 of 52 total issues

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

    def initialize(user, load_admin_abilities = true, pdp_class = nil)
      @pdp_class = pdp_class

      @ability_builders = ability_builder_classes.map do |builder_class|
        builder_class.new(self, user, pdp_class)
Severity: Minor
Found in app/models/atmosphere/ability.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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    alert = nil
    params[:virtual_machine_flavor][:hourly_cost].each do |os_family_id, cost|
      os_family = Atmosphere::OSFamily.find_by(id: os_family_id)
      if cost.strip.empty? &&
Severity: Minor
Found in app/controllers/atmosphere/admin/virtual_machine_flavors_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 add_dnat_for_vm has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def add_dnat_for_vm(vm, pmts)
      pmt_map = {}
      to_add = pmts.collect {|pmt|
        if not pmt.target_port.in? MIN_PORT_NO..MAX_PORT_NO
          Rails.logger.error "Error when trying to add redirections for VM #{vm.uuid} with IP #{vm.ip}. Requested redirection for forbidden port #{pmt.target_port}"
Severity: Minor
Found in app/services/atmosphere/dnat_wrangler.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 add_dnat has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def add_dnat
      return unless ip?
      pmts = nil
      if appliances.first && appliances.first.development?
        pmts = appliances.first.dev_mode_property_set.port_mapping_templates
Severity: Minor
Found in app/models/atmosphere/virtual_machine.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 create_or_update_http_mappings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def create_or_update_http_mappings
        to_update, to_remove = [], []
        port_mapping_templates.each do |pmt|
          to_update << update_for_pmt(pmt, 'http') if pmt.http?
          to_update << update_for_pmt(pmt, 'https') if pmt.https?
Severity: Minor
Found in app/services/atmosphere/proxy/appliance_proxy_updater.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

Avoid deeply nested control flow statements.
Open

                BillingLog.new(timestamp: Time.now.utc, user: appl.appliance_set.user, appliance: appl.id.to_s+'---'+(appl.name.blank? ? 'unnamed_appliance' : appl.name), fund: appl.fund.name, message: "Error saving appliance following update of billing information.", actor: "bill_appliance", amount_billed: 0).save
Severity: Major
Found in app/services/atmosphere/billing_service.rb - About 45 mins to fix

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

        def create_dev_mode_property_set(options={})
          unless dev_mode_property_set
            set = DevModePropertySet.create_from(appliance_type)
            set.preference_memory = options[:preference_memory] if options[:preference_memory]
            set.preference_cpu = options[:preference_cpu] if options[:preference_cpu]
    Severity: Minor
    Found in app/models/atmosphere/appliance.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

    Avoid deeply nested control flow statements.
    Open

                    BillingLog.new(timestamp: Time.now.utc, user: appl.appliance_set.user, appliance: appl.id.to_s+'---'+(appl.name.blank? ? 'unnamed_appliance' : appl.name), fund: appl.fund.name, message: message, actor: "bill_appliance", amount_billed: amount_due).save
    Severity: Major
    Found in app/services/atmosphere/billing_service.rb - About 45 mins to fix

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

          def perform_update!
            vm.source_template ||= source_template
            vm.name = server.name || '[unnamed]'
            vm.state = map_saving_state(vm, server.task_state) ||
              map_state(server.state.downcase.to_sym)
      Severity: Minor
      Found in app/services/atmosphere/vm_updater.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 ensure_single_default has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def ensure_single_default
            unless default
              ufs = UserFund.where(user_id: user_id)
              if ufs.count == 0 || (ufs.count == 1 && ufs[0].id == id)
                self.default = true
      Severity: Minor
      Found in app/models/atmosphere/user_fund.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

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

              def get_candidate_tenants_for_template(tmpl)
                # Determine which tenants can be used to spawn this specific template in the context
                # of the current @appliance.
                # If @appliance is nil (which may happen) return active tenants:
                if @appliance.blank?
      Severity: Minor
      Found in app/providers/atmosphere/optimization_strategy/default.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

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

          def update_custom_proxy
            old_custom_name = custom_name_was
      
            yield
      
      
      Severity: Minor
      Found in app/models/atmosphere/http_mapping.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

      Avoid too many return statements within this method.
      Open

          return start if start_action?
      Severity: Major
      Found in app/controllers/atmosphere/api/v1/appliances_controller.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return suspend if suspend_action?
        Severity: Major
        Found in app/controllers/atmosphere/api/v1/appliances_controller.rb - About 30 mins to fix

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

                def execute
                  if optimization_strategy.can_scale_manually?
                    action.log(I18n.t('scale_appliance.start'))
                    if quantity > 0
                      vms = optimization_strategy.vms_to_start(quantity)
          Severity: Minor
          Found in app/services/atmosphere/cloud/scale_appliance.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              if @tenant.update(tenant_params)
                if @tenant.proxy_urls_changed?
                  Atmosphere::Proxy::TenantUrlUpdater.new(@tenant).update
                end
          Severity: Minor
          Found in app/controllers/atmosphere/admin/tenants_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 apply_funding_policy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.apply_funding_policy
                VirtualMachine.manageable.each do |vm|
                  # If this VM has at least one prepaid deployment, it must not be touched.
                  # For safety's sake, we will also not touch deployments whose billing state is flagged as erroneous
                  if vm.deployments.select {|dep| ['prepaid', 'error'].include? dep.billing_state}.count > 0
          Severity: Minor
          Found in app/services/atmosphere/billing_service.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

          Severity
          Category
          Status
          Source
          Language