alexandre025/cdx

View on GitHub

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

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

          if($(elem).find('input').attr('data-end-date') != undefined)
              $(elem).datepicker('setEndDate', $(elem).find('input').attr('data-end-date'));
      Severity: Major
      Found in app/assets/javascripts/cdx/admin/shared/date_picker.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/cdx/admin/shared/date_picker.js on lines 19..20

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

      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($(elem).find('input').attr('data-start-date') != undefined)
            $(elem).datepicker('setStartDate', $(elem).find('input').attr('data-start-date'));
      Severity: Major
      Found in app/assets/javascripts/cdx/admin/shared/date_picker.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/cdx/admin/shared/date_picker.js on lines 22..23

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

      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

      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

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

                              else if(event.target.classList.contains('daterange-end')){
                                  $(elem).data('datepicker').pickers[1].setDate($(elem).datepicker.currentDate);
                              }
              Severity: Minor
              Found in app/assets/javascripts/cdx/admin/shared/date_picker.js and 1 other location - About 35 mins to fix
              app/assets/javascripts/cdx/admin/shared/date_picker.js on lines 33..38

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

              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(event.target.classList.contains('daterange-start')){
                                  $(elem).data('datepicker').pickers[0].setDate($(elem).datepicker.currentDate);
                              }
                              else if(event.target.classList.contains('daterange-end')){
                                  $(elem).data('datepicker').pickers[1].setDate($(elem).datepicker.currentDate);
              Severity: Minor
              Found in app/assets/javascripts/cdx/admin/shared/date_picker.js and 1 other location - About 35 mins to fix
              app/assets/javascripts/cdx/admin/shared/date_picker.js on lines 36..38

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

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

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

                    def current_ability
                      if try(:current_admin_user)
                        controller_name_segments = params[:controller].split('/')
                        controller_name_segments.pop
                        controller_namespace = controller_name_segments.join('/').camelize
              Severity: Minor
              Found in app/controllers/cdx/admin/base_controller.rb and 1 other location - About 25 mins to fix
              app/controllers/cdx/application_controller.rb on lines 8..15

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

              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 current_ability
                    if try(:current_user)
                      controller_name_segments = params[:controller].split('/')
                      controller_name_segments.pop
                      controller_namespace = controller_name_segments.join('/').camelize
              Severity: Minor
              Found in app/controllers/cdx/application_controller.rb and 1 other location - About 25 mins to fix
              app/controllers/cdx/admin/base_controller.rb on lines 26..33

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

              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 parent_data.present?
                          cdx.send "admin_#{resource.model_name}_#{resource.object_name}_url", parent, target, options
                        else
                          cdx.send "admin_#{resource.object_name}_url", target, options
              Severity: Minor
              Found in app/controllers/cdx/admin/resource_controller.rb and 1 other location - About 15 mins to fix
              app/controllers/cdx/admin/resource_controller.rb on lines 165..168

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

              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 parent_data.present?
                          cdx.send "edit_admin_#{resource.model_name}_#{resource.object_name}_url", parent, object, options
                        else
                          cdx.send "edit_admin_#{resource.object_name}_url", object, options
              Severity: Minor
              Found in app/controllers/cdx/admin/resource_controller.rb and 1 other location - About 15 mins to fix
              app/controllers/cdx/admin/resource_controller.rb on lines 178..181

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

              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

                class Asset::User::Avatar < Asset
                  has_attached_file :attachment,
                                    styles:  { thumb: '100x100^', regular: '250x250^' },
                                    url:            '/cdx/user/avatar/:id/:style/:basename.:extension',
                                    path:           ':rails_root/public/cdx/user/avatar/:id/:style/:basename.:extension',
              Severity: Minor
              Found in app/models/cdx/asset/user/avatar.rb and 1 other location - About 15 mins to fix
              app/models/cdx/asset/seo/og_image.rb on lines 2..10

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

              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 link_to_edit(resource, options = {})
                      if can? :edit, resource
                        url             = options[:url] || edit_object_url(resource)
                        options[:class] = 'btn-sm btn-info'
                        link_to fa_icon(:pencil), url, options
              Severity: Minor
              Found in app/helpers/cdx/admin/resource_helper.rb and 1 other location - About 15 mins to fix
              app/helpers/cdx/admin/resource_helper.rb on lines 42..46

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

              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

                class Asset::Seo::OgImage < Asset
                  has_attached_file :attachment,
                                    styles:  { thumb: '600x315^', regular: '1200x630^' },
                                    url:            '/cdx/seo/og_image/:id/:style/:basename.:extension',
                                    path:           ':rails_root/public/cdx/seo/og_image/:id/:style/:basename.:extension',
              Severity: Minor
              Found in app/models/cdx/asset/seo/og_image.rb and 1 other location - About 15 mins to fix
              app/models/cdx/asset/user/avatar.rb on lines 2..10

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

              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

              Severity
              Category
              Status
              Source
              Language