konsento/konsento

View on GitHub

Showing 21 of 21 total issues

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

    $.support.animation = (function() {

        var animationEnd = (function() {

            var element = doc.body || doc.documentElement,
Severity: Major
Found in app/assets/javascripts/angle/modules/utils.js and 1 other location - About 4 hrs to fix
app/assets/javascripts/angle/modules/utils.js on lines 12..30

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

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

    $.support.transition = (function() {

        var transitionEnd = (function() {

            var element = doc.body || doc.documentElement,
Severity: Major
Found in app/assets/javascripts/angle/modules/utils.js and 1 other location - About 4 hrs to fix
app/assets/javascripts/angle/modules/utils.js on lines 32..50

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

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

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

                              if @subscription.save
                                return "just_subscribed"
                              else
                                @redirect_url = url_for(
                                  controller: '/requirement_values',
                Severity: Minor
                Found in app/controllers/js/proposals_controller.rb and 1 other location - About 15 mins to fix
                app/controllers/js/proposals_controller.rb on lines 113..123

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

                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