Rademade/rademade_admin

View on GitHub

Showing 27 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

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

                        def build_where_condition(field: nil, value: nil)
                          field = table_field(field)
              
                          if value.is_a? Regexp
                            ["LOWER(#{field}) ~* ?", [value.source]]
              Severity: Minor
              Found in lib/rademade_admin/model/adapter/query/postgresql.rb and 1 other location - About 45 mins to fix
              lib/rademade_admin/model/adapter/query/sql.rb on lines 32..40

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

              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 build_where_condition(field: nil, value: nil)
                          field = table_field(field)
                          if value.is_a? Regexp
                            ["LOWER(#{field}) REGEXP LOWER(?)", [value.source]]
                          elsif value.is_a? Array
              Severity: Minor
              Found in lib/rademade_admin/model/adapter/query/sql.rb and 1 other location - About 45 mins to fix
              lib/rademade_admin/model/adapter/query/postgresql.rb on lines 12..21

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

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

                Severity
                Category
                Status
                Source
                Language