Noosfero/noosfero

View on GitHub

Showing 1,031 of 1,643 total issues

Avoid too many return statements within this method.
Open

      return render partial: "comment/comment", collection: @comments
Severity: Major
Found in app/controllers/public/content_viewer_controller.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return "%1.1f TB" % value
    Severity: Major
    Found in lib/extensions/integer.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          redirect_to_translation && (return) if @page.profile.redirect_l10n
      Severity: Major
      Found in app/controllers/public/content_viewer_controller.rb - About 30 mins to fix

        Function validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              validate: function(form) {
                for (var i=0; tinymce.editors[i]; i++) {
                  var editor = tinymce.editors[i]
                  var textarea = editor.getElement()
                  textarea.value = editor.getContent()
        Severity: Minor
        Found in plugins/fb_app/public/javascripts/fb_app.js - 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

        Function cropImage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function cropImage(element) {
        
          $("#crop-image-button").click()
        
          if( jcrop_api != null ) jcrop_api.destroy()
        Severity: Minor
        Found in public/javascripts/cropped_image.js - 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

        Function edit_in_place_submit_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function edit_in_place_submit_image(form, field) {
        
          var formData = new FormData(form[0]);
        
          $.ajax({
        Severity: Minor
        Found in public/javascripts/edit-in-place.js - 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

        Function unlocalize_currency has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function unlocalize_currency(value, from) {
          if (!value)
            return 0;
          if (!from)
            from = locale;
        Severity: Minor
        Found in plugins/orders/public/javascripts/locale.js - 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

        Function autoCompleteStateCity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function autoCompleteStateCity($) {
          var country_selected = $('[id$="_country"] option:selected').val()
          if(country_selected == "BR")
          {
            $('#state_field').autocomplete({
        Severity: Minor
        Found in public/javascripts/city_state_validation.js - 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

        Method body_ending has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def body_ending
            domain = context.environment.piwik_domain
            site_id = context.environment.piwik_site_id
            unless domain.blank? || site_id.blank?
              piwik_url = "#{domain}/#{context.environment.piwik_path}"
        Severity: Minor
        Found in plugins/piwik/lib/piwik_plugin.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

        Method search_scope has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.search_scope(scope, params)
            scope = scope.with_status params[:status] if params[:status].present?
            scope = scope.for_consumer_id params[:consumer_id] if params[:consumer_id].present?
            scope = scope.for_profile_id params[:supplier_id] if params[:supplier_id].present?
            scope = scope.with_code params[:code] if params[:code].present?
        Severity: Minor
        Found in plugins/orders/models/orders_plugin/order.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

        Method holder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def holder
              return nil if self.box.nil? || self.owner.nil?
        
              if self.owner.kind_of?(Environment)
                return nil if self.owner.portal_community.nil?
        Severity: Minor
        Found in plugins/display_content/lib/display_content_block.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

        Method user_can_rate_now? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def user_can_rate_now?
              return false unless user
        
              ratings = OrganizationRating.where(
                organization_id: profile.id,

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

          def set_seed(new_seed = false)
            block = self
            proc do
              if block.order == "random"
                if new_seed || cookies[:_noosfero_community_tracks_rand_seed].blank?
        Severity: Minor
        Found in plugins/community_track/lib/community_track_plugin/track_list_block.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

        Method index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            if request.post?
              if params[:environment][:piwik_domain]
                params[:environment][:piwik_domain].sub! /^https?:\/\//, ""
              end
        Severity: Minor
        Found in plugins/piwik/controllers/piwik_plugin_admin_controller.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

        Method check_comment_actions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_comment_actions(comment)
            proc do
              if user
                comment.marked_as_read?(user) ? "#comment-action-mark-as-not-read-#{comment.id}" : "#comment-action-mark-as-read-#{comment.id}"
              end
        Severity: Minor
        Found in plugins/mark_comment_as_read/lib/mark_comment_as_read_plugin.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

        Method filter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def filter
            if id = params[:id]
              @order = OrdersCyclePlugin::Sale.find id rescue nil
              @cycle = @order.cycle
            else

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

            def distribute_products_to_consumer
              self.distribute_products_on_create = true if self.distribute_products_on_create.nil?
              return if self.self? || self.consumer.person? || (not self.distribute_products_on_create)
        
              already_supplied = self.consumer.distributed_products.unarchived.from_supplier_id(self.id).all
        Severity: Minor
        Found in plugins/suppliers/models/suppliers_plugin/supplier.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

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

          def edit
            @provider = params[:id] ? environment.oauth_providers.find(params[:id]) : environment.oauth_providers.new
            if request.post?
              if @provider.update(params["oauth_client_plugin_provider"])
                session[:notice] = _("Saved!")
        Severity: Minor
        Found in plugins/oauth_client/controllers/oauth_client_plugin_admin_controller.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

        Method get_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_node(block, articles)
              nodes = []
              articles.map do |article|
                node = {}
                node[:data] = article.title
        Severity: Minor
        Found in plugins/display_content/controllers/display_content_plugin_module.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

        Method docs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def docs
            order_string = "published_at"
            order_string += " DESC" if order_by_recent
        
            limit_final = [limit_to_show, 0].max
        Severity: Minor
        Found in plugins/display_content/lib/display_content_block.rb - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Severity
        Category
        Status
        Source
        Language