activescaffold/active_scaffold

View on GitHub

Showing 296 of 296 total issues

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

      def condition_for_column(column, value, text_search, session)
        like_pattern = like_pattern(text_search)
        value = value.with_indifferent_access if value.is_a? Hash
        column_method = "condition_for_#{column.name}_column"
        if respond_to?(column_method)
Severity: Minor
Found in lib/active_scaffold/finder.rb - About 1 hr to fix

    Method initialize has 37 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 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 == '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

        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

        Method active_scaffold_search_select has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def active_scaffold_search_select(column, html_options, options = {}, ui_options: column.options)
                record = html_options.delete(:object)
                associated = html_options.delete :value
                if include_null_comparators?(column, ui_options: ui_options)
                  range_opts = html_options.slice(:name, :id)
        Severity: Minor
        Found in lib/active_scaffold/helpers/search_column_helpers.rb - About 1 hr to fix

          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 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 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 _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?
          
                    supported_actions = %i[create update show subform]
                    model.bitfields.each do |column_name, options|
          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 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

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

                def condition_for_datetime(column, value, like_pattern = nil)
                  operator = ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(value['opt']) && value['opt'] != 'BETWEEN' ? value['opt'] : nil
                  from_value, to_value = datetime_from_to(column, value)
          
                  if column.search_sql.is_a? Proc
          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
          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 subgroup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def subgroup(name, label = nil)
                group = self if name == self.name
                group ||= @set.find do |item|
                  name == item.name if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
                end
          Severity: Minor
          Found in lib/active_scaffold/data_structures/action_links.rb - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

          Method 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

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

                  show_empty_message: function(tbody) {
                    if (this.records_for(tbody).length != 0) {
                      jQuery(tbody).parent().find('tbody.messages p.empty-message').hide();
                    }
                  },
            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 645..649

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

            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

                  hide_empty_message: function(tbody) {
                    if (this.records_for(tbody).length != 0) {
                      jQuery(tbody).parent().find('tbody.messages p.empty-message').hide();
                    }
                  },
            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 650..654

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

            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 5 locations. Consider refactoring.
            Open

                    if (event.detail && !xhr) {
                      error = event.detail[0];
                      status = event.detail[1];
                      xhr = event.detail[2];
                    }
            Severity: Major
            Found in app/assets/javascripts/jquery/active_scaffold.js and 4 other locations - About 1 hr to fix
            app/assets/javascripts/jquery/active_scaffold.js on lines 66..70
            app/assets/javascripts/jquery/active_scaffold.js on lines 133..137
            app/assets/javascripts/jquery/active_scaffold.js on lines 172..176
            app/assets/javascripts/jquery/active_scaffold.js on lines 189..193

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

            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 5 locations. Consider refactoring.
            Open

                    if (event.detail && !xhr) {
                      error = event.detail[0];
                      status = event.detail[1];
                      xhr = event.detail[2];
                    }
            Severity: Major
            Found in app/assets/javascripts/jquery/active_scaffold.js and 4 other locations - About 1 hr to fix
            app/assets/javascripts/jquery/active_scaffold.js on lines 66..70
            app/assets/javascripts/jquery/active_scaffold.js on lines 172..176
            app/assets/javascripts/jquery/active_scaffold.js on lines 189..193
            app/assets/javascripts/jquery/active_scaffold.js on lines 222..226

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

            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 5 locations. Consider refactoring.
            Open

                    if (event.detail && !xhr) {
                      error = event.detail[0];
                      status = event.detail[1];
                      xhr = event.detail[2];
                    }
            Severity: Major
            Found in app/assets/javascripts/jquery/active_scaffold.js and 4 other locations - About 1 hr to fix
            app/assets/javascripts/jquery/active_scaffold.js on lines 66..70
            app/assets/javascripts/jquery/active_scaffold.js on lines 133..137
            app/assets/javascripts/jquery/active_scaffold.js on lines 189..193
            app/assets/javascripts/jquery/active_scaffold.js on lines 222..226

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

            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

            Severity
            Category
            Status
            Source
            Language