ManageIQ/manageiq-providers-openstack

View on GitHub
app/models/manageiq/providers/openstack/identity_sync_mixin.rb

Summary

Maintainability
A
2 hrs
Test Coverage
A
91%

Method create_or_find_miq_group_and_add_user has a Cognitive Complexity of 23 (exceeds 11 allowed). Consider refactoring.
Open

  def create_or_find_miq_group_and_add_user(user, tenant, role_name)
    # Find MiqGroup corresponding to this role and project/tenant
    # create one if it doesn't exist
    # add user to the MiqGroup
    admin_role_id = ext_management_system.miq_custom_get(IDENTITY_SYNC_ADMIN_ROLE_ID_NEW)
Severity: Minor
Found in app/models/manageiq/providers/openstack/identity_sync_mixin.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

Avoid more than 3 levels of block nesting.
Open

          if description_errors.size == 1 && description_errors[0].starts_with?("is not unique")
            # A group with this description already exists, probably because a user previously changed
            # the associated role. Create a timestamped description to ensure uniqueness
            miq_group.description = create_group_name(ext_management_system, tenant, this_role, true)
          end

Checks for excessive nesting of conditional and looping constructs.

You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

The maximum level of nesting allowed is configurable.

There are no issues that match your filters.

Category
Status