aeolusproject/conductor

View on GitHub
src/app/models/provider.rb

Summary

Maintainability
C
1 day
Test Coverage

Method populate_realms has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

  def populate_realms
    reload

    # if the provider is not running, mark as unavailable and don't refresh its
    # realms
Severity: Minor
Found in src/app/models/provider.rb - About 5 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 populate_realms has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def populate_realms
    reload

    # if the provider is not running, mark as unavailable and don't refresh its
    # realms
Severity: Major
Found in src/app/models/provider.rb - About 2 hrs to fix

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

      def imagefactory_info
        if provider_type.deltacloud_driver == 'openstack'
          # TODO: We might want to pull this up to the Provider, really
          acct = provider_accounts.first
          uri = URI.parse(acct.credentials_hash['glance_url'])
    Severity: Minor
    Found in src/app/models/provider.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 disable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def disable(user)
        res = {}
        if valid_framework?
          # if we can connect to the provider, try to stop running instances
          # TODO: now provider is disabled even if stop request fails, is it ok?
    Severity: Minor
    Found in src/app/models/provider.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 valid_provider? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def valid_provider?
        if deltacloud_provider.present?
          client = connect
          return false if client.nil?
          return false unless client.driver(provider_type.deltacloud_driver).valid_provider? deltacloud_provider
    Severity: Minor
    Found in src/app/models/provider.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