activescaffold/active_scaffold

View on GitHub

Showing 362 of 362 total issues

Method active_scaffold_search_for has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def active_scaffold_search_for(column, options = nil)
        options ||= active_scaffold_search_options(column)
        record = options[:object]
        if column.delegated_association
          record = record.send(column.delegated_association.name) || column.active_record_class.new
Severity: Minor
Found in lib/active_scaffold/helpers/search_column_helpers.rb - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

  get: function(element) {
    if (typeof(element) == 'string') element = '#' + element;
    var element = jQuery(element);
    if (element.length > 0) {
      element.data(); // $ 1.4.2 workaround
Severity: Minor
Found in app/assets/javascripts/jquery/active_scaffold.js - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Method active_scaffold_search_select has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def active_scaffold_search_select(column, html_options, options = {})
        record = html_options.delete(:object)
        associated = html_options.delete :value
        if column.association
          associated = associated.is_a?(Array) ? associated.map(&:to_i) : associated.to_i unless associated.nil?
Severity: Minor
Found in lib/active_scaffold/helpers/search_column_helpers.rb - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Method initialize has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(name, active_record_class, delegated_association = nil) #:nodoc:
      @name = name.to_sym
      @active_record_class = active_record_class
      @column = _columns_hash[name.to_s]
      @delegated_association = delegated_association
Severity: Minor
Found in lib/active_scaffold/data_structures/column.rb - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Method active_scaffold_input_radio has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def active_scaffold_input_radio(column, html_options)
        record = html_options[:object]
        html_options.merge!(column.options[:html_options] || {})
        options =
          if column.association
Severity: Minor
Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

      if (span.up('div.active-scaffold').readAttribute('data-eid')) {
        if (options['params'].length > 0) {
          options['params'] += "&";
        }
        options['params'] += ("eid=" + span.up('div.active-scaffold').readAttribute('data-eid'));
Severity: Major
Found in app/assets/javascripts/prototype/active_scaffold.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/jquery/active_scaffold.js on lines 1006..1011

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

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

      if (span.closest('div.active-scaffold').data('eid')) {
        if (options['params'].length > 0) {
          options['params'] += "&";
        }
        options['params'] += ("eid=" + span.closest('div.active-scaffold').data('eid'));
Severity: Major
Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/prototype/active_scaffold.js on lines 204..209

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

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

      def association_options_find(association, conditions = nil, klass = nil, record = nil)
        if klass.nil? && association.polymorphic?
          class_name = record.send(association.foreign_type) if association.belongs_to?
          return [] if class_name.blank?
          klass = class_name.constantize
Severity: Minor
Found in lib/active_scaffold/helpers/association_helpers.rb - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

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

Cognitive Complexity

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

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

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

Further reading

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

    def self.active_scaffold_controller_for(klass, controller_namespace = '::')
      error_message = []
      class_names = [klass.to_s, klass.to_s.demodulize].map { |k| k.underscore.pluralize }.map { |k| [k, k.singularize] }.flatten
      [controller_namespace, ''].each do |namespace|
        class_names.each do |controller_name|
Severity: Minor
Found in lib/active_scaffold/core.rb - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

      def params_for(options = {})
        unless @params_for
          @params_for = {}
          params.except(*BLACKLIST_PARAMS).each do |key, value|
            @params_for[key.to_sym] = copy_param(value)
Severity: Minor
Found in lib/active_scaffold/helpers/controller_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 clause has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def clause(grouped_columns_calculations = nil)
      return nil if sorts_by_method? || default_sorting?

      # unless the sorting is by method, create the sql string
      order = []
Severity: Minor
Found in lib/active_scaffold/data_structures/sorting.rb - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

      def active_scaffold_render_subform_column(column, scope, crud_type, readonly, add_class = false, record = nil) # rubocop:disable Metrics/ParameterLists
        if add_class
          col_class = []
          col_class << 'required' if column.required?(action_for_validation?(record))
          col_class << column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc)
Severity: Minor
Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

  disable_form: function(as_form) {
    as_form = $(as_form)
    var loading_indicator = $(as_form.readAttribute('id').sub('-form', '-loading-indicator'));
    if (loading_indicator) loading_indicator.style.visibility = 'visible';
    as_form.disable();
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 527..532

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

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_form: function(as_form) {
    as_form = $(as_form)
    var loading_indicator = $(as_form.readAttribute('id').sub('-form', '-loading-indicator'));
    if (loading_indicator) loading_indicator.style.visibility = 'hidden';
    as_form.enable();
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 520..525

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

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

File core.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveScaffold::Config
  # to fix the ckeditor bridge problem inherit from full class name
  class Core < ActiveScaffold::Config::Base
    include ActiveScaffold::OrmChecks
    # global level configuration
Severity: Minor
Found in lib/active_scaffold/config/core.rb - About 2 hrs to fix

    File search_column_helpers.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveScaffold
      module Helpers
        # Helpers that assist with the rendering of a Form Column
        module SearchColumnHelpers
          # This method decides which input to use for the given column.
    Severity: Minor
    Found in lib/active_scaffold/helpers/search_column_helpers.rb - About 2 hrs to fix

      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

          File list.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module ActiveScaffold::Actions
            module List
              def self.included(base)
                base.before_action :list_authorized_filter, :only => :index
                base.helper_method :list_columns, :count_on_association_class?
          Severity: Minor
          Found in lib/active_scaffold/actions/list.rb - About 2 hrs to fix
            Severity
            Category
            Status
            Source
            Language