maestrano/maestrano-connector-rails

View on GitHub

Showing 41 of 41 total issues

File entity.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Maestrano::Connector::Rails::Concerns::Entity
  extend ActiveSupport::Concern

  module ClassMethods
    # ----------------------------------------------
Severity: Minor
Found in app/models/maestrano/connector/rails/concerns/entity.rb - About 3 hrs to fix

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

      def perform(organization_id, opts = {})
        organization = Maestrano::Connector::Rails::Organization.find(organization_id)
        return unless organization&.sync_enabled
    
        # Check if previous synchronization is still running
    Severity: Minor
    Found in app/jobs/maestrano/connector/rails/concerns/synchronization_job.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_connec_entities has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_connec_entities(last_synchronization_date = nil)
        return [] if @opts[:__skip_connec] || !self.class.can_read_connec?
    
        Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "Fetching Connec! #{self.class.connec_entity_name}")
    
    
    Severity: Minor
    Found in app/models/maestrano/connector/rails/concerns/entity.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 batch_calls has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def batch_calls(array_with_idmap, proc, connec_entity_name, id_update_only = false)
          request_per_call = @opts[:request_per_batch_call] || 50
          start = 0
          while start < array_with_idmap.size
            # Prepare batch request
    Severity: Minor
    Found in app/models/maestrano/connector/rails/concerns/entity.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 apply_template! has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def apply_template!
    
      check_compatible_rails_version
      ensure_valid_options
    
    
    Severity: Major
    Found in template/maestrano_connector_template.rb - About 2 hrs to fix

      Method consolidate_connec_entities has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def consolidate_connec_entities(connec_entities, external_entities, references, external_entity_name)
            connec_entities.map do |entity|
              # Entity has been created before date filtering limit
              next if before_date_filtering_limit?(entity, false) && !@opts[:full_sync]
      
      
      Severity: Minor
      Found in app/models/maestrano/connector/rails/services/data_consolidator.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 perform has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def perform(organization, entities_hash, opts = {})
            return unless organization.sync_enabled && organization.oauth_uid
      
            connec_client = Maestrano::Connector::Rails::ConnecHelper.get_client(organization)
            external_client = Maestrano::Connector::Rails::External.get_client(organization)
      Severity: Minor
      Found in app/jobs/maestrano/connector/rails/push_to_connec_job.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 snake_name has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.snake_name(entity)
            class_name = entity.class.name.underscore.split('/').last
            if entity.is_a?(Maestrano::Connector::Rails::SubEntityBase)
              name = ''
              Entities.constants&.each do |c|
      Severity: Minor
      Found in app/helpers/maestrano/connector/rails/entity_helper.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 perform has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def perform(organization_id, opts = {})
          organization = Maestrano::Connector::Rails::Organization.find(organization_id)
          return unless organization&.sync_enabled
      
          # Check if previous synchronization is still running
      Severity: Minor
      Found in app/jobs/maestrano/connector/rails/concerns/synchronization_job.rb - About 1 hr to fix

        Method unfold_references_helper has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def unfold_references_helper(entity, array_of_refs, organization)
              ref = array_of_refs.shift
              field = entity[ref]
        
              # Unfold the id
        Severity: Minor
        Found in app/models/maestrano/connector/rails/concerns/connec_helper.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 consolidate_external_entities has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def consolidate_external_entities(external_entities, connec_entity_name)
              external_entities.map do |entity|
                # Entity has been created before date filtering limit
                next if before_date_filtering_limit?(entity) && !@opts[:full_sync]
        
        
        Severity: Minor
        Found in app/models/maestrano/connector/rails/services/data_consolidator.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 notifications has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def notifications
            begin
              params.except(:tenant, :controller, :action, :connec).each do |entity_name, entities|
                entity_class_hash = find_entity_class(entity_name)
                next Maestrano::Connector::Rails::ConnectorLogger.log('info', nil, "Received notification from Connec! for unknow entity: #{entity_name}") unless entity_class_hash
        Severity: Minor
        Found in app/controllers/maestrano/connec_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 push_entity_to_external has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def push_entity_to_external(mapped_connec_entity_with_idmap, external_entity_name)
            idmap = mapped_connec_entity_with_idmap[:idmap]
            mapped_connec_entity = mapped_connec_entity_with_idmap[:entity]
            id_refs_only_connec_entity = mapped_connec_entity_with_idmap[:id_refs_only_connec_entity]
        
        
        Severity: Minor
        Found in app/models/maestrano/connector/rails/concerns/entity.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 consolidate_singleton has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def consolidate_singleton(connec_entities, external_entities)
              return {connec_entities: [], external_entities: []} if external_entities.empty? && connec_entities.empty?
        
              idmap = @current_entity.class.find_or_create_idmap(organization_id: @organization.id)
              # No to_connec, to_external and inactive consideration here as we don't expect those workflow for singleton
        Severity: Minor
        Found in app/models/maestrano/connector/rails/services/data_consolidator.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 push_entity_to_external has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def push_entity_to_external(mapped_connec_entity_with_idmap, external_entity_name)
            idmap = mapped_connec_entity_with_idmap[:idmap]
            mapped_connec_entity = mapped_connec_entity_with_idmap[:entity]
            id_refs_only_connec_entity = mapped_connec_entity_with_idmap[:id_refs_only_connec_entity]
        
        
        Severity: Minor
        Found in app/models/maestrano/connector/rails/concerns/entity.rb - About 1 hr to fix

          Method get_connec_entities has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def get_connec_entities(last_synchronization_date = nil)
              return [] if @opts[:__skip_connec] || !self.class.can_read_connec?
          
              Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "Fetching Connec! #{self.class.connec_entity_name}")
          
          
          Severity: Minor
          Found in app/models/maestrano/connector/rails/concerns/entity.rb - About 1 hr to fix

            Method consume has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def consume
                params[:tenant] ||= 'default'
                user = Maestrano::Connector::Rails::User.find_or_create_for_maestrano(user_auth_hash, params[:tenant])
                organization = Maestrano::Connector::Rails::Organization.find_or_create_for_maestrano(group_auth_hash, params[:tenant])
            
            
            Severity: Minor
            Found in app/controllers/maestrano/auth/saml_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 merge_id_hashes_helper has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def merge_id_hashes_helper(hash, array_of_refs, src, path = [])
                  ref = array_of_refs.shift
                  field = hash[ref]
            
                  if array_of_refs.empty? && field
            Severity: Minor
            Found in app/models/maestrano/connector/rails/concerns/connec_helper.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 push_entities_to_connec_to has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def push_entities_to_connec_to(mapped_external_entities_with_idmaps, connec_entity_name)
                unless @organization.push_to_connec_enabled?(self)
                  Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "#{Maestrano::Connector::Rails::External.external_name}-#{self.class.external_entity_name.pluralize} not sent to Connec! Push disabled or name not found")
                  return
                end
            Severity: Minor
            Found in app/models/maestrano/connector/rails/concerns/entity.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def initialize(attributes = nil, options = {})
                super(attributes, options)
            
                self.synchronized_entities = {}
                Maestrano::Connector::Rails::External.entities_list.each do |entity|
            Severity: Minor
            Found in app/models/maestrano/connector/rails/concerns/organization.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

            Severity
            Category
            Status
            Source
            Language