cubesystems/releaf

View on GitHub

Showing 95 of 95 total issues

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

    body.on('contentloaded', function(e)
    {
        jQuery(e.target).find('.flash').trigger('notificationaddflash');
    });
releaf-core/app/assets/javascripts/releaf/include/search.js on lines 139..142

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

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

      def duplicate_dragonfly_attachments(original, copy)
        attachment_keys = original.dragonfly_attachments.keys
        return unless attachment_keys.present?

        # during the dup() call the copy object has its dragonfly_attachments property duplicated from the original.
Severity: Minor
Found in releaf-content/app/services/releaf/content/node/copy.rb - About 35 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 destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def destroy
        begin
          content
        rescue NameError => e
          raise if content_id.nil? && content_type.nil?
Severity: Minor
Found in releaf-content/lib/releaf/content/node.rb - About 35 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 auto_create? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def auto_create?(key, options)
    return false unless config.i18n_database.translation_auto_creation
    return false if options[:auto_create] == false
    return false unless auto_creation_inclusion?(key)
    return false if auto_creation_exception?(key)
Severity: Minor
Found in releaf-i18n_database/app/lib/releaf/i18n_database/translations_store.rb - About 35 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 join_reflection_without_through has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def join_reflection_without_through(reflection, table)
      klass = reflection.active_record
      other_class = reflection.klass

      table1 = table || klass.arel_table
Severity: Minor
Found in releaf-core/app/lib/releaf/search.rb - About 35 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 build_tree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def build_tree
      object_hash = collection.inject({}) do |result, node|
        result[node.id] = { node: node, children: [] }
        result
      end
Severity: Minor
Found in releaf-content/app/builders/releaf/content/builders/tree.rb - About 35 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 releaf_button_content has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def releaf_button_content( text, icon, attributes = {} )
      if text.blank? && icon.present?
        raise ArgumentError, "Title is required for icon-only buttons" if attributes[:title].blank?
      end

Severity: Minor
Found in releaf-core/app/helpers/releaf/button_helper.rb - About 35 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 tree_resource_collapser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def tree_resource_collapser(resource, expanded)
      return if resource[:children].empty?
      tag(:div, class: "collapser-cell") do
        button(nil, (expanded ? 'chevron-down' : 'chevron-right'), class: %w(secondary collapser trigger), title: t(expanded ? "Collapse" : "Expand"))
      end
Severity: Minor
Found in releaf-content/app/builders/releaf/content/builders/tree.rb - About 35 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

        if (block.is('.field.i18n'))
        {
            fields = block;
        }
        else
releaf-core/app/assets/javascripts/releaf/include/toolbox.js on lines 21..28

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

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

    body.on('contentloaded', function(e)
    {
        // reinit localization for all content that gets replaced via ajax
        jQuery(e.target).trigger('localizationinit');

releaf-core/app/assets/javascripts/releaf/include/ajaxbox.js on lines 172..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 41.

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

    body.on('contentloaded', function(e)
    {
        // reinit ajaxbox for all content that gets replaced via ajax
        jQuery(e.target).trigger('ajaxboxinit');
    });
Severity: Minor
Found in releaf-core/app/assets/javascripts/releaf/include/ajaxbox.js and 1 other location - About 35 mins to fix
releaf-core/app/assets/javascripts/releaf/include/localization.js on lines 199..204

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

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 (target.is('.toolbox'))
        {
            toolboxes = target;
        }
        else
Severity: Minor
Found in releaf-core/app/assets/javascripts/releaf/include/toolbox.js and 1 other location - About 35 mins to fix
releaf-core/app/assets/javascripts/releaf/include/localization.js on lines 18..25

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

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

Avoid too many return statements within this method.
Open

    return false if stored_keys.key?(key)
Severity: Major
Found in releaf-i18n_database/app/lib/releaf/i18n_database/translations_store.rb - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return;
    Severity: Major
    Found in releaf-core/app/assets/javascripts/releaf/include/nested_fields.js - About 30 mins to fix

      Method releaf_button_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def releaf_button_attributes( text, icon, attributes = {} )
            default_attributes = {
              class: ["button"],
              title: text
            }
      Severity: Minor
      Found in releaf-core/app/helpers/releaf/button_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 normalize_controllers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.normalize_controllers(list)
            list.map do |item|
              if item.is_a?(Hash) && item.has_key?(:items)
                ControllerGroupDefinition.new(item)
              elsif item.is_a?(Hash) || item.is_a?(String)
      Severity: Minor
      Found in releaf-core/lib/releaf/configuration.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 join_search_tables has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def join_search_tables klass, attributes: fields, table: klass.arel_table
            attributes.each do |attribute|
              if attribute.is_a? Hash
                attribute.each_pair do |key, values|
                  reflection = klass.reflect_on_association(key.to_sym)
      Severity: Minor
      Found in releaf-core/app/lib/releaf/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 item_position_select_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def item_position_select_options
            after_text = t("After")
            list = [[t("First"), 0]]
      
            order_nodes = object.self_and_siblings.reorder(:item_position).to_a
      Severity: Minor
      Found in releaf-content/app/builders/releaf/content/nodes/form_builder.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 feature_available? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def feature_available?(feature)
          return false if feature.blank?
          return false if feature == :create_another && !feature_available?(:create)
          return false if feature == :search && !feature_available?(:index)
          features.include? feature
      Severity: Minor
      Found in releaf-core/app/lib/releaf/action_controller/features.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 merge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def merge!(var_name, hash_value)
            raise ArgumentError unless hash_value.is_a?(Hash)
      
            old_value = self[var_name] || {}
            raise TypeError, "Existing value is not a hash, can't merge!" unless old_value.is_a?(Hash)
      Severity: Minor
      Found in releaf-core/lib/releaf/settings.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