Noosfero/noosfero

View on GitHub

Showing 1,643 of 1,643 total issues

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

                        error_func = function (x, t, e) {
                            var ef = this.get_settings().html_data.ajax.error; 
                            if(ef) { ef.call(this, x, t, e); }
                            if(obj != -1 && obj.length) {
                                obj.children("a.jstree-loading").removeClass("jstree-loading");
plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 1729..1741
plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 3253..3265

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

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 3 locations. Consider refactoring.
Open

                        error_func = function (x, t, e) {
                            var ef = this.get_settings().json_data.ajax.error; 
                            if(ef) { ef.call(this, x, t, e); }
                            if(obj != -1 && obj.length) {
                                obj.children("a.jstree-loading").removeClass("jstree-loading");
plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 3253..3265
plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 4092..4104

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

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 3 locations. Consider refactoring.
Open

                        error_func = function (x, t, e) {
                            var ef = this.get_settings().xml_data.ajax.error; 
                            if(ef) { ef.call(this, x, t, e); }
                            if(obj !== -1 && obj.length) {
                                obj.children("a.jstree-loading").removeClass("jstree-loading");
plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 1729..1741
plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 4092..4104

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

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

  def article_actions
    actions = [following_button(@page, user)]

    if @page.allow_edit?(user) && !remove_content_button(:edit, @page)
      content = font_awesome(:edit, label_for_edit_article(@page))
Severity: Minor
Found in app/helpers/article_helper.rb - About 1 day 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 __init has 209 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        __init : function () {
            this.data.dnd = {
                active : false,
                after : false,
                inside : false,

    Class ProfileController has 58 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ProfileController < PublicController
      needs_profile
      before_action :check_access_to_profile, except: [:join, :join_not_logged, :index, :add]
      before_action :store_location, only: [:join, :join_not_logged, :report_abuse, :send_mail]
      before_action :login_required, only: [:add, :join, :leave, :unblock, :leave_scrap, :remove_scrap, :remove_activity, :view_more_activities, :view_more_network_activities, :report_abuse, :register_report, :leave_comment_on_activity, :send_mail, :follow, :unfollow]
    Severity: Major
    Found in app/controllers/public/profile_controller.rb - About 1 day to fix

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

              calendar : {
                  sameDay : function () {
                      return '[avui a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
                  },
                  nextDay : function () {
      Severity: Major
      Found in plugins/orders/public/javascripts/moment-with-locales.js and 2 other locations - About 1 day to fix
      plugins/orders/public/javascripts/moment-with-locales.js on lines 5037..5054
      plugins/orders/public/javascripts/moment-with-locales.js on lines 5615..5632

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

      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 3 locations. Consider refactoring.
      Open

              calendar : {
                  sameDay : function () {
                      return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
                  },
                  nextDay : function () {
      Severity: Major
      Found in plugins/orders/public/javascripts/moment-with-locales.js and 2 other locations - About 1 day to fix
      plugins/orders/public/javascripts/moment-with-locales.js on lines 4208..4225
      plugins/orders/public/javascripts/moment-with-locales.js on lines 5615..5632

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

      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 3 locations. Consider refactoring.
      Open

              calendar : {
                  sameDay : function () {
                      return '[hoxe ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
                  },
                  nextDay : function () {
      Severity: Major
      Found in plugins/orders/public/javascripts/moment-with-locales.js and 2 other locations - About 1 day to fix
      plugins/orders/public/javascripts/moment-with-locales.js on lines 4208..4225
      plugins/orders/public/javascripts/moment-with-locales.js on lines 5037..5054

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

      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

              this.container.find('.calendar')
                  .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
                  .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
                  .on('click.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
                  .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
      Severity: Major
      Found in plugins/orders/public/javascripts/daterangepicker.js and 1 other location - About 1 day to fix
      plugins/orders/public/javascripts/daterangepicker.js on lines 86..94

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

      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

              this.container.find('.ranges')
                  .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
                  .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
                  .on('click.daterangepicker', '.daterangepicker_start_input,.daterangepicker_end_input', $.proxy(this.showCalendars, this))
                  .on('change.daterangepicker', '.daterangepicker_start_input,.daterangepicker_end_input', $.proxy(this.inputsChanged, this))
      Severity: Major
      Found in plugins/orders/public/javascripts/daterangepicker.js and 1 other location - About 1 day to fix
      plugins/orders/public/javascripts/daterangepicker.js on lines 76..84

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

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

        def self.included(base)
          base.class_eval do
            before_create do |ra|
              if ra.resource.kind_of?(Profile)
                profile = ra.resource
      Severity: Minor
      Found in plugins/custom_forms/lib/ext/role_assignment_trigger.rb - About 7 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

      Method date_field has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
      Open

        def date_field(name, value, datepicker_options = {}, html_options = {})
          datepicker_options[:disabled] ||= false
          datepicker_options[:alt_field] ||= ""
          datepicker_options[:alt_format] ||= ""
          datepicker_options[:append_text] ||= ""
      Severity: Minor
      Found in app/helpers/forms_helper.rb - About 7 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

      File helpers.rb has 495 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "base64"
      require "tempfile"
      require "recaptcha"
      
      module Api
      Severity: Minor
      Found in app/api/helpers.rb - About 7 hrs to fix

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

                    $(document)
                        .bind("keydown", "up", function (e) { 
                            if($.vakata.context.vis) { 
                                var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").prevAll("li:not(.vakata-separator)").first();
                                if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").last(); }
        plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 3647..3665

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

        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

        File profile_controller.rb has 477 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class ProfileController < PublicController
          needs_profile
          before_action :check_access_to_profile, except: [:join, :join_not_logged, :index, :add]
          before_action :store_location, only: [:join, :join_not_logged, :report_abuse, :send_mail]
          before_action :login_required, only: [:add, :join, :leave, :unblock, :leave_scrap, :remove_scrap, :remove_activity, :view_more_activities, :view_more_network_activities, :report_abuse, :register_report, :leave_comment_on_activity, :send_mail, :follow, :unfollow]
        Severity: Minor
        Found in app/controllers/public/profile_controller.rb - About 7 hrs to fix

          Method map_facet_results has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
          Open

                def map_facet_results(facet, facet_params, facets_data, unfiltered_facets_data = {}, options = {})
                  raise "Use map_facets_for before this method" if facet[:solr_field].nil?
          
                  facets_data = {} if facets_data.blank? # could be empty array
                  solr_facet = to_solr_fields_names[facet[:solr_field]]
          Severity: Minor
          Found in plugins/solr/lib/acts_as_faceted.rb - About 7 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

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

                                      if(e.pageX + 24 > this.data.dnd.cof.left + this.data.dnd.cw) {
                                          if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
                                          this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft += $.vakata.dnd.scroll_spd; }, cnt), 100);
                                      }
                                      else if(e.pageX - 24 < this.data.dnd.cof.left) {
          plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 2372..2382

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

          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(e.pageY + 24 > this.data.dnd.cof.top + this.data.dnd.ch) {
                                          if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
                                          this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop += $.vakata.dnd.scroll_spd; }, cnt), 100);
                                      }
                                      else if(e.pageY - 24 < this.data.dnd.cof.top) {
          plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 2359..2369

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

          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($(window).width() - (e.pageX - l) < 20) {
                              if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
                              if(!sli) { dir2 = "right"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() + $.vakata.dnd.scroll_spd); }, 150); }
                          }
                          else { 
          plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 2234..2240

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

          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