activescaffold/active_scaffold

View on GitHub

Showing 374 of 374 total issues

Method active_scaffold_render_input has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def active_scaffold_render_input(column, options)
        record = options[:object]

        # first, check if the dev has created an override for this specific field
        if (method = override_form_field(column))
Severity: Minor
Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 3 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

File search_column_helpers.rb has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveScaffold
  module Helpers
    # Helpers that assist with the rendering of a Form Column
    module SearchColumnHelpers
      # This method decides which input to use for the given column.
Severity: Minor
Found in lib/active_scaffold/helpers/search_column_helpers.rb - About 3 hrs to fix

    Class Tableless has 31 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
      class AssociationScope < ActiveRecord::Associations::AssociationScope
        INSTANCE = create
        def self.scope(association, connection)
          INSTANCE.scope association, connection
    Severity: Minor
    Found in lib/active_scaffold/tableless.rb - About 3 hrs to fix

      Function update_column has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        update_column: function(element, url, send_form, source_id, val, additional_params) {
          if (!element) element = jQuery('#' + source_id);
          var as_form = element.closest('form.as_form');
          var params = null;
      
      
      Severity: Minor
      Found in app/assets/javascripts/jquery/active_scaffold.js - About 3 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_constraints_to_record has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def apply_constraints_to_record(record, options = {})
            options[:allow_autosave] = false if options[:allow_autosave].nil?
            constraints = options[:constraints] || active_scaffold_constraints
      
            config = record.is_a?(active_scaffold_config.model) ? active_scaffold_config : active_scaffold_config_for(record.class)
      Severity: Minor
      Found in lib/active_scaffold/constraints.rb - About 3 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 Core has 30 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Core < ActiveScaffold::Config::Base
          include ActiveScaffold::OrmChecks
          # global level configuration
          # --------------------------
      
      
      Severity: Minor
      Found in lib/active_scaffold/config/core.rb - About 3 hrs to fix

        Method active_scaffold has a Cognitive Complexity of 25 (exceeds 5 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 3 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 pagination_ajax_links has a Cognitive Complexity of 24 (exceeds 5 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 3 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 Sorting has 28 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Sorting
            include Enumerable
            include ActiveScaffold::OrmChecks
        
            attr_accessor :constraint_columns
        Severity: Minor
        Found in lib/active_scaffold/data_structures/sorting.rb - About 3 hrs to fix

          Method action_link_html_options has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

                def action_link_html_options(link, record, options)
                  link_id = get_action_link_id(link, record)
                  html_options = link.html_options.merge(:class => [link.html_options[:class], link.action.to_s].compact.join(' '))
                  html_options[:link] = action_link_text(link, options)
          
          
          Severity: Minor
          Found in lib/active_scaffold/helpers/action_link_helpers.rb - About 3 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

          Function in_place_editor_field_clicked has 81 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            in_place_editor_field_clicked: function(span) {
              // test editor is open
              if (typeof(span.data('editInPlace')) === 'undefined') {
                var options = {show_buttons: true,
                    hover_class: 'hover',
          Severity: Major
          Found in app/assets/javascripts/jquery/active_scaffold.js - About 3 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              decrement_record_count: function(scaffold) {
                // decrement the last record count, firsts record count are in nested lists
                if (typeof(scaffold) == 'string') scaffold = '#' + scaffold;
                scaffold = jQuery(scaffold);
                count = scaffold.find('span.active-scaffold-records').last();
            Severity: Major
            Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 3 hrs to fix
            app/assets/javascripts/jquery/active_scaffold.js on lines 648..654

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 98.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              increment_record_count: function(scaffold) {
                // increment the last record count, firsts record count are in nested lists
                if (typeof(scaffold) == 'string') scaffold = '#' + scaffold;
                scaffold = jQuery(scaffold);
                count = scaffold.find('span.active-scaffold-records').last();
            Severity: Major
            Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 3 hrs to fix
            app/assets/javascripts/jquery/active_scaffold.js on lines 641..647

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 98.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method active_scaffold_search_for has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                  def active_scaffold_search_for(column, options = nil)
                    options ||= active_scaffold_search_options(column)
                    search_columns = active_scaffold_config.field_search.columns.visible_columns_names
                    options = update_columns_options(column, nil, options, form_columns: search_columns, url_params: {form_action: :field_search})
                    record = options[:object]
            Severity: Minor
            Found in lib/active_scaffold/helpers/search_column_helpers.rb - About 3 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 display_action_link has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                  def display_action_link(link, content, record, options)
                    if content
                      html_classes = hover_via_click? ? 'hover_click ' : ''
                      if (options[:level]).zero?
                        html_classes << 'action_group'
            Severity: Minor
            Found in lib/active_scaffold/helpers/action_link_helpers.rb - About 3 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              set_opened: function() {
                if (this.position == 'after') {
                  this.set_adapter(this.target.next());
                }
                else if (this.position == 'before') {
            Severity: Major
            Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 3 hrs to fix
            app/assets/javascripts/prototype/active_scaffold.js on lines 1110..1118

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 95.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              set_opened: function() {
                if (this.position == 'after') {
                  this.set_adapter(this.target.next());
                }
                else if (this.position == 'before') {
            Severity: Major
            Found in app/assets/javascripts/prototype/active_scaffold.js and 1 other location - About 3 hrs to fix
            app/assets/javascripts/jquery/active_scaffold.js on lines 1426..1434

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 95.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method link_for_association has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                  def link_for_association(column, options = {})
                    return if (controller = active_scaffold_controller_for_column(column, options)).nil?
                    options.reverse_merge! :position => :after, :type => :member, :column => column,
                                           :controller => (controller == :polymorph ? controller : "/#{controller.controller_path}")
                    options[:parameters] ||= {}
            Severity: Minor
            Found in lib/active_scaffold/core.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 ActionLink has 25 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class ActionLink
                NO_OPTIONS = {}.freeze
            
                # provides a quick way to set any property of the object from a hash
                def initialize(action, options = {})
            Severity: Minor
            Found in lib/active_scaffold/data_structures/action_link.rb - About 2 hrs to fix

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

                    def display_action_links(action_links, record, options, &block)
                      options[:level_0_tag] ||= nil
                      options[:options_level_0_tag] ||= nil
                      options[:level] ||= 0
                      options[:first_action] = true
              Severity: Minor
              Found in lib/active_scaffold/helpers/action_link_helpers.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

              Severity
              Category
              Status
              Source
              Language