konsento/konsento

View on GitHub

Showing 17 of 21 total issues

Method user_is_able_to_perform_action has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def user_is_able_to_perform_action
      if signed_in?
        unless @proposal.blank?
          if @proposal.topic.location.is_user_subscribed?(current_user)
            return "able"
Severity: Minor
Found in app/controllers/js/proposals_controller.rb - About 2 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 user_is_able_to_perform_action has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def user_is_able_to_perform_action
      if signed_in?
        unless @proposal.blank?
          if @proposal.topic.location.is_user_subscribed?(current_user)
            return "able"
Severity: Minor
Found in app/controllers/js/proposals_controller.rb - About 1 hr to fix

    Function StateToggler has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      window.StateToggler = function() {
    
        var storageKeyName  = 'jq-toggleState';
    
        // Helper object to check for words in a phrase //
    Severity: Minor
    Found in app/assets/javascripts/angle/modules/toggle-state.js - About 1 hr to fix

      Method perform has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def perform(params)
          location = Location.find(params[:location_id])
      
          topic = location.topics.create!(
            params.except(:proposals_attributes, :auto_split_text)
      Severity: Minor
      Found in app/jobs/create_topic_job.rb - About 1 hr to fix

        Method link_for_notification has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def link_for_notification(notification)
            if notification.notifiable
              case notification.notifiable_type
              when 'Comment'
                case notification.notifiable.commentable_type
        Severity: Minor
        Found in app/helpers/notifications_helper.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

        Method show has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def show
            if params[:locations]
              locations_slugs = params[:locations].split('/').last(Location.max_ancestry_size)
              locations_slugs.unshift(current_model.slug) if current_model.is_a? Location
              locations_slugs.unshift('global') unless locations_slugs.first == 'global'
        Severity: Minor
        Found in app/controllers/locations_controller.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 toggleMenuItem has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function toggleMenuItem($listItem) {
        
            removeFloatingNav();
        
            var ul = $listItem.children('ul');
        Severity: Minor
        Found in app/assets/javascripts/angle/modules/sidebar.js - About 1 hr to fix

          Method consensus has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def consensus(include_suggested)
              total_votes_minimum_percent = topic.location.total_votes_percent
              agree_votes_minimum_percent = topic.location.agree_votes_percent
          
              proposal = nil
          Severity: Minor
          Found in app/models/section.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 recursive_location_path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def recursive_location_path(location)
              locations = location.parents
              locations << location
              url_params = []
              subdomain = nil
          Severity: Minor
          Found in app/controllers/application_controller.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 invite_emails has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.invite_emails(emails, team, user)
              emails = emails.split(',') unless emails.respond_to? :to_ary
              emails = emails.map(&:strip)
              team_invitations = []
          
          
          Severity: Minor
          Found in app/models/team_invitation.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

          Method search_form_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def search_form_url
              if params[:controller] == 'locations' && (
                params[:action] == 'show' ||
                params[:action] == 'search_topics'
              )
          Severity: Minor
          Found in app/helpers/search_helper.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

          Method perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def perform(params)
              location = Location.find(params[:location_id])
          
              topic = location.topics.create!(
                params.except(:proposals_attributes, :auto_split_text)
          Severity: Minor
          Found in app/jobs/create_topic_job.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

          Avoid too many return statements within this method.
          Open

                        return "just_subscribed"
          Severity: Major
          Found in app/controllers/js/proposals_controller.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                          return "not_able_to_subscribe"
            Severity: Major
            Found in app/controllers/js/proposals_controller.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return "not_logged"
              Severity: Major
              Found in app/controllers/js/proposals_controller.rb - About 30 mins to fix

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

                  def self.invite_emails(emails, user)
                    emails = emails.split(',') unless emails.respond_to? :to_ary
                    emails = emails.map(&:strip)
                
                    return false unless user.available_invitations.to_i >= emails.size
                Severity: Minor
                Found in app/models/invitation.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 create_from_omniauth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def create_from_omniauth
                    auth_hash = request.env['omniauth.auth']
                
                    authentication =
                      Authentication.find_by_provider_and_uid(
                Severity: Minor
                Found in app/controllers/sessions_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

                Severity
                Category
                Status
                Source
                Language