activescaffold/active_scaffold

View on GitHub

Showing 296 of 296 total issues

Avoid too many return statements within this method.
Open

      return false unless association.source_reflection.collection? # create allowed if source is singular, rails creates joint model
Severity: Major
Found in lib/active_scaffold/data_structures/nested_info.rb - About 30 mins to fix

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

            jQuery(document).on('change input', '.active-scaffold form:not(.search) input, .active-scaffold form:not(.search) textarea, .active-scaffold form:not(.search) select', function() {
              jQuery(this).closest('form').addClass('need-confirm');
            });
    Severity: Minor
    Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 30 mins to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 1213..1215

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

    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 .as_cancel:not([data-remote]), .active-scaffold input[type=submit]', function() {
              jQuery(this).closest('form').removeClass('need-confirm');
            });
    Severity: Minor
    Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 30 mins to fix
    app/assets/javascripts/jquery/active_scaffold.js on lines 1210..1212

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

    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.should_not_include_columns_in(action, *columns)
        should "not include #{columns.to_sentence} columns in #{action}" do
          action_columns = column_names(action)
          columns.each do |column|
            assert action_columns.exclude?(column.to_sym), "#{column} is included in #{action}"
    Severity: Minor
    Found in shoulda_macros/macros.rb and 1 other location - About 25 mins to fix
    shoulda_macros/macros.rb on lines 8..12

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

    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.should_include_columns_in(action, *columns)
        should "include #{columns.to_sentence} columns in #{action}" do
          action_columns = column_names(action)
          columns.each do |column|
            assert action_columns.include?(column.to_sym), "#{column} is not included in #{action}"
    Severity: Minor
    Found in shoulda_macros/macros.rb and 1 other location - About 25 mins to fix
    shoulda_macros/macros.rb on lines 17..21

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

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

          def display_message(message)
            message = safe_join message, tag.br if message.is_a?(Array)
            if (highlights = active_scaffold_config.user.highlight_messages)
              message = highlights.inject(message) do |msg, (phrases, highlighter)|
                highlight(msg, phrases, highlighter || {})
    Severity: Minor
    Found in lib/active_scaffold/helpers/view_helpers.rb - About 25 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 active_scaffold_radio_option has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def active_scaffold_radio_option(option, selected, column, radio_options, ui_options: column.options)
            if column.association
              label_method = ui_options[:label_method] || :to_label
              text = option.send(label_method)
              value = option.id
    Severity: Minor
    Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 25 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 active_record_column_type_cast has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.active_record_column_type_cast(value, column_or_type)
          return Time.zone.at(value.to_i) if %i[time datetime].include?(column_or_type.type) && value =~ /\A\d+\z/
    
          cast_type = column_or_type.is_a?(ActiveRecord::ConnectionAdapters::Column) ? ActiveRecord::Type.lookup(column_or_type.type) : column_or_type
          cast_type ? cast_type.cast(value) : value
    Severity: Minor
    Found in lib/active_scaffold/core.rb - About 25 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 create_respond_to_js has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_respond_to_js
          if successful? && !render_parent?
            do_refresh_list if active_scaffold_config.create.refresh_list
            if params[:dont_close]
              @saved_record = @record
    Severity: Minor
    Found in lib/active_scaffold/actions/create.rb - About 25 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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def call(mapper, options = {})
            actions = get_actions(ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING, options)
    
            mapper.collection do
              ActiveScaffold::Routing::ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING[:collection].each do |name, type|
    Severity: Minor
    Found in lib/active_scaffold/extensions/routing_mapper.rb - About 25 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 active_scaffold_checkbox_option has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def active_scaffold_checkbox_option(option, label_method, associated_ids, checkbox_options, li_options = {})
            content_tag(:li, li_options) do
              option_id = option.is_a?(Array) ? option[1] : option.id
              label = option.is_a?(Array) ? option[0] : option.send(label_method)
              check_box_tag(checkbox_options[:name], option_id, associated_ids.include?(option_id), checkbox_options) <<
    Severity: Minor
    Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 25 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 active_scaffold_add_existing_input has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def active_scaffold_add_existing_input(options)
            record = options.delete(:object)
            if controller.respond_to?(:record_select_config, true)
              remote_controller = active_scaffold_controller_for(record_select_config.model).controller_path
              options[:controller] = remote_controller
    Severity: Minor
    Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 25 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_jquery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def setup_jquery(file, original_js = nil, where: 'ujs')
            original_js ||= File.binread(file)
            if Object.const_defined?(:Jquery)
              unless original_js.include?('require jquery')
                insert_into_file file, before: %r{//= require +.*#{where}['"]?\n} do
    Severity: Minor
    Found in lib/generators/active_scaffold/install_generator.rb - About 25 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 format_to_datetime_picker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.format_to_datetime_picker(rails_time_format)
            date_format, time_format = split_datetime_format(to_datepicker_format(rails_time_format))
            datetime_picker_options = {}
            datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
            unless time_format.nil?
    Severity: Minor
    Found in lib/active_scaffold/bridges/date_picker/helper.rb - About 25 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 field_search_record_select_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def field_search_record_select_value(column, value, ui_options: column.options)
            return if value.blank?
    
            if ui_options[:multiple]
              column.association.klass.find value.compact_blank.collect!(&:to_i)
    Severity: Minor
    Found in lib/active_scaffold/bridges/record_select/helpers.rb - About 25 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 configure_nested has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def configure_nested
          return unless nested?
    
          register_constraints_with_action_columns(nested.constrained_fields)
          return unless active_scaffold_config.actions.include? :list
    Severity: Minor
    Found in lib/active_scaffold/actions/nested.rb - About 25 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 active_scaffold_tab_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def active_scaffold_tab_options(column, record)
            subform_column = column.first
            if subform_column
              tabbed_by = subform_column.options[:tabbed_by] || column.tabbed_by
              if tabbed_by_association(subform_column, tabbed_by)
    Severity: Minor
    Found in lib/active_scaffold/helpers/tabs_helpers.rb - About 25 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 form_hidden_field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def form_hidden_field(column, record, scope)
            options = active_scaffold_input_options(column, scope)
            if column.association&.collection?
              associated = record.send(column.name)
              if associated.blank?
    Severity: Minor
    Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 25 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 init_field_search_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def init_field_search_params(default_params)
            return unless (params[:search].is_a?(String) || search_params.nil?) && params[:search].blank?
    
            params[:search] = default_params.is_a?(Proc) ? instance_eval(&default_params) : default_params
          end
    Severity: Minor
    Found in lib/active_scaffold/actions/field_search.rb - About 25 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 datepicker_format_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def datepicker_format_options(column, format)
              return {} if format == :default
    
              if column.form_ui == :date_picker
                js_format = to_datepicker_format(I18n.translate!("date.formats.#{format}"))
    Severity: Minor
    Found in lib/active_scaffold/bridges/date_picker/helper.rb - About 25 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

    Severity
    Category
    Status
    Source
    Language