activescaffold/active_scaffold

View on GitHub

Showing 273 of 362 total issues

Method pagination_ajax_links has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def pagination_ajax_links(current_page, url_options, options, inner_window, outer_window)
        start_number = current_page.number - inner_window
        end_number = current_page.number + inner_window
        start_number = 1 if start_number <= 0
        if current_page.pager.infinite?
Severity: Minor
Found in lib/active_scaffold/helpers/pagination_helpers.rb - About 1 hr to fix

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

            def authorized_for?(options = {})
              raise InvalidArgument if options[:crud_type].blank? && options[:action].blank?
              if current_ability.present?
                crud_type_result = options[:crud_type].nil? ? true : current_ability.can?(options[:crud_type], self)
                action_result = options[:action].nil? ? true : current_ability.can?(options[:action].to_sym, self)
    Severity: Minor
    Found in lib/active_scaffold/bridges/cancan/cancan_bridge.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 get_column_value has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

          def get_column_value(record, column)
            record = record.send(column.delegated_association.name) if column.delegated_association
            if record
              method, list_ui = get_column_method(record, column)
              value =
    Severity: Minor
    Found in lib/active_scaffold/helpers/list_column_helpers.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

    Function create_record_row has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      create_record_row: function(active_scaffold_id, html, options) {
        tbody = $(active_scaffold_id).down('tbody.records');
    
        var new_row = null;
        
    Severity: Minor
    Found in app/assets/javascripts/prototype/active_scaffold.js - 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 render_list_column has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_list_column(text, column, record)
            if column.link && !skip_action_link?(column.link, record)
              link = column.link
              associated = record.send(column.association.name) if column.association
              authorized = link.action.nil?
    Severity: Minor
    Found in lib/active_scaffold/helpers/list_column_helpers.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 setup_parent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def setup_parent(record)
          cfg = main_form_controller.active_scaffold_config
          association = cfg.columns[subform_child_association]&.association&.reverse_association
          return if association.nil?
    
    
    Severity: Minor
    Found in lib/active_scaffold/actions/core.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 register_constraints_with_action_columns has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def register_constraints_with_action_columns(constrained_fields = nil)
          constrained_fields ||= []
          constrained_fields |= active_scaffold_constraints.select { |k, v| register_constraint?(k, v) }.keys.collect(&:to_sym)
          exclude_actions = []
          %i[list update].each do |action_name|
    Severity: Minor
    Found in lib/active_scaffold/constraints.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 conditions_from_constraints has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def conditions_from_constraints
          hash_conditions = {}
          conditions = [hash_conditions]
          active_scaffold_constraints.each do |k, v|
            column = active_scaffold_config.columns[k]
    Severity: Minor
    Found in lib/active_scaffold/constraints.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 condition_from_association_constraint has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def condition_from_association_constraint(association, value)
          # when the reverse association is a :belongs_to, the id for the associated object only exists as
          # the primary_key on the other table. so for :has_one and :has_many (when the reverse is :belongs_to),
          # we have to use the other model's primary_key.
          #
    Severity: Minor
    Found in lib/active_scaffold/constraints.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 configure_column_link has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

          def configure_column_link(link, record, associated, actions = nil)
            actions ||= link.controller_actions || []
            if column_empty?(associated) # if association is empty, we only can link to create form
              if actions.include?(:new)
                link.action = 'new'
    Severity: Minor
    Found in lib/active_scaffold/helpers/action_link_helpers.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 active_scaffold has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def active_scaffold(model_id = nil, &block)
            extend Prefixes
            # initialize bridges here
            ActiveScaffold::Bridges.run_all
    
    
    Severity: Minor
    Found in lib/active_scaffold/core.rb - About 1 hr to fix

      Function handleSubmitToServer has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          handleSubmitToServer: function(enteredText) {
              var data = '';
              if (typeof(enteredText) === 'string') {
                  data += this.settings.update_value + '=' + encodeURIComponent(enteredText) + '&';
              } else {
      Severity: Minor
      Found in app/assets/javascripts/jquery/jquery.editinplace.js - About 1 hr to fix

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

              def render_parent_action
                if @parent_action.nil?
                  @parent_action = :row
                  if parent_sti_controller
                    parent_sti_config = parent_sti_controller.active_scaffold_config
        Severity: Minor
        Found in lib/active_scaffold/helpers/controller_helpers.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 format_collection_association_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def format_collection_association_value(value, column, label_method, size)
                associated_limit = column.associated_limit
                if associated_limit.nil?
                  firsts = value.collect(&label_method)
                  safe_join firsts, association_join_text(column)
        Severity: Minor
        Found in lib/active_scaffold/helpers/list_column_helpers.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 visibles_and_hiddens has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def visibles_and_hiddens(search_config)
                visibles = []
                hiddens = []
                search_config.columns.each_column do |column|
                  next unless column.search_sql
        Severity: Minor
        Found in lib/active_scaffold/helpers/search_column_helpers.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 active_scaffold_human_condition_select has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def active_scaffold_human_condition_select(column, associated)
                attribute = column.active_record_class.human_attribute_name(column.name)
                associated = [associated].compact unless associated.is_a? Array
                if column.association
                  method = column.options[:label_method] || :to_label
        Severity: Minor
        Found in lib/active_scaffold/helpers/human_condition_helpers.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 get_action_link_id has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def get_action_link_id(link, record = nil)
                column = link.column
                if column&.association && record
                  associated = record.send(column.association.name) unless column.association.collection?
                  id =
        Severity: Minor
        Found in lib/active_scaffold/helpers/action_link_helpers.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 find_page has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def find_page(options = {})
              options.assert_valid_keys :sorting, :per_page, :page, :count_includes, :pagination, :select
              options[:per_page] ||= 999_999_999
              options[:page] ||= 1
        
        
        Severity: Minor
        Found in lib/active_scaffold/finder.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 condition_value_for_datetime has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def condition_value_for_datetime(column, value, conversion = :to_time)
                return if value.nil? || value.blank?
                if value.is_a? Hash
                  local_time_from_hash(value, conversion)
                elsif value.respond_to?(:strftime)
        Severity: Minor
        Found in lib/active_scaffold/finder.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 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(name, active_record_class, delegated_association = nil) #:nodoc:
              @name = name.to_sym
              @active_record_class = active_record_class
              @column = _columns_hash[name.to_s]
              if @column.nil? && active_record? && active_record_class._default_attributes.key?(name.to_s)
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.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