cubesystems/releaf

View on GitHub

Showing 42 of 95 total issues

Function open_ajax_box has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var open_ajax_box = function( params )
    {
        var magnific_popup_params =
        {
            showCloseBtn     : false,
Severity: Minor
Found in releaf-core/app/assets/javascripts/releaf/include/ajaxbox.js - About 1 hr to fix

    Function get_notification_ids has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var get_notification_ids = function( params )
        {
            var notification_ids = [];
    
            if (typeof params === 'string')
    Severity: Minor
    Found in releaf-core/app/assets/javascripts/releaf/include/notifications.js - About 1 hr to fix

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

        def add_resource_breadcrumb(resource, url = nil)
          if resource.new_record?
            name=  I18n.t('New record', scope: 'admin.breadcrumbs')
            url = url_for(action: :new, only_path: true) if url.nil?
          else
      Severity: Minor
      Found in releaf-core/app/lib/releaf/action_controller/breadcrumbs.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 releaf_item_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def releaf_item_field(name, input: {}, label: {}, field: {}, options: {}, &block)
          label_options = {translation_key: name.to_s.sub(/_id$/, '').to_s}
          attributes = input_attributes(name, {value: object.send(name)}.merge(input), options)
          options = {field: {type: "item"}, label: label_options}.deep_merge(options)
      
      
      Severity: Minor
      Found in releaf-core/app/builders/releaf/builders/form_builder/associations.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

      Avoid deeply nested control flow statements.
      Open

                          if( this.query[ name ] === undefined || !(this.query[ name ] instanceof Array) )
                          {
                              this.query[ name ] = [];
                          }
      Severity: Major
      Found in releaf-core/app/assets/javascripts/releaf/include/url_builder.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    for( var b in temp.query )
                    {
                        if (temp.query.hasOwnProperty(b))
                        {
                            this.query[ b ] = temp.query[b];
        Severity: Major
        Found in releaf-core/app/assets/javascripts/releaf/include/url_builder.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if( this.query[ name ] === undefined || !(this.query[ name ] instanceof Array) )
                              {
                                  this.query[ name ] = [];
                              }
          Severity: Major
          Found in releaf-core/app/assets/javascripts/releaf/include/url_builder.js - About 45 mins to fix

            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

            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

                Severity
                Category
                Status
                Source
                Language