cubesystems/releaf

View on GitHub

Showing 88 of 88 total issues

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

                    if( this.query[ name ] === undefined || !(this.query[ name ] instanceof Array) )
                    {
                        this.query[ name ] = [];
                    }
releaf-core/app/assets/javascripts/releaf/include/url_builder.js on lines 55..58

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

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 mount_releaf_at has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def mount_releaf_at(mount_location)
    mount_location_namespace = mount_location.delete("/").to_sym
    Releaf.application.config.mount_location = mount_location_namespace.to_s
    scope mount_location do
      initialize_releaf_components
Severity: Minor
Found in releaf-core/lib/releaf/route_mapper.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

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

    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

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

          body.on('attributechanged', 'textarea.richtext', function(event, event_params)
          {
              if (event_params.attribute !== 'id')
              {
                  return;
      releaf-core/app/assets/javascripts/releaf/include/field.type_richtext.js on lines 202..209

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

      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

          body.on('beforeattributechange', 'textarea.richtext', function(event, event_params)
          {
              if (event_params.attribute !== 'id')
              {
                  return;
      releaf-core/app/assets/javascripts/releaf/include/field.type_richtext.js on lines 211..218

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

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

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

              fields.find('.localization-switch .trigger').click(function()
              {
                  jQuery(this).closest('.field.i18n').trigger('localizationmenutoggle');
              });
      releaf-core/app/assets/javascripts/releaf/include/toolbox.js on lines 153..156

      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

              toolboxes.find('.trigger').click(function()
              {
                  jQuery(this).closest('.toolbox').trigger('toolboxtoggle');
              });
      Severity: Minor
      Found in releaf-core/app/assets/javascripts/releaf/include/toolbox.js and 1 other location - About 50 mins to fix
      releaf-core/app/assets/javascripts/releaf/include/localization.js on lines 99..102

      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

                  jQuery(instance.dpDiv[0]).find('.ui-datepicker-next').removeClass().addClass('button only-icon next').html('<i class="fa fa-chevron-right"></i>');
      releaf-core/app/assets/javascripts/releaf/include/field.type_date_or_datetime_or_time.js on lines 9..9

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

      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

              jQuery(event.target).find('textarea.richtext').each(function()
              {
                  jQuery(this).trigger('richtextsuspend');
              });
      releaf-core/app/assets/javascripts/releaf/include/field.type_richtext.js on lines 195..198

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

      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

              jQuery(event.target).find('textarea.richtext').each(function()
              {
                  jQuery(this).trigger('richtextresume');
              });
      releaf-core/app/assets/javascripts/releaf/include/field.type_richtext.js on lines 185..188

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

      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

                  jQuery(instance.dpDiv[0]).find('.ui-datepicker-prev').removeClass().addClass('button only-icon previous').html('<i class="fa fa-chevron-left"></i>');
      releaf-core/app/assets/javascripts/releaf/include/field.type_date_or_datetime_or_time.js on lines 10..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 46.

      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 store_settings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def store_settings
          if params[:settings].is_a? Hash
            params[:settings].each_pair do|key, value|
              value = false if value == "false"
              value = true if value == "true"
      Severity: Minor
      Found in releaf-core/app/controllers/releaf/root_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

      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

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

                body.on('contentloaded', function(e)
                {
                    jQuery(e.target).find('.flash').trigger('notificationaddflash');
                });
            releaf-core/app/assets/javascripts/releaf/include/search.js on lines 139..142

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

            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

                body.on('contentloaded', function(event)
                {
                    jQuery(event.target).find('form.search').trigger('searchinit');
                });
            Severity: Minor
            Found in releaf-core/app/assets/javascripts/releaf/include/search.js and 1 other location - About 40 mins to fix
            releaf-core/app/assets/javascripts/releaf/include/notifications.js on lines 260..263

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

            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