activescaffold/active_scaffold

View on GitHub

Showing 374 of 374 total issues

Method render_list_column has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def render_list_column(text, column, record)
        if column.link && !skip_action_link?(column.link, record)
          link = column.link
          associated = record.send(column.association.name) if column.association
          authorized = link.action.nil?
Severity: Minor
Found in lib/active_scaffold/helpers/list_column_helpers.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 get_column_value has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def get_column_value(record, column)
        record = record.send(column.delegated_association.name) if column.delegated_association
        if record
          method, list_ui = get_column_method(record, column)
          value =
Severity: Minor
Found in lib/active_scaffold/helpers/list_column_helpers.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 create_record_row has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  create_record_row: function(active_scaffold_id, html, options) {
    tbody = $(active_scaffold_id).down('tbody.records');

    var new_row = 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 setup_parent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def setup_parent(record)
      cfg = main_form_controller.active_scaffold_config
      association = cfg.columns[subform_child_association]&.association&.reverse_association
      return if association.nil?

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

Function create_record_row has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  create_record_row: function(active_scaffold_id, html, options) {
    if (typeof(active_scaffold_id) == 'string') active_scaffold_id = '#' + active_scaffold_id;
    tbody = jQuery(active_scaffold_id).find('tbody.records').first();
    var new_row;

Severity: Minor
Found in app/assets/javascripts/jquery/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 configure_column_link has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def configure_column_link(link, record, associated, actions = nil)
        actions ||= link.controller_actions || []
        if column_empty?(associated) # if association is empty, we only can link to create form
          if actions.include?(:new)
            link.action = 'new'
Severity: Minor
Found in lib/active_scaffold/helpers/action_link_helpers.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 conditions_from_constraints has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def conditions_from_constraints
      hash_conditions = {}
      conditions = [hash_conditions]
      active_scaffold_constraints.each do |k, v|
        column = active_scaffold_config.columns[k]
Severity: Minor
Found in lib/active_scaffold/constraints.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_from_association_constraint has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def condition_from_association_constraint(association, value)
      # when the reverse association is a :belongs_to, the id for the associated object only exists as
      # the primary_key on the other table. so for :has_one and :has_many (when the reverse is :belongs_to),
      # we have to use the other model's primary_key.
      #
Severity: Minor
Found in lib/active_scaffold/constraints.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 register_constraints_with_action_columns has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def register_constraints_with_action_columns(constrained_fields = nil)
      constrained_fields ||= []
      constrained_fields |= active_scaffold_constraints.select { |k, v| register_constraint?(k, v) }.keys.collect(&:to_sym)
      exclude_actions = []
      %i[list update].each do |action_name|
Severity: Minor
Found in lib/active_scaffold/constraints.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

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

    removeHoverEffect: function() {
        if (this.settings.hover_class)
            this.dom.removeClass(this.settings.hover_class);
        else
            this.dom.css("background-color", this.settings.bg_out);
Severity: Major
Found in app/assets/javascripts/jquery/jquery.editinplace.js and 1 other location - About 1 hr to fix
app/assets/javascripts/jquery/jquery.editinplace.js on lines 164..169

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

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

    addHoverEffect: function() {
        if (this.settings.hover_class)
            this.dom.addClass(this.settings.hover_class);
        else
            this.dom.css("background-color", this.settings.bg_over);
Severity: Major
Found in app/assets/javascripts/jquery/jquery.editinplace.js and 1 other location - About 1 hr to fix
app/assets/javascripts/jquery/jquery.editinplace.js on lines 171..176

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

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

      def active_scaffold(model_id = nil, &block)
        extend Prefixes
        # initialize bridges here
        ActiveScaffold::Bridges.run_all

Severity: Minor
Found in lib/active_scaffold/core.rb - About 1 hr to fix

    Function handleSubmitToServer has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        handleSubmitToServer: function(enteredText) {
            var data = '';
            if (typeof(enteredText) === 'string') {
                data += this.settings.update_value + '=' + encodeURIComponent(enteredText) + '&';
            } else {
    Severity: Minor
    Found in app/assets/javascripts/jquery/jquery.editinplace.js - About 1 hr to fix

      Method render_parent_action has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def render_parent_action
              if @parent_action.nil?
                @parent_action = :row
                if parent_sti_controller
                  parent_sti_config = parent_sti_controller.active_scaffold_config
      Severity: Minor
      Found in lib/active_scaffold/helpers/controller_helpers.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 format_collection_association_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def format_collection_association_value(value, column, label_method, size)
              associated_limit = column.associated_limit
              if associated_limit.nil?
                firsts = value.collect(&label_method)
                safe_join firsts, association_join_text(column)
      Severity: Minor
      Found in lib/active_scaffold/helpers/list_column_helpers.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 active_scaffold_human_condition_select has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def active_scaffold_human_condition_select(column, associated)
              attribute = column.active_record_class.human_attribute_name(column.name)
              associated = [associated].compact unless associated.is_a? Array
              if column.association
                method = column.options[:label_method] || :to_label
      Severity: Minor
      Found in lib/active_scaffold/helpers/human_condition_helpers.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 disable_optional_subforms has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        disable_optional_subforms: function(element) {
          jQuery('.sub-form.optional', element).each(function () {
            var $this = jQuery(this), toggle = $this.find('>.visibility-toggle');
            if (toggle.length) {
              var hide = toggle.text() == toggle.data('show');
      Severity: Minor
      Found in app/assets/javascripts/jquery/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 visibles_and_hiddens has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def visibles_and_hiddens(search_config)
              visibles = []
              hiddens = []
              search_config.columns.each_column do |column|
                next unless column.search_sql
      Severity: Minor
      Found in lib/active_scaffold/helpers/search_column_helpers.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 each_column has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def each_column(options = {}, &proc)
            columns = options[:core_columns] || action.core.columns
            self.unauthorized_columns = []
            options[:for] ||= columns.active_record_class
      
      
      Severity: Minor
      Found in lib/active_scaffold/data_structures/action_columns.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 active_scaffold_new_record_subform has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def active_scaffold_new_record_subform(column, record, html_options, ui_options: column.options, new_record_attributes: nil, locals: {}, skip_link: false)
              klass =
                if column.association.polymorphic? && column.association.belongs_to?
                  type = record.send(column.association.foreign_type)
                  column.association.klass(record) if type.present? && (ui_options[:add_new] == true || type.in?(ui_options[:add_new]))
      Severity: Minor
      Found in lib/active_scaffold/helpers/form_column_helpers.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

      Severity
      Category
      Status
      Source
      Language