ndlib/sipity

View on GitHub

Showing 34 of 96 total issues

File processing_queries.rb has 569 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'active_support/core_ext/array/wrap'

module Sipity
  module Queries
    # Welcome intrepid developer. You have stumbled into some complex data
Severity: Major
Found in app/repositories/sipity/queries/processing_queries.rb - About 1 day to fix

Method scope_processing_entities_for_the_user_and_proxy_for_type has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def scope_processing_entities_for_the_user_and_proxy_for_type(criteria:)
        proxy_for_type = PowerConverter.convert(criteria.proxy_for_type, to: :polymorphic_type)

        entities = Models::Processing::Entity.arel_table
        strategy_state_actions = Models::Processing::StrategyStateAction.arel_table
Severity: Major
Found in app/repositories/sipity/queries/processing_queries.rb - About 3 hrs to fix

Class WorkEmailDecorator has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

      class WorkEmailDecorator
        def initialize(work, repository: default_repository)
          self.work = work
          self.repository = repository
        end
Severity: Minor
Found in app/decorators/sipity/decorators/emails/work_email_decorator.rb - About 3 hrs to fix

Function add_to_section_list has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    add_to_section_list: function( event ) {
      event.preventDefault();

      var $activeField = $('.repeat:last', this.element), // Assume we are always working with the bottom-most row
          $activeFieldControls = $activeField.children('.row-controls'),
Severity: Major
Found in app/assets/javascripts/sipity/manage_repeating_sections.js - About 2 hrs to fix

Method configure has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def self.configure(form_class:, base_class:, attribute_names:, **keywords)
        processing_form_class = self
        form_class.module_exec do
          class_attribute(:attribute_names, instance_writer: :false) unless respond_to?(:attribute_names=)
          self.attribute_names = Array.wrap(attribute_names)
Severity: Minor
Found in app/forms/sipity/forms/processing_form.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

Class AttachmentsExtension has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

      class AttachmentsExtension
        def initialize(form:, repository:, **args)
          self.form = form
          self.repository = repository
          self.files = args[:files] || {}
Severity: Minor
Found in app/forms/sipity/forms/composable_elements/attachments_extension.rb - About 2 hrs to fix

Class CoreConverter has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

        class CoreConverter
          DEFAULT_ROF_TYPE = 'fobject'.freeze
          def initialize(work:, repository: default_repository, attachment_converter: default_attachment_converter)
            self.work = work
            self.repository = repository

Class ActionTakenOnEntity has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

    class ActionTakenOnEntity
      def self.register(**keywords)
        new(**keywords).register
      end

Severity: Minor
Found in app/services/sipity/services/action_taken_on_entity.rb - About 2 hrs to fix

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

      def convert_to_year(input)
        return input if input.is_a?(Integer)
        return input.to_year if input.respond_to?(:to_year)
        return input.year if input.respond_to?(:year)
        return convert_to_year(input.to_date) if input.respond_to?(:to_date)
Severity: Minor
Found in app/conversions/sipity/conversions/convert_to_year.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 configure has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.configure(form_class:, base_class:, attribute_names:, **keywords)
        processing_form_class = self
        form_class.module_exec do
          class_attribute(:attribute_names, instance_writer: :false) unless respond_to?(:attribute_names=)
          self.attribute_names = Array.wrap(attribute_names)
Severity: Minor
Found in app/forms/sipity/forms/processing_form.rb - About 1 hr to fix

Method scope_users_for_entity_and_roles has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def scope_users_for_entity_and_roles(entity:, roles:)
        entity = Conversions::ConvertToProcessingEntity.call(entity)
        role_ids = Array.wrap(roles).map { |role| Conversions::ConvertToRole.call(role).id }
        group_polymorphic_type = PowerConverter.convert(Models::Group, to: :polymorphic_type)
        user_polymorphic_type = PowerConverter.convert(User, to: :polymorphic_type)
Severity: Minor
Found in app/repositories/sipity/queries/processing_queries.rb - About 1 hr to fix

Method call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def call
        create_the_strategy_action!

        if config.key?(:attributes)
          action_attributes = config.fetch(:attributes).stringify_keys

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 call has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def call
        create_the_strategy_action!

        if config.key?(:attributes)
          action_attributes = config.fetch(:attributes).stringify_keys

Method scope_permitted_entity_strategy_actions_for_current_state has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def scope_permitted_entity_strategy_actions_for_current_state(user:, entity:)
        action_scope = scope_permitted_without_concern_for_repetition_entity_strategy_actions_for_current_state(user: user, entity: entity)

        entity = Conversions::ConvertToProcessingEntity.call(entity)
        actor = Conversions::ConvertToProcessingActor.call(user)
Severity: Minor
Found in app/repositories/sipity/queries/processing_queries.rb - About 1 hr to fix

Method scope_actors_associated_with_entity_and_role has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def scope_actors_associated_with_entity_and_role(entity:, role:)
        entity = Conversions::ConvertToProcessingEntity.call(entity)
        role = Conversions::ConvertToRole.call(role)
        strategy_roles = Models::Processing::StrategyRole.arel_table
        strategy_responsibilities = Models::Processing::StrategyResponsibility.arel_table
Severity: Minor
Found in app/repositories/sipity/queries/processing_queries.rb - About 1 hr to fix

Method build has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.build(mailer_suffix, &block)
      builder = new
      builder.instance_exec(&block) if block_given?
      the_mailer_name = File.join('sipity/mailers', "#{mailer_suffix.to_s.underscore}_mailer")

Severity: Minor
Found in app/mailers/sipity/mailer_builder.rb - About 1 hr to fix

Function queryLdap has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function queryLdap(){
    var $button = $('#people-search-button'),
        $icon = $button.find('i'),
        query = $('#submission_window_advisor_name').val(),
        api = "//www3.nd.edu/~webdev/utilities/ldap/?callback=?",
Severity: Minor
Found in app/assets/javascripts/sipity/nd_ldap_lookup.js - About 1 hr to fix

Function add_to_list has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    add_to_list: function( event ) {
      event.preventDefault();

      var $activeField = $(event.target).parents('.field-wrapper'),
          $activeFieldControls = $activeField.children('.field-controls'),
Severity: Minor
Found in app/assets/javascripts/sipity/manage_repeating_fields.js - About 1 hr to fix

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

      def convert_to_processing_action(object, scope:)
        strategy_id = ConvertToProcessingStrategyId.call(scope)
        if object.is_a?(Models::Processing::StrategyAction)
          return object if object.strategy_id == strategy_id
        elsif object.respond_to?(:to_processing_action)
Severity: Minor
Found in app/conversions/sipity/conversions/convert_to_processing_action.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 collaborators_that_have_taken_the_action_on_the_entity has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def collaborators_that_have_taken_the_action_on_the_entity(entity:, actions:)
        entity = Conversions::ConvertToProcessingEntity.call(entity)
        collaborators = Models::Collaborator.arel_table
        users = User.arel_table
        users_scope = users_that_have_taken_the_action_on_the_entity(entity: entity, actions: actions)
Severity: Minor
Found in app/repositories/sipity/queries/processing_queries.rb - About 1 hr to fix
Severity
Category
Status
Source
Language