cloudspokes/cs-website-cms

View on GitHub

Showing 56 of 93 total issues

Method process_submission has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def self.process_submission(challenge_id, membername, challenge_submission_id)

    # get an admin token for the get requests. fails without an admin token. not sure why.
    admin_access_token = RestforceUtils.access_token(:admin)

Severity: Minor
Found in lib/thurgood.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 update has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update

    # scrub out this crap when nothing submitted in ckeditor -- <p>&Acirc;&#32;</p>\r\n (see http://dev.ckeditor.com/ticket/9732)
    params[:admin_challenge][:description] = nil if params[:admin_challenge][:description].include?('&Acirc;&#32;')
    params[:admin_challenge][:requirements] = nil if params[:admin_challenge][:requirements].include?('&Acirc;&#32;')
Severity: Minor
Found in app/controllers/admin/challenges_controller.rb - About 1 hr to fix

    Method advanced_search has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.advanced_search(options)
        
        params = Hashie::Mash.new()    
    
        if options[:platforms]
    Severity: Minor
    Found in app/models/challenge.rb - About 1 hr to fix

      Method getJsConnectString has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def JsConnect.getJsConnectString(user, request = {}, client_id = "", secret = "", secure = true)
            error = nil
            
            timestamp = request["timestamp"].to_i
            current_timestamp = JsConnect.timestamp
      Severity: Minor
      Found in lib/js_connect.rb - About 1 hr to fix

        Method process_submission has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.process_submission(challenge_id, membername, challenge_submission_id)
        
            # get an admin token for the get requests. fails without an admin token. not sure why.
            admin_access_token = RestforceUtils.access_token(:admin)
        
        
        Severity: Minor
        Found in lib/thurgood.rb - About 1 hr to fix

          Method payload has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def payload
              # Get the original challenge to figure out the stuff to be deleted.
              # We are re-requesting the original challenge instead of tracking which
              # entries are to be deleted client-side to minimize race conditions. Race
              # conditions aren't totally eliminated, but the window is largely smaller
          Severity: Minor
          Found in app/models/admin/challenge.rb - About 1 hr to fix

            Method login_third_party has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def login_third_party(omniauth, sfdc_account)
            
                  begin
            
                    db_authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
            Severity: Minor
            Found in app/controllers/authentications_controller.rb - About 1 hr to fix

              Method search has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                def search
                  @title = 'Challenge Search Results'
                  search_default_params
              
                  gon.adv_search_display = true
              Severity: Minor
              Found in app/controllers/challenges_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

              Method redis_insert has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def redis_insert
                  Rails.logger.info "[REDIS] Inserting challenge #{challenge_id}"
                  nest[:raw_data].hset challenge_id, raw_data.to_json
              
                  redis_metaphones.each do |meta|
              Severity: Minor
              Found in lib/redis/challenge_searchable.rb - About 1 hr to fix

                Function appendItem has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      appendItem: function(source) {
                        var that = this,
                            html,
                            $standardItem;
                
                
                Severity: Minor
                Found in app/assets/javascripts/bootstrap-typeahead.js - About 1 hr to fix

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

                      def current_access_token
                        if current_user
                          if current_user.access_token
                            current_user.last_access_token_refresh_at = Date.yesterday if current_user.last_access_token_refresh_at.nil?
                            logger.info "[ACCESS_TOKEN] Has access token expired?: #{Time.now.utc} (Now) > 45 minutes past last refresh #{current_user.last_access_token_refresh_at.getutc} - expired? #{Time.now.utc > 45.minutes.since(current_user.last_access_token_refresh_at.getutc)}"
                  Severity: Minor
                  Found in app/controllers/application_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

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

                    def self.perform(membername, email, challenge_id, challenge_participant_id)
                  
                      account = {
                        :name => membername, 
                        :email => email,
                  Severity: Minor
                  Found in app/workers/create_papertrail_system.rb - About 1 hr to fix

                    Method update has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def update
                        user = User.find_by_username(params[:user][:username].downcase)
                        attributes = params[:user]
                        if user and attributes[:password].present? and attributes[:password] == attributes[:password_confirmation]
                          resp = user.account.update_password(attributes[:reset_password_token], attributes[:password])
                    Severity: Minor
                    Found in app/controllers/users/passwords_controller.rb - About 1 hr to fix

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

                          def login_third_party(omniauth, sfdc_account)
                      
                            begin
                      
                              db_authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
                      Severity: Minor
                      Found in app/controllers/authentications_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

                      Method process_messages has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def process_messages(messages, type)
                                  processed_messages = []
                                  messages.each do |m|
                                      new_message = {}
                                      new_message['id'] = m.id
                      Severity: Minor
                      Found in lib/message_box.rb - About 1 hr to fix

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

                            def show_restricted_info(participant, user)
                              # if a challenge admin always return true!
                              return true if user && user.challenge_admin?(self)
                              if @require_registration
                                return false if participant.nil?
                        Severity: Minor
                        Found in app/models/challenge.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 check_for_appirio_task has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def check_for_appirio_task
                            if params[:task]
                        
                              cmc_client = Restforce.new :username => ENV['CMC_USERNAME'],
                                :password         => ENV['CMC_PASSWORD'],
                        Severity: Minor
                        Found in app/controllers/admin/challenges_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 redis_key_for_prize_money has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def redis_key_for_prize_money(value)
                              if value.is_a?(Hash)
                                min = value[:min].blank? ? 0 : value[:min].to_i
                                max = value[:max].blank? ? 1000000 : value[:max].to_i
                                nest[:temp][{prize_money: value}.hash].tap do |k|
                        Severity: Minor
                        Found in lib/redis/challenge_searchable.rb - About 45 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 results has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def results
                            if user_signed_in?
                              unless ['winner selected','no winner selected','failed','no winner selected'].include?(@challenge.status.downcase) || 
                                @challenge.challenge_type.downcase == "first2finish" || 
                                (current_user.challenge_admin?(@challenge) && ['review','scored - awaiting approval'].include?(@challenge.status.downcase))
                        Severity: Minor
                        Found in app/controllers/challenges_controller.rb - About 45 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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def initialize(params={})
                            # the api names some fields as challenge_xxx where as the payload needs to be xxx
                            # params['reviewers'] = params.delete('challenge_reviewers') if params.include? 'challenge_reviewers'
                            # params['commentNotifiers'] = params.delete('challenge_comment_notifiers') if params.include? 'challenge_comment_notifiers'
                            params['prizes'] = params.delete('challenge_prizes__r') if params.include? 'challenge_prizes__r'
                        Severity: Minor
                        Found in app/models/admin/challenge.rb - About 45 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