Noosfero/noosfero

View on GitHub

Showing 1,643 of 1,643 total issues

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

  Cart.prototype.hide = function(register) {
    if(register) {
      this.ajax({
        url: '/plugin/shopping_cart/hide',
        dataType: 'json',
Severity: Major
Found in plugins/shopping_cart/public/cart.js and 1 other location - About 5 hrs to fix
plugins/shopping_cart/public/cart.js on lines 239..255

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

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 acts_as_faceted has 140 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def acts_as_faceted(options)
      extend ClassMethods
      extend ActsAsSolr::CommonMethods

      cattr_accessor :facets
Severity: Major
Found in plugins/solr/lib/acts_as_faceted.rb - About 5 hrs to fix

    Method extended has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.extended(base)
          if base.respond_to?(:scope)
            if base.attribute_names.include?("created_at")
              base.class_eval do
                scope :younger_than, lambda { |created_at|
    Severity: Minor
    Found in app/models/concerns/time_scopes.rb - About 5 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 CmsController has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class CmsController < MyProfileController
      protect "edit_profile", :profile, only: [:set_home_page]
    
      include ArticleHelper
      include CategoriesHelper
    Severity: Minor
    Found in app/controllers/my_profile/cms_controller.rb - About 5 hrs to fix

      File user.rb has 387 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "digest/sha1"
      require "securerandom"
      
      # User models the system users, and is generated by the acts_as_authenticated
      # Rails generator.
      Severity: Minor
      Found in app/models/user.rb - About 5 hrs to fix

        File infobox.js has 381 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * @name InfoBox
         * @version 1.1.9 [October 2, 2011]
         * @author Gary Little (inspired by proof-of-concept code from Pamela Fox of Google)
         * @copyright Copyright 2010 Gary Little [gary at luxcentral.com]
        Severity: Minor
        Found in plugins/sniffer/public/javascripts/infobox.js - About 5 hrs to fix

          Method dispatch_publications has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

            def dispatch_publications
              print_debug "open_graph: dispatch_publications of #{story}" if debug? self.actor
          
              return unless self.match_criteria?
          
          
          Severity: Minor
          Found in plugins/open_graph/models/open_graph_plugin/activity.rb - About 5 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 Callbacks has 127 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          jQuery.Callbacks = function( options ) {
          
              // Convert options from String-formatted to Object-formatted if needed
              // (we check in cache first)
              options = typeof options === "string" ?

            Method _move has 127 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function _move($id, $ref_id, $position = 0, $is_copy = false) {
                    if((int)$ref_id === 0 || (int)$id === 1) { return false; }
                    $sql        = array();                        // Queries executed at the end
                    $node        = $this->_get_node($id);        // Node data
                    $nchildren    = $this->_get_children($id);    // Node children

              Consider simplifying this complex logical expression.
              Open

                          if ( event.pageX == null && original.clientX != null ) {
                              eventDoc = event.target.ownerDocument || document;
                              doc = eventDoc.documentElement;
                              body = eventDoc.body;
              
              

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

                      else{
                        clicked.fadeOut(function(){
                          clicked.css("display","none");
                          clicked.parent().parent().find(".join-community").fadeIn();
                          clicked.parent().parent().find(".join-community").css("display", "");
                Severity: Major
                Found in public/javascripts/add-and-join.js and 1 other location - About 4 hrs to fix
                public/javascripts/add-and-join.js on lines 26..35

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

                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

                    $.post(url, function(data){
                      clicked.fadeOut(function(){
                        clicked.css("display","none");
                        clicked.parent().parent().find(".leave-community").fadeIn();
                        clicked.parent().parent().find(".leave-community").css("display", "");
                Severity: Major
                Found in public/javascripts/add-and-join.js and 1 other location - About 4 hrs to fix
                public/javascripts/add-and-join.js on lines 52..62

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

                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

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

                                            if(d) {
                                                if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
                                                else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree_is_loading"); }
                                                this.clean_node(obj);
                                                if(s_call) { s_call.call(this); }
                plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 1707..1712

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

                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

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

                                            else {
                                                if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
                                                else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree_is_loading"); }
                                                this.clean_node(obj);
                                                if(s_call) { s_call.call(this); }
                plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 1749..1754

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

                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 load_node_xml has 122 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                            load_node_xml : function (obj, s_call, e_call) {
                                var s = this.get_settings().xml_data,
                                    error_func = function () {},
                                    success_func = function () {};
                
                

                  Class Product has 37 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class ProductsPlugin::Product < ApplicationRecord
                    ##
                    # Keep compatibility with previous core name
                    #
                    def self.sti_name
                  Severity: Minor
                  Found in plugins/products/models/products_plugin/product.rb - About 4 hrs to fix

                    File profile_editor_helper.rb has 365 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    module ProfileEditorHelper
                      NATIONALITY = [
                        N_("Afghan"),
                        N_("Albanian"),
                        N_("Algerian"),
                    Severity: Minor
                    Found in app/helpers/profile_editor_helper.rb - About 4 hrs to fix

                      Method edit has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def edit
                          return show_more if params[:page].present?
                      
                          if request.xhr? && params[:order].present?
                            status = params[:order][:status]

                      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 _reconstruct has 118 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function _reconstruct() {
                              $this->db->query("" . 
                                  "CREATE TEMPORARY TABLE `temp_tree` (" . 
                                      "`".$this->fields["id"]."` INTEGER NOT NULL, " . 
                                      "`".$this->fields["parent_id"]."` INTEGER NOT NULL, " . 

                        File entities.rb has 363 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module Api
                          module Entities
                            PERMISSIONS = {
                              admin: 0,
                              self: 10,
                        Severity: Minor
                        Found in app/api/entities.rb - About 4 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language