activescaffold/active_scaffold

View on GitHub

Showing 296 of 296 total issues

Method delete_group has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def delete_group(name)
      @set.each do |group|
        next unless group.is_a?(ActiveScaffold::DataStructures::ActionLinks)

        if group.name == name
Severity: Minor
Found in lib/active_scaffold/data_structures/action_links.rb - About 45 mins 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 3 locations. Consider refactoring.
Open

      def element_form_id(options = {})
        options[:action] ||= params[:action]
        options[:id] ||= params[:id]
        options[:id] ||= nested_parent_id if nested?
        clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-form"
Severity: Major
Found in lib/active_scaffold/helpers/id_helpers.rb and 2 other locations - About 45 mins to fix
lib/active_scaffold/helpers/id_helpers.rb on lines 93..97
lib/active_scaffold/helpers/id_helpers.rb on lines 118..122

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

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

    def readonly_through_association?(columns)
      return false unless through_association?
      return true if association.through_reflection.options[:through] # create not possible, too many levels
      return true if association.source_reflection.options[:through] # create not possible, too many levels
      return false if create_through_singular? # create allowed, AS has code for this
Severity: Minor
Found in lib/active_scaffold/data_structures/nested_info.rb - About 45 mins 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 as_marked= has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def as_marked=(value)
      if [true, 'true', 1, '1', 'T', 't'].include?(value.respond_to?(:downcase) ? value.downcase : value)
        marked_records[id.to_s] = true unless as_marked
      else
        marked_records.delete(id.to_s)
Severity: Minor
Found in lib/active_scaffold/marked_model.rb - About 45 mins 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 3 locations. Consider refactoring.
Open

      def element_messages_id(options = {})
        options[:action] ||= params[:action]
        options[:id] ||= params[:id]
        options[:id] ||= nested_parent_id if nested?
        clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-messages"
Severity: Major
Found in lib/active_scaffold/helpers/id_helpers.rb and 2 other locations - About 45 mins to fix
lib/active_scaffold/helpers/id_helpers.rb on lines 81..85
lib/active_scaffold/helpers/id_helpers.rb on lines 93..97

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

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

Avoid deeply nested control flow statements.
Open

            if reverse&.singular? && !reverse.belongs_to? && options[:allow_autosave]
              record.send(k).send(:"#{reverse.name}=", record)
            end
Severity: Major
Found in lib/active_scaffold/constraints.rb - About 45 mins to fix

    Method add_association_columns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_association_columns(association, *columns)
          column = self[association]
          raise ArgumentError, "unknown column #{association}" if column.nil?
          raise ArgumentError, "column #{association} is not an association" if column.association.nil?
          raise ArgumentError, "column #{association} is not singular association" unless column.association.singular?
    Severity: Minor
    Found in lib/active_scaffold/data_structures/columns.rb - About 45 mins 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_association_info has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def setup_association_info
          assoc = active_record_class.reflect_on_association(name)
          @association =
            if assoc
              if active_record?
    Severity: Minor
    Found in lib/active_scaffold/data_structures/column.rb - About 45 mins 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 cache_association_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def cache_association_options(association, conditions, klass, cache = true)
            if active_scaffold_config.cache_association_options && cache
              @_associations_cache ||= Hash.new { |h, k| h[k] = {} }
              key = [association.name, association.inverse_klass.name, klass.respond_to?(:cache_key) ? klass.cache_key : klass.name].join('/')
              @_associations_cache[key][conditions] ||= yield
    Severity: Minor
    Found in lib/active_scaffold/helpers/association_helpers.rb - About 45 mins 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

      def self.install
        require File.join(File.dirname(__FILE__), 'dragonfly/form_ui')
        require File.join(File.dirname(__FILE__), 'dragonfly/list_ui')
        require File.join(File.dirname(__FILE__), 'dragonfly/dragonfly_bridge_helpers')
        require File.join(File.dirname(__FILE__), 'dragonfly/dragonfly_bridge')
    Severity: Minor
    Found in lib/active_scaffold/bridges/dragonfly.rb and 1 other location - About 45 mins to fix
    lib/active_scaffold/bridges/carrierwave.rb on lines 2..8

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

    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.install
        require File.join(File.dirname(__FILE__), 'carrierwave/form_ui')
        require File.join(File.dirname(__FILE__), 'carrierwave/list_ui')
        require File.join(File.dirname(__FILE__), 'carrierwave/carrierwave_bridge_helpers')
        require File.join(File.dirname(__FILE__), 'carrierwave/carrierwave_bridge')
    Severity: Minor
    Found in lib/active_scaffold/bridges/carrierwave.rb and 1 other location - About 45 mins to fix
    lib/active_scaffold/bridges/dragonfly.rb on lines 2..8

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

    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

              value = form_element.find(':checked').map(function(item){return $(this).val();}).toArray();
    Severity: Minor
    Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 258..258

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

    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

              value = form_element.find(':checked').map(function(item){return $(this).val();}).toArray();
    Severity: Minor
    Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 274..274

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

    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

          jQuery(document).on('click', '.active-scaffold form .check-all', function(e) {
            e.preventDefault();
            ActiveScaffold.update_all_checkboxes($(this), true);
          });
    Severity: Minor
    Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 445..448

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

    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

          jQuery(document).on('click', '.active-scaffold form .uncheck-all', function(e) {
            e.preventDefault();
            ActiveScaffold.update_all_checkboxes($(this), false);
          });
    Severity: Minor
    Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 441..444

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

    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

            unless options[:max]
              max = validators.filter_map { |v| v.options[:less_than_or_equal_to] }.min
              less_than = validators.filter_map { |v| v.options[:less_than] }.min
              numerical_constraints[:max] = [max, (less_than - margin if less_than)].compact.min
    Severity: Minor
    Found in lib/active_scaffold/helpers/form_column_helpers.rb and 1 other location - About 40 mins to fix
    lib/active_scaffold/helpers/form_column_helpers.rb on lines 820..823

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

    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

            unless options[:min]
              min = validators.filter_map { |v| v.options[:greater_than_or_equal_to] }.max
              greater_than = validators.filter_map { |v| v.options[:greater_than] }.max
              numerical_constraints[:min] = [min, (greater_than + margin if greater_than)].compact.max
    Severity: Minor
    Found in lib/active_scaffold/helpers/form_column_helpers.rb and 1 other location - About 40 mins to fix
    lib/active_scaffold/helpers/form_column_helpers.rb on lines 827..830

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

    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_tabs_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def active_scaffold_tabs_for(column, record, subsection_id, tab_options, used_tabs)
    Severity: Minor
    Found in lib/active_scaffold/helpers/tabs_helpers.rb - About 35 mins to fix

      Method find_template has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def find_template(name, prefixes = [], partial = false, keys = [], options = {}) # rubocop:disable Metrics, Style
      Severity: Minor
      Found in lib/active_scaffold/extensions/action_view_rendering.rb - About 35 mins to fix

        Method active_scaffold_tabbed_by has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def active_scaffold_tabbed_by(column, record, scope, subsection_id, &block)
        Severity: Minor
        Found in lib/active_scaffold/helpers/tabs_helpers.rb - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language