Rademade/rademade_admin

View on GitHub

Showing 23 of 27 total issues

Method admin_resources has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

      def admin_resources(*resources, &block)
        options = resources.extract_options!.dup

        if apply_common_behavior_for(:admin_resources, resources, options, &block)
          return self
Severity: Minor
Found in lib/rademade_admin/routing/mapper.rb - About 3 hrs 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 editorConfig has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    CKEDITOR.editorConfig = function (config) {
        config.filebrowserBrowseUrl = "/ckeditor/attachment_files";

        // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
        config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
Severity: Minor
Found in app/assets/javascripts/ckeditor/config.js - About 3 hrs 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

Class DataItems has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

      class DataItems
        include ::Enumerable

        def initialize
          @data_items = {}
Severity: Minor
Found in lib/rademade_admin/model/info/data_items.rb - About 3 hrs to fix

    Class DataItem has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class DataItem
    
            # TODO extract sub classes
    
            attr_accessor :name, :field, :relation, :label, :uploader, :order_column, :form_params,
    Severity: Minor
    Found in lib/rademade_admin/model/info/data_item.rb - About 3 hrs to fix

      Class ModelController has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class ModelController < RademadeAdmin::AbstractController
      
          extend RademadeAdmin::ModelOptions
      
          include RademadeAdmin::InstanceOptions
      Severity: Minor
      Found in app/controllers/rademade_admin/model_controller.rb - About 2 hrs to fix

        Function editorConfig has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            CKEDITOR.editorConfig = function (config) {
                config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
        
                // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
                config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
        Severity: Major
        Found in app/assets/javascripts/ckeditor/config.js - About 2 hrs to fix

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

                    def _map_relations
                      relations = {}
                      @model.reflections.each do |name, relation_info|
                        name = name.to_sym
                        type = relation_info.macro
          Severity: Minor
          Found in lib/rademade_admin/model/adapter/data/active_record.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 _map_relations has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                    def _map_relations
                      relations = {}
                      @model.relations.each do |name, relation_info|
                        name = name.to_sym
                        type = relation_info.relation.macro
          Severity: Minor
          Found in lib/rademade_admin/model/adapter/data/mongoid.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 build_items has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  def build_items
                    data_items = RademadeAdmin::Model::Info::DataItems.new
                    used_relations = []
          
                    # TODO extract sub - methods
          Severity: Minor
          Found in lib/rademade_admin/model/info/fields.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 admin_resources has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def admin_resources(*resources, &block)
                  options = resources.extract_options!.dup
          
                  if apply_common_behavior_for(:admin_resources, resources, options, &block)
                    return self
          Severity: Minor
          Found in lib/rademade_admin/routing/mapper.rb - About 1 hr to fix

            Method template_paths has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def template_paths
                  @template_paths ||= {
                    :main_layout => layout_path('main'),
                    :login_layout => layout_path('login'),
                    :content_item_layout => layout_path('content_item'),
            Severity: Minor
            Found in app/services/template_service.rb - About 1 hr to fix

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

                    def delete_other_images(image_path)
                      filename = File.basename(image_path)
              
                      store_path = full_image_path(store_dir)
              
              
              Severity: Minor
              Found in lib/rademade_admin/uploader/photo.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 crop has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def crop(image_path, x, y, width, height)
              Severity: Minor
              Found in lib/rademade_admin/uploader/crop_photo.rb - About 35 mins to fix

                Method collect_where_conditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                          def collect_where_conditions(where_conditions)
                            condition = ''
                            values = []
                            where_conditions.parts.each do |part|
                              condition += " #{where_conditions.type.to_s.capitalize} " unless condition.empty?
                Severity: Minor
                Found in lib/rademade_admin/model/adapter/query/sql.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 save_model_upload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def save_model_upload(data_item, image_path)
                      if item.try(:translation).respond_to? data_item.setter
                        entity = item.translation
                      else
                        entity = item
                Severity: Minor
                Found in app/services/saver.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 collect_children has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def collect_children(menu_key)
                    menu = []
                    menu_key = menu_key.to_s
                    unless @menu_data[menu_key].nil?
                      @menu_data[menu_key].each do |model_info|
                Severity: Minor
                Found in app/helpers/rademade_admin/menu_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 display_item_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def display_item_value(item, data_item)
                    if data_item.list_preview_handler.nil?
                      value = item.send(data_item.list_preview_accessor)
                      return display_upload_item(value) if data_item.has_uploader?
                      return display_related_item(data_item, item, value) if data_item.has_relation?
                Severity: Minor
                Found in app/helpers/rademade_admin/field_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 save_localizable_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def save_localizable_fields
                      current_locale = I18n.locale
                      @model_info.data_items.localizable_fields.each do |_, data_item|
                        values = @params[:data].try(:[], data_item.name)
                        values.each do |locale, value|
                Severity: Minor
                Found in app/services/saver.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 default_field_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def default_field_type(data_item)
                    if data_item.gallery_relation?
                      :'rademade_admin/gallery'
                    elsif data_item.has_relation?
                      :'rademade_admin/related_select'
                Severity: Minor
                Found in app/helpers/rademade_admin/field_type_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 localizable? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                        def localizable?(localizable = true)
                          if !@form_params.nil? && @form_params.has_key?(:localize)
                            @form_params[:localize] == localizable
                          else
                            return !localizable unless has_field?
                Severity: Minor
                Found in lib/rademade_admin/model/info/data_item.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