activescaffold/active_scaffold

View on GitHub

Showing 362 of 362 total issues

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

      if (child.tagName != 'SCRIPT'
        && !child.hasClassName("create")
        && !child.hasClassName("update")
        && !child.hasClassName("inline-adapter")
        && !child.hasClassName("active-scaffold-calculations")) {
Severity: Major
Found in app/assets/javascripts/prototype/active_scaffold.js and 1 other location - About 1 hr to fix
app/assets/javascripts/jquery/active_scaffold.js on lines 613..623

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

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

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

    Method column_numerical_constraints has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def column_numerical_constraints(column, options)
            validators = column.active_record_class.validators.select do |v|
              v.is_a?(ActiveModel::Validations::NumericalityValidator) &&
                v.attributes.include?(column.name) &&
                !v.options[:if] && !v.options[:unless]
    Severity: Minor
    Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 1 hr to fix

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

              if (event.type == 'mouseleave') {
                if (td.hasClass('empty') || typeof(span.data('editInPlace')) === 'undefined') td.find('span').removeClass("hover");
              }
      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 201..203

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

      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 (event.type == 'mouseenter') {
                if (td.hasClass('empty') || typeof(span.data('editInPlace')) === 'undefined') td.find('span').addClass("hover");
              }
      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 204..206

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

      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 initialize has 36 lines of code (exceeds 25 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]
            if @column.nil? && active_record? && active_record_class._default_attributes.key?(name.to_s)
      Severity: Minor
      Found in lib/active_scaffold/data_structures/column.rb - About 1 hr to fix

        Method _setup_bitfields has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

                def _setup_bitfields
                  return unless model.respond_to?(:bitfields) && model.bitfields.present?
                  model.bitfields.each do |column_name, options|
                    columns = options.keys.sort_by { |column| self.columns[column].weight }
                    %i[create update show subform].each do |action|
        Severity: Minor
        Found in lib/active_scaffold/bridges/bitfields/bitfields_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

        Method look_for_parent_sti_controller has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def look_for_parent_sti_controller
              klass = self.class.active_scaffold_config.model
              loop do
                klass = klass.superclass
                controller = self.class.active_scaffold_controller_for(klass)
        Severity: Minor
        Found in lib/active_scaffold/actions/core.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_save has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_save(attributes: params[:record], no_record_param_update: false)
              active_scaffold_config.model.transaction do
                unless no_record_param_update
                  @record = update_record_from_params(@record, active_scaffold_config.update.columns, attributes)
                end
        Severity: Minor
        Found in lib/active_scaffold/actions/update.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 render_field_for_update_columns has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def render_field_for_update_columns
              return if (@column = active_scaffold_config.columns[params.delete(:column)]).nil?
              @source_id = params.delete(:source_id)
              @columns = @column.update_columns || []
              @scope = params.delete(:scope)
        Severity: Minor
        Found in lib/active_scaffold/actions/core.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 keeping_errors has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def keeping_errors
            old_errors = errors.dup if errors.present?
            result = yield
            old_errors&.each do |e|
              if e.is_a?(String) || e.is_a?(Symbol)
        Severity: Minor
        Found in lib/active_scaffold/extensions/unsaved_record.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_field_search has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def do_field_search
                filtered_columns = []
                text_search = active_scaffold_config.field_search.text_search
                columns = active_scaffold_config.field_search.columns
                search_params.each do |key, value|
        Severity: Minor
        Found in lib/active_scaffold/actions/field_search.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 update_column has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          update_column: function(element, url, send_form, source_id, val, additional_params) {
            if (!element) element = $(source_id);
            
            var as_form = element.up('form.as_form');
            var params = 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

        Method target_scope has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def target_scope
              super.tap do |scope|
                if klass < ActiveScaffold::Tableless
                  class << scope; include RelationExtension; end
                  assoc_conditions = scope.proxy_association&.send(:association_scope)&.conditions
        Severity: Minor
        Found in lib/active_scaffold/tableless.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 attributes_hash_is_empty? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def attributes_hash_is_empty?(hash, klass)
              hash.all? do |key, value|
                # convert any possible multi-parameter attributes like 'created_at(5i)' to simply 'created_at'
                column_name = key.to_s.split('(', 2)[0]
        
        
        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 update_column_from_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_column_from_params(parent_record, column, attribute, avoid_changes = false)
              value = column_value_from_param_value(parent_record, column, attribute, avoid_changes)
              if column.association
                if avoid_changes
                  parent_record.association(column.name).target = value
        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 find_page has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def find_page(options = {})
              options.assert_valid_keys :sorting, :per_page, :page, :count_includes, :pagination, :select
              options[:per_page] ||= 999_999_999
              options[:page] ||= 1
        
        
        Severity: Minor
        Found in lib/active_scaffold/finder.rb - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Method condition_value_for_numeric has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def condition_value_for_numeric(column, value)
                return value if value.nil?
                value = column.number_to_native(value) if column.options[:format] && column.search_ui != :number
                case (column.search_ui || column.column_type)
                when :integer   then
        Severity: Minor
        Found in lib/active_scaffold/finder.rb - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Method render has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def render(*args, &block)
              if args.first.is_a?(Hash) && args.first[:active_scaffold]
                render_embedded args.first
              elsif args.first == :super
                if @lookup_context # rails 6
        Severity: Minor
        Found in lib/active_scaffold/extensions/action_view_rendering.rb - About 1 hr to fix

          Function update_column has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            update_column: function(element, url, send_form, source_id, val, additional_params) {
              if (!element) element = $(source_id);
              
              var as_form = element.up('form.as_form');
              var params = null;
          Severity: Minor
          Found in app/assets/javascripts/prototype/active_scaffold.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language