activescaffold/active_scaffold

View on GitHub

Showing 296 of 296 total issues

Class Sorting has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Sorting
    include Enumerable
    include ActiveScaffold::OrmChecks

    attr_accessor :constraint_columns, :sorting_by_primary_key # sorting_by_primary_key enabled by default for postgres
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, record, 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

            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);
              var 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 682..688

      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

            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);
              var 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 689..695

      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_select has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

            def active_scaffold_search_select(column, html_options, options = {}, ui_options: column.options)
              record = html_options.delete(:object)
              associated = html_options.delete :value
              if include_null_comparators?(column, ui_options: ui_options)
                range_opts = html_options.slice(:name, :id)
      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

      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}")
      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

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

          def clause(grouped_columns = nil)
            return nil if sorts_by_method? || default_sorting?
      
            # unless the sorting is by method, create the sql string
            order = []
      Severity: Minor
      Found in lib/active_scaffold/data_structures/sorting.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 active_scaffold has a Cognitive Complexity of 20 (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 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 authorized_for? has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

                def authorized_for?(options = {})
                  raise ArgumentError, "unknown crud type #{options[:crud_type]}" if options[:crud_type] && %i[create read update delete].exclude?(options[:crud_type])
        
                  not_authorized_reason = ActiveRecordPermissions.not_authorized_reason
                  # collect other possibly-related methods that actually exist
        Severity: Minor
        Found in lib/active_scaffold/active_record_permissions.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 active_scaffold_input_radio has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

              def active_scaffold_input_radio(column, html_options, ui_options: column.options)
                record = html_options[:object]
                html_options.merge!(ui_options[:html_options] || {})
                options =
                  if column.association
        Severity: Minor
        Found in lib/active_scaffold/helpers/form_column_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

        Method active_scaffold_search_for has a Cognitive Complexity of 18 (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 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 condition_for_column has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

              def condition_for_column(column, value, text_search, session)
                like_pattern = like_pattern(text_search)
                value = value.with_indifferent_access if value.is_a? Hash
                column_method = "condition_for_#{column.name}_column"
                if respond_to?(column_method)
        Severity: Minor
        Found in lib/active_scaffold/finder.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 association_options_find has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

              def association_options_find(association, conditions = nil, klass = nil, record = nil)
                if klass.nil? && association.polymorphic?
                  class_name = record.send(association.foreign_type) if association.belongs_to?
                  return [] if class_name.blank?
        
        
        Severity: Minor
        Found in lib/active_scaffold/helpers/association_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

        Method process_action_link_action has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_action_link_action(render_action = :action_update, crud_type_or_security_options = nil)
              if request.get? || request.head?
                # someone has disabled javascript, we have to show confirmation form first
                @record = find_if_allowed(params[:id], :read) if params[:id]
                respond_to_action(:action_confirmation)
        Severity: Minor
        Found in lib/active_scaffold/actions/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

        Method active_scaffold_render_subform_column has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

              def active_scaffold_render_subform_column(column, scope, crud_type, readonly, add_class = false, record = nil) # rubocop:disable Metrics/ParameterLists
                if add_class
                  col_class = []
                  col_class << 'required' if column.required?(action_for_validation?(record))
                  col_class << column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc)
        Severity: Minor
        Found in lib/active_scaffold/helpers/form_column_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

        Method active_scaffold_controller_for has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.active_scaffold_controller_for(klass, controller_namespace = '::')
              error_message = []
              class_names = [klass.to_s, klass.to_s.demodulize].map { |k| k.underscore.pluralize }.map { |k| [k, k.singularize] }.flatten
              [controller_namespace, ''].each do |namespace|
                class_names.each do |controller_name|
        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

        Method active_scaffold_human_condition_select has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

              def active_scaffold_human_condition_select(column, associated)
                attribute = column.label
                if associated.is_a?(Hash)
                  return active_scaffold_human_condition_range(column, associated) unless associated['opt'] == '='
        
        
        Severity: Minor
        Found in lib/active_scaffold/helpers/human_condition_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