activescaffold/active_scaffold

View on GitHub

Showing 296 of 296 total issues

Method add_to_js_app has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def add_to_js_app
        original_js = File.binread(JS_APP)
        if original_js.match?(/^import +['"]active_scaffold['"]/)
          say_status('skipped', "append active_scaffold to #{JS_APP}", :yellow)
        else
Severity: Minor
Found in lib/generators/active_scaffold/install_generator.rb - About 55 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 inplace_edit_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def inplace_edit_data(column)
        data = {}
        data[:ie_url] = url_for(params_for(action: 'update_column', column: column.name, id: '__id__'))
        data[:ie_cancel_text] = column.options[:cancel_text] || as_(:cancel)
        data[:ie_loading_text] = column.options[:loading_text] || as_(:loading)
Severity: Minor
Found in lib/active_scaffold/helpers/list_column_helpers.rb - About 55 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 date_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def self.date_options(locale)
        date_picker_options = {
          closeText:       as_(:close),
          prevText:        as_(:previous),
          nextText:        as_(:next),
Severity: Minor
Found in lib/active_scaffold/bridges/date_picker/helper.rb - About 55 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_input_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def active_scaffold_input_options(column, scope = nil, options = {})
        name = scope ? "record#{scope}[#{column.name}]" : "record[#{column.name}]"
        record = options[:object]

        # Add some HTML5 attributes for in-browser validation and better user experience
Severity: Minor
Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 55 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 main_path_to_return has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def main_path_to_return
        if params[:return_to]
          params[:return_to]
        else
          exclude_parameters = %i[utf8 associated_id]
Severity: Minor
Found in lib/active_scaffold/helpers/controller_helpers.rb - About 55 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 updated_record_with_form has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def updated_record_with_form(columns, attributes, scope)
      if attributes && scope
        attributes = scope.delete('[').split(']').inject(attributes) { |h, idx| h[idx] }
        id = attributes[:id]
      else
Severity: Minor
Found in lib/active_scaffold/actions/core.rb - About 55 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 sti_nested_build_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def sti_nested_build_options(klass)
      config = active_scaffold_config_for(klass)
      return unless config

      column = klass.inheritance_column
Severity: Minor
Found in lib/active_scaffold/actions/core.rb - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
Open

      def call(mapper, options = {})
        options = @defaults.merge(options)
        actions = get_actions(ACTIVE_SCAFFOLD_CORE_ROUTING, options)

        mapper.collection do
Severity: Minor
Found in lib/active_scaffold/extensions/routing_mapper.rb - About 55 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 name_to_cache has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def name_to_cache
      return @name_to_cache if defined? @name_to_cache

      [
        controller || 'self',
Severity: Minor
Found in lib/active_scaffold/data_structures/action_link.rb - About 55 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 set_link has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def set_link(action, options = {})
        if action.is_a?(ActiveScaffold::DataStructures::ActionLink) || (action.is_a? Proc)
          @link = action
        else
          options[:label] ||= label
Severity: Minor
Found in lib/active_scaffold/data_structures/column.rb - About 55 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 number_to_native has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def number_to_native(value)
        return value if value.blank? || !value.is_a?(String)

        native = '.' # native ruby separator
        format = {separator: '', delimiter: ''}.merge! I18n.t('number.format', default: {})
Severity: Minor
Found in lib/active_scaffold/data_structures/column.rb - About 55 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 column_link_authorized? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def column_link_authorized?(link, column, record, associated)
        if column.association
          associated_for_authorized =
            if column.association.collection? || associated.nil?
              column.association.klass
Severity: Minor
Found in lib/active_scaffold/helpers/action_link_helpers.rb - About 55 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 initialize_search_sql has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize_search_sql
        self.search_sql =
          unless virtual?
            if association.nil?
              field.to_s unless tableless?
Severity: Minor
Found in lib/active_scaffold/data_structures/column.rb - About 55 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 type_casted_tokens has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def type_casted_tokens(tokens, columns, like_pattern)
        tokens.map do |value|
          columns.each_with_object({}) do |column, column_tokens|
            column_tokens[column.name] =
              if column.text?
Severity: Minor
Found in lib/active_scaffold/finder.rb - About 55 mins to fix

Cognitive Complexity

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

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

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

Further reading

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

      def sub_form_list_id(options = {})
        options[:id] ||= params[:id]
        options[:id] ||= nested_parent_id if nested?
        clean_id "#{controller_id}-#{options[:id]}-#{options[:association]}#{'-' if options[:tab_id]}#{options[:tab_id]}-subform-list"
Severity: Minor
Found in lib/active_scaffold/helpers/id_helpers.rb and 1 other location - About 50 mins to fix
lib/active_scaffold/helpers/id_helpers.rb on lines 106..109

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

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 sub_form_id(options = {})
        options[:id] ||= params[:id]
        options[:id] ||= nested_parent_id if nested?
        clean_id "#{controller_id}-#{options[:id]}-#{options[:association]}#{'-' if options[:tab_id]}#{options[:tab_id]}-subform"
Severity: Minor
Found in lib/active_scaffold/helpers/id_helpers.rb and 1 other location - About 50 mins to fix
lib/active_scaffold/helpers/id_helpers.rb on lines 112..115

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

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

    def do_update_column
      # delete from params so update :table won't break urls, also they shouldn't be used in sort links too
      value = params.delete(:value)
      column = params.delete(:column)
      params.delete(:original_html)
Severity: Minor
Found in lib/active_scaffold/actions/update.rb - About 45 mins to fix

Cognitive Complexity

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

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

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

Further reading

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

      def history_state
        if active_scaffold_config.store_user_settings
          state = {page: @page&.number}
          state[:search] = search_params if respond_to?(:search_params) && search_params.present?
          if active_scaffold_config.list.user.user_sorting?
Severity: Minor
Found in lib/active_scaffold/helpers/view_helpers.rb - About 45 mins to fix

Cognitive Complexity

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

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

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

Further reading

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

        def active_scaffold_search_date_picker_field(column, options, current_search, name, ui_options: column.options)
          value =
            if current_search.is_a? Hash
              conversion = column.search_ui == :date_picker ? :to_date : :to_time
              controller.class.condition_value_for_datetime(column, current_search[name], conversion, ui_method: :search_ui, ui_options: ui_options)
Severity: Minor
Found in lib/active_scaffold/bridges/date_picker/helper.rb - About 45 mins to fix

Cognitive Complexity

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

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

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

Further reading

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

    def create_respond_to_html
      if successful?
        flash[:info] = as_(:created_model, model: ERB::Util.h(@record.to_label))
        if (action = active_scaffold_config.create.action_after_create)
          redirect_to params_for(action: action, id: @record.to_param)
Severity: Minor
Found in lib/active_scaffold/actions/create.rb - About 45 mins to fix

Cognitive Complexity

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

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

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

Further reading

Severity
Category
Status
Source
Language