activescaffold/active_scaffold

View on GitHub

Showing 362 of 362 total issues

Method condition_for_column has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def condition_for_column(column, value, text_search = :full)
        like_pattern = like_pattern(text_search)
        value = value.with_indifferent_access if value.is_a? Hash
        if respond_to?("condition_for_#{column.name}_column")
          return send("condition_for_#{column.name}_column", column, value, like_pattern)
Severity: Minor
Found in lib/active_scaffold/finder.rb - About 1 hr to fix

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

            if (event.detail && !xhr) {
              error = event.detail[0];
              status = event.detail[1];
              xhr = event.detail[2];
            }
    Severity: Major
    Found in app/assets/javascripts/jquery/active_scaffold.js and 4 other locations - About 1 hr to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 66..70
    app/assets/javascripts/jquery/active_scaffold.js on lines 133..137
    app/assets/javascripts/jquery/active_scaffold.js on lines 189..193
    app/assets/javascripts/jquery/active_scaffold.js on lines 222..226

    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 62.

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

            if (event.detail && !xhr) {
              error = event.detail[0];
              status = event.detail[1];
              xhr = event.detail[2];
            }
    Severity: Major
    Found in app/assets/javascripts/jquery/active_scaffold.js and 4 other locations - About 1 hr to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 66..70
    app/assets/javascripts/jquery/active_scaffold.js on lines 133..137
    app/assets/javascripts/jquery/active_scaffold.js on lines 172..176
    app/assets/javascripts/jquery/active_scaffold.js on lines 222..226

    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 62.

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

            if (event.detail && !xhr) {
              error = event.detail[0];
              status = event.detail[1];
              xhr = event.detail[2];
            }
    Severity: Major
    Found in app/assets/javascripts/jquery/active_scaffold.js and 4 other locations - About 1 hr to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 133..137
    app/assets/javascripts/jquery/active_scaffold.js on lines 172..176
    app/assets/javascripts/jquery/active_scaffold.js on lines 189..193
    app/assets/javascripts/jquery/active_scaffold.js on lines 222..226

    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 62.

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

            if (event.detail && !xhr) {
              error = event.detail[0];
              status = event.detail[1];
              xhr = event.detail[2];
            }
    Severity: Major
    Found in app/assets/javascripts/jquery/active_scaffold.js and 4 other locations - About 1 hr to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 66..70
    app/assets/javascripts/jquery/active_scaffold.js on lines 172..176
    app/assets/javascripts/jquery/active_scaffold.js on lines 189..193
    app/assets/javascripts/jquery/active_scaffold.js on lines 222..226

    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 62.

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

            if (event.detail && !xhr) {
              error = event.detail[0];
              status = event.detail[1];
              xhr = event.detail[2];
            }
    Severity: Major
    Found in app/assets/javascripts/jquery/active_scaffold.js and 4 other locations - About 1 hr to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 66..70
    app/assets/javascripts/jquery/active_scaffold.js on lines 133..137
    app/assets/javascripts/jquery/active_scaffold.js on lines 172..176
    app/assets/javascripts/jquery/active_scaffold.js on lines 189..193

    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 62.

    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

    Function add has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

           add: function(newLocation, historyData) {
                   
                   var that = this;
                   
                   /*Escape the location and remove any leading hash symbols*/
    Severity: Minor
    Found in app/assets/javascripts/prototype/dhtml_history.js - About 1 hr to fix

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

        Function create_record_row has 32 lines of code (exceeds 25 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

          Method query_string_for_action_links has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def query_string_for_action_links(link)
                  if defined?(@query_string) && link.parameters.none? { |k, _| @query_string_params.include? k }
                    return [@query_string, @non_nested_query_string]
                  end
                  keep = true
          Severity: Minor
          Found in lib/active_scaffold/helpers/action_link_helpers.rb - About 1 hr to fix

            Method options_for_render_super has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def options_for_render_super(options)
                  options ||= {}
                  options[:locals] ||= {}
                  if view_stack.last
                    options[:locals] = view_stack.last[:locals].merge!(options[:locals]) if view_stack.last[:locals]
            Severity: Minor
            Found in lib/active_scaffold/extensions/action_view_rendering.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 add has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                   add: function(newLocation, historyData) {
                           
                           var that = this;
                           
                           /*Escape the location and remove any leading hash symbols*/
            Severity: Minor
            Found in app/assets/javascripts/prototype/dhtml_history.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 active_scaffold_search_range has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def active_scaffold_search_range(column, options, input_method = :text_field_tag, input_options = {}, ui_options: column.options)
                    opt_value, from_value, to_value = field_search_params_range_values(column)
            
                    select_options = active_scaffold_search_range_comparator_options(column, ui_options: ui_options)
                    text_field_size = active_scaffold_search_range_string?(column) ? 15 : 10
            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 set_includes_for_sorting has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def set_includes_for_sorting(columns, sorting)
                  sorting.each_column do |col|
                    next if sorting.constraint_columns.include? col.name
                    next unless col.includes.present? && !columns.include?(col)
                    if active_scaffold_config.model.connection.needs_order_expressions_in_select?
            Severity: Minor
            Found in lib/active_scaffold/actions/list.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 show_column_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def show_column_value(record, column)
                    value_record = column.delegated_association ? record.send(column.delegated_association.name) : record
                    return get_column_value(record, column) unless value_record
                    # check for an override helper
                    if (method = show_column_override(column))
            Severity: Minor
            Found in lib/active_scaffold/helpers/show_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

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

                    if (l.position) {
                      l.url = l.url.append_params({adapter: '_list_inline_adapter'});
                      l.tag.attr('href', l.url);
                    }
            Severity: Major
            Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/jquery/active_scaffold.js on lines 1366..1369

            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 60.

            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

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

                    if (l.position) {
                      l.url = l.url.append_params({adapter: '_list_inline_adapter'});
                      l.tag.attr('href', l.url);
                    }
            Severity: Major
            Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/jquery/active_scaffold.js on lines 1460..1463

            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 60.

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

                  def condition_for_datetime(column, value, like_pattern = nil)
                    operator = ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(value['opt']) && value['opt'] != 'BETWEEN' ? value['opt'] : nil
                    from_value, to_value = datetime_from_to(column, value)
            
                    if column.search_sql.is_a? Proc
            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 add has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def add(action, options = {})
                  link =
                    if action.is_a?(ActiveScaffold::DataStructures::ActionLink) || action.is_a?(ActiveScaffold::DataStructures::ActionLinks)
                      action
                    else
            Severity: Minor
            Found in lib/active_scaffold/data_structures/action_links.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 parse_time_with_format has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse_time_with_format(value, format, offset)
                    format.gsub!(/%-d|%-m|%_m/) { |s| s.gsub(/[-_]/, '') } # strptime fails with %-d, %-m, %_m
                    en_value = I18n.locale == :en ? value : translate_days_and_months(value, format)
                    time = Time.strptime(en_value, format)
                    offset ? time : Time.zone.local_to_utc(time).in_time_zone
            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

            Severity
            Category
            Status
            Source
            Language