activescaffold/active_scaffold

View on GitHub

Showing 362 of 362 total issues

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

        ActiveScaffold[(element.val() == 'null' || element.val() == 'not_null') ? 'hide' : 'show'](element.attr('id').replace(/_opt/, '_numeric'));
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 301..301

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

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

        ActiveScaffold[(element.val() == 'PAST' || element.val() == 'FUTURE') ? 'show' : 'hide'](element.attr('id').replace(/_opt/, '_trend'));
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 294..294

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

Function create_record_row has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      create_record_row: function(active_scaffold_id, html, options) {
        if (typeof(active_scaffold_id) == 'string') active_scaffold_id = '#' + active_scaffold_id;
        var tbody = jQuery(active_scaffold_id).find('tbody.records').first(), new_row;

        if (options.insert_at == 'top') {
Severity: Minor
Found in app/assets/javascripts/jquery/active_scaffold.js - About 1 hr to fix

    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.href = l.url;
        }
    Severity: Major
    Found in app/assets/javascripts/prototype/active_scaffold.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/prototype/active_scaffold.js on lines 1127..1130

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

    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.href = l.url;
        }
    Severity: Major
    Found in app/assets/javascripts/prototype/active_scaffold.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/prototype/active_scaffold.js on lines 1036..1039

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

    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 29 lines of code (exceeds 25 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 1 hr to fix

      Method conditions_from_params has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def conditions_from_params
            @conditions_from_params ||= begin
              conditions = [{}]
              params.except(:controller, :action, :page, :sort, :sort_direction, :format, :id).each do |key, value|
                distinct = true if key.match?(/!$/)
      Severity: Minor
      Found in lib/active_scaffold/actions/core.rb - About 1 hr to fix

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

          def self.should_render_as_list_ui(column_name, list_ui)
            before_block = lambda do
              @rendered_columns = []
              @controller.view_context_class.any_instance.expects(:"active_scaffold_column_#{list_ui}").at_least_once.with do |column, _|
                @rendered_columns << column.name
        Severity: Major
        Found in shoulda_macros/macros.rb and 1 other location - About 1 hr to fix
        shoulda_macros/macros.rb on lines 26..36

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

        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

          def self.should_render_as_form_ui(column_name, form_ui)
            before_block = lambda do
              @rendered_columns = []
              @controller.view_context_class.any_instance.expects(:"active_scaffold_input_#{form_ui}").at_least_once.with do |column, _|
                @rendered_columns << column.name
        Severity: Major
        Found in shoulda_macros/macros.rb and 1 other location - About 1 hr to fix
        shoulda_macros/macros.rb on lines 75..85

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

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

               setup: function(options) {
                       
                       /*
                               options - object to store initialization parameters - passed in from dhtmlHistory or directly into historyStorage
                               options.debugMode - boolean that causes hidden form fields to be shown for development purposes.
        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_calendar_date_select_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def active_scaffold_search_calendar_date_select_field(column, options, current_search, name, ui_options: column.options)
                  value =
                    if current_search.is_a? Hash
                      controller.class.condition_value_for_datetime(column, current_search[name], column.column_type == :date ? :to_date : :to_time)
                    else
        Severity: Minor
        Found in lib/active_scaffold/bridges/calendar_date_select/as_cds_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

        Function get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          get: function(element) {
            var element = $(element);
            if (typeof(element.retrieve('action_link')) === 'undefined' && !element.hasClassName('as_adapter')) {
              var parent = element.up('.actions');
              if (typeof(parent) === 'undefined') {
        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 active_scaffold_record_select has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def active_scaffold_record_select(record, column, options, value, multiple, ui_options: column.options)
                unless column.association
                  raise ArgumentError, "record_select can only work against associations (and #{column.name} is not). "\
                    'A common mistake is to specify the foreign key field (like :user_id), instead of the association (:user).'
                end
        Severity: Minor
        Found in lib/active_scaffold/bridges/record_select/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 do_create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_create(options = {})
              attributes = options[:attributes] || params[:record]
              active_scaffold_config.model.transaction do
                @record = update_record_from_params(new_model, active_scaffold_config.create.columns, attributes)
                apply_constraints_to_record(@record, :allow_autosave => true)
        Severity: Minor
        Found in lib/active_scaffold/actions/create.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 build_associated has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_associated(association, parent_record)
                if association.through? && association.through_reflection.collection?
                  # build full chain, only check create_associated on initial parent_record
                  parent_record = build_associated(association.class.new(association.through_reflection), parent_record)
                  source_assoc = association.class.new(association.source_reflection)
        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 subgroup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def subgroup(name, label = nil)
              group = self if name == self.name
              group ||= @set.find do |item|
                name == item.name if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
              end
        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 setup_defaults_for_column has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def setup_defaults_for_column
              if active_record_class.respond_to?(:defined_enums) && active_record_class.defined_enums[name.to_s]
                @form_ui = :select
                @options = {:options => active_record_class.send(name.to_s.pluralize).keys.map(&:to_sym)}
              elsif column_number?
        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

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

            def add_link(attribute, options = {})
              column = @core.columns[attribute.to_sym]
              raise ArgumentError, "unknown column #{attribute}" if column.nil?
              raise ArgumentError, "column #{attribute} is not an association" if column.association.nil?
        
        
        Severity: Minor
        Found in lib/active_scaffold/config/nested.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 update_record_from_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_record_from_params(parent_record, columns, attributes, avoid_changes = false)
              crud_type = parent_record.new_record? ? :create : :update
              return parent_record unless parent_record.authorized_for?(:crud_type => crud_type)
        
              multi_parameter_attrs = multi_parameter_attributes(attributes)
        Severity: Minor
        Found in lib/active_scaffold/attribute_params.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_query_string_to_cached_url has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_query_string_to_cached_url(link, url)
                query_string, non_nested_query_string = query_string_for_action_links(link)
                nested_params = (!link.nested_link? && non_nested_query_string)
                if query_string || nested_params
                  url << (url.include?('?') ? '&' : '?')
        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

        Severity
        Category
        Status
        Source
        Language