activescaffold/active_scaffold

View on GitHub

Showing 374 of 374 total issues

dhtmlHistory has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

window.dhtmlHistory = {
       
       /*Public: User-agent booleans*/
       isIE: false,
       isOpera: false,
Severity: Minor
Found in app/assets/javascripts/prototype/dhtml_history.js - About 2 hrs to fix

    Function update_column has 54 lines of code (exceeds 25 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: Major
    Found in app/assets/javascripts/jquery/active_scaffold.js - About 2 hrs to fix

      Method update_columns_options has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def update_columns_options(column, scope, options, force = false, form_columns: nil, url_params: {})
              record = options[:object]
              subform_controller = controller.class.active_scaffold_controller_for(record.class) if scope
              if @main_columns && (scope.nil? || subform_controller == controller.class)
                form_columns ||= @main_columns.visible_columns_names
      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 format_for_datetime has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def format_for_datetime(column, value)
              parts = Date._parse(value)
              if ActiveScaffold.js_framework == :jquery
                format = I18n.translate "time.formats.#{column.options[:format] || :picker}", :default => ''
              end
      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 form_attribute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def form_attribute(column, record, scope = nil, only_value = false, col_class = nil)
              column_options = active_scaffold_input_options(column, scope, :object => record)
              collapsible_id = column_options.delete :collapsible_id
              attributes = field_attributes(column, record)
              attributes[:class] = "#{attributes[:class]} #{col_class}" if col_class.present?
      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 condition_for_column has a Cognitive Complexity of 16 (exceeds 5 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 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

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

        disable: function() {
          var _this = this;
          jQuery.each(this.set.links, function(index, item) {
            if (item.url != _this.url) return;
            item.tag.addClass('disabled');
      Severity: Major
      Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/jquery/active_scaffold.js on lines 1410..1416

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

      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

        enable: function() {
          var _this = this;
          jQuery.each(this.set.links, function(index, item) {
            if (item.url != _this.url) return;
            item.tag.removeClass('disabled');
      Severity: Major
      Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/jquery/active_scaffold.js on lines 1418..1424

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

      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

        enable: function() {
          this.set.links.each(function(item) {
            if (item.url != this.url) return;
            item.tag.removeClassName('disabled');
          }.bind(this));
      Severity: Major
      Found in app/assets/javascripts/prototype/active_scaffold.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/prototype/active_scaffold.js on lines 1103..1108

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

      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

        disable: function() {
          this.set.links.each(function(item) {
            if (item.url != this.url) return;
            item.tag.addClassName('disabled');
          }.bind(this));
      Severity: Major
      Found in app/assets/javascripts/prototype/active_scaffold.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/prototype/active_scaffold.js on lines 1096..1101

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

      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
          scaffold = $(scaffold)
          count = scaffold.select('span.active-scaffold-records').last();
          if (count) count.update(parseInt(count.innerHTML, 10) + 1);
      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 462..467

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

      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
          scaffold = $(scaffold)
          count = scaffold.select('span.active-scaffold-records').last();
          if (count) count.update(parseInt(count.innerHTML, 10) - 1);
      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 468..473

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

      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_error_messages_for has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def active_scaffold_error_messages_for(*params)
              options = params.extract_options!.symbolize_keys
              options.reverse_merge!(:container_tag => :div, :list_type => :ul)
      
              objects = Array.wrap(options.delete(:object) || params).map do |object|
      Severity: Minor
      Found in lib/active_scaffold/helpers/view_helpers.rb - About 1 hr to fix

        Method columns_reader has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.columns_reader(name, options, &block)
              var = "@#{name}"
              define_method name do
                unless instance_variable_defined?(var) # lazy evaluation
                  action, columns = options[:copy] if options[:copy]
        Severity: Minor
        Found in lib/active_scaffold/config/base.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 column_class has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def column_class(column, column_value, record)
                classes = ActiveScaffold::Registry.cache :column_classes, column.cache_key do
                  classes = "#{column.name}-column "
                  classes << 'sorted ' if active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.user.sorting.sorts_on?(column)
                  classes << 'numeric ' if column.number?
        Severity: Minor
        Found in lib/active_scaffold/helpers/view_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 action_link_url_options has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def action_link_url_options(link, record)
                url_options = {:action => link.action}
                url_options[:id] = '--ID--' unless record.nil?
                url_options[:controller] = link.controller.to_s if link.controller
                url_options.merge! link.parameters if link.parameters
        Severity: Minor
        Found in lib/active_scaffold/helpers/action_link_helpers.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method sorting has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def sorting
                if @_sorting.nil?
                  # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
                  self['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] && @params['sort_direction']
                  self['sort'] = nil if @params['sort_direction'] == 'reset'
        Severity: Minor
        Found in lib/active_scaffold/config/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 query_string_for_action_links has a Cognitive Complexity of 15 (exceeds 5 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

        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 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

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

            create_record_row: function(active_scaffold_id, html, options) {
              tbody = $(active_scaffold_id).down('tbody.records');
          
              var new_row = null;
              
          Severity: Minor
          Found in app/assets/javascripts/prototype/active_scaffold.js - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Severity
          Category
          Status
          Source
          Language