maestrano/maestrano-connector-rails

View on GitHub

Showing 37 of 41 total issues

Method notifications has 26 lines of code (exceeds 25 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

    Method batch_calls has 26 lines of code (exceeds 25 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 1 hr to fix

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

            def find_entity_instance(entity_name, organization, connec_client, external_client, opts)
              Maestrano::Connector::Rails::External.entities_list.each do |entity_name_from_list|
                clazz = "Entities::#{entity_name_from_list.singularize.titleize.split.join}".constantize
                if clazz.methods.include?('external_entities_names'.to_sym)
                  return {instance: clazz.new(organization, connec_client, external_client, opts), is_complex: true, name: entity_name_from_list} if clazz.external_entities_names.include?(entity_name)
      Severity: Minor
      Found in app/jobs/maestrano/connector/rails/push_to_connec_job.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 map_to has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def map_to(name, entity, idmap = nil)
          first_time_mapped = self.class.external? ? idmap&.last_push_to_connec.nil? : idmap&.last_push_to_external.nil?
          mapper = first_time_mapped ? self.class.creation_mapper_classes[name] : self.class.mapper_classes[name]
          raise "Impossible mapping from #{self.class.entity_name} to #{name}" unless mapper
      
      
      Severity: Minor
      Found in app/models/maestrano/connector/rails/concerns/sub_entity_base.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 first_sync_entity has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def first_sync_entity(entity_name, organization, connec_client, external_client, last_synchronization_date, opts, external = true)
      Severity: Major
      Found in app/jobs/maestrano/connector/rails/concerns/synchronization_job.rb - About 50 mins to fix

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

              def self.generate_composite_filters
                _allowed_filters.keys.each do |key|
                  # iterating through all the api operator and adding them as custom filter
                  # name.gt, name.like etc...
                  next unless _model_class
        Severity: Minor
        Found in app/resources/maestrano/api/base_resource.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 sync_entity has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def sync_entity(entity_name, organization, connec_client, external_client, last_synchronization_date, opts)
        Severity: Minor
        Found in app/jobs/maestrano/connector/rails/concerns/synchronization_job.rb - About 45 mins to fix

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

            def first_sync_entity(entity_name, organization, connec_client, external_client, last_synchronization_date, opts, external = true)
              limit = Settings.first_sync_batch_size || 50
              skip = 0
              entities_count = limit
              last_first_record = nil
          Severity: Minor
          Found in app/jobs/maestrano/connector/rails/concerns/synchronization_job.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 instantiate_sub_entity_instance has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def instantiate_sub_entity_instance(entity_name, organization, connec_client, external_client, opts)
          Severity: Minor
          Found in app/models/maestrano/connector/rails/concerns/complex_entity.rb - About 35 mins to fix

            Method find_entity_instance has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def find_entity_instance(entity_name, organization, connec_client, external_client, opts)
            Severity: Minor
            Found in app/jobs/maestrano/connector/rails/push_to_connec_job.rb - About 35 mins to fix

              Method find_complex_entity_and_instantiate_external_sub_entity_instance has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def find_complex_entity_and_instantiate_external_sub_entity_instance(entity_name, organization, connec_client, external_client, opts)
              Severity: Minor
              Found in app/models/maestrano/connector/rails/concerns/complex_entity.rb - About 35 mins to fix

                Method solve_conflict has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def solve_conflict(connec_entity, external_entities, external_entity_name, idmap, id_refs_only_connec_entity)
                Severity: Minor
                Found in app/models/maestrano/connector/rails/services/data_consolidator.rb - About 35 mins to fix

                  Method instanciate_entity has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def instanciate_entity(entity_name, organization, connec_client, external_client, opts)
                  Severity: Minor
                  Found in app/jobs/maestrano/connector/rails/concerns/synchronization_job.rb - About 35 mins to fix

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

                    def ensure_valid_options
                      valid_options = {
                        skip_gemfile: false,
                        skip_bundle: false,
                        skip_git: false
                    Severity: Minor
                    Found in template/maestrano_connector_template.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 find_entity_class has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def find_entity_class(entity_name)
                          parametrised_entity_name = entity_name.parameterize('_').pluralize
                          Maestrano::Connector::Rails::External.entities_list.each do |entity_name_from_list|
                            clazz = "Entities::#{entity_name_from_list.singularize.titleize.split.join}".constantize
                            if clazz.methods.include?('connec_entities_names'.to_sym)
                    Severity: Minor
                    Found in app/controllers/maestrano/connec_controller.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 solve_conflict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def solve_conflict(connec_entity, external_entities, external_entity_name, idmap, id_refs_only_connec_entity)
                          # Here the connec_entity['id'] is an external id (String) because the entity has been unfolded.
                          external_entity = external_entities.find { |entity| connec_entity['id'] == @current_entity.class.id_from_external_entity_hash(entity) }
                          # No conflict
                          return map_connec_entity_with_idmap(connec_entity, external_entity_name, idmap, id_refs_only_connec_entity) unless external_entity
                    Severity: Minor
                    Found in app/models/maestrano/connector/rails/services/data_consolidator.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def create
                            tenant = params[:tenant]
                            uid = params[:group_id]
                            opts = params[:opts] || {}
                            organization = Maestrano::Connector::Rails::Organization.find_by(uid: uid, tenant: tenant)
                    Severity: Minor
                    Found in app/controllers/maestrano/concerns/synchronizations_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

                    Severity
                    Category
                    Status
                    Source
                    Language