alexandre025/cdx

View on GitHub

Showing 9 of 21 total issues

Function taxons_jstree has 108 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function taxons_jstree(data) {
    var create_or_update_url = data['create_or_update_url'];

    $('#taxonomy_tree').jstree({
        core: {
Severity: Major
Found in app/assets/javascripts/cdx/admin/controllers/taxonomies.js - About 4 hrs to fix

    Class ResourceController has 31 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class ResourceController < BaseController
          before_action :authenticate_admin_user!
    
          before_action :load_resource
    
    
    Severity: Minor
    Found in app/controllers/cdx/admin/resource_controller.rb - About 3 hrs to fix

      Function initDatepicker has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function initDatepicker(elem){
          $(elem).datepicker({
              language: 'fr',
              todayBtn: "linked",
              keyboardNavigation: false,
      Severity: Minor
      Found in app/assets/javascripts/cdx/admin/shared/date_picker.js - About 1 hr to fix

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

              def update
                @object.assign_attributes permitted_resource_params
        
                if @object.send current_action
                  flash_message(@object, (current_action == :save ? :update : current_action), :success)
        Severity: Minor
        Found in app/controllers/cdx/admin/publishable_resource_controller.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

        Consider simplifying this complex logical expression.
        Open

                if object.respond_to? :seo
                  fields['og:title']       = object.og_title || Setting.current.og_title
                  fields['og:description'] = object.og_description || Setting.current.og_description
                  fields['og:keywords']    = object.og_keywords || Setting.current.og_keywords
                  fields['og:image']       = object.og_image&.attachment&.url(:regular) || Setting.current.og_image&.attachment&.url(:regular)
        Severity: Major
        Found in lib/cdx/controller_helpers/seo.rb - About 40 mins to fix

          Function check_callback has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                      check_callback: function (op, node, par, pos, more) {
          Severity: Minor
          Found in app/assets/javascripts/cdx/admin/controllers/taxonomies.js - About 35 mins to fix

            Method main_sidebar_menu_simple_item has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def main_sidebar_menu_simple_item(current_main_tree, target, icon, path, label)
            Severity: Minor
            Found in app/helpers/cdx/admin/base_helper.rb - About 35 mins to fix

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

                    def content_header_page_title
                      # Work arround with Ransack issue, where all helpers are available
                      # even with our initializer : include_all_helpers = false
                      if @object && try(:member_action?)
                        # TODO : Parent data ?
              Severity: Minor
              Found in app/helpers/cdx/admin/resource_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 translated_field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def translated_field(form_object, field, options = {})
                      concat form_object.input field, options
                      current_settings.available_locales.each do |locale|
                        unless locale.to_sym == current_settings.default_locale.to_sym
                          options[:label] = form_object.object.class.human_attribute_name(field) + ' ' + EmojiFlag.new(locale)
              Severity: Minor
              Found in app/helpers/cdx/admin/form_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

              Severity
              Category
              Status
              Source
              Language