cloudspokes/cs-website-cms

View on GitHub
app/controllers/challenges_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

Class ChallengesController has 41 methods (exceeds 20 allowed). Consider refactoring.
Open

class ChallengesController < ApplicationController

  before_filter :authenticate_user!, :only => [:preview, :preview_survey, :review, :register, 
    :watch, :agree_tos, :submission, :submissions, :submission_view_only, :comment, 
    :submit, :submit_details, :participant_submissions, :results_scorecard, :appeals]
Severity: Minor
Found in app/controllers/challenges_controller.rb - About 5 hrs to fix

    File challenges_controller.rb has 372 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'will_paginate/array'
    require 'digest/sha1'
    
    class ChallengesController < ApplicationController
    
    
    Severity: Minor
    Found in app/controllers/challenges_controller.rb - About 4 hrs to fix

      Method search has 45 lines of code (exceeds 25 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

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

          def comment
            comments = params[:comment][:comments]
        
            if current_user.use_captcha?(@challenge, @current_member_participant)
              unless verify_recaptcha
        Severity: Minor
        Found in app/controllers/challenges_controller.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 register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def register
            redirect_to challenge_path, :error => 'Registration is closed for this challenge.' if current_challenge.closed_for_registration?
            # puts CsPlatform.docusign_document(current_user.access_token, current_challenge.docusign_document) if current_challenge.docusign_document    
            # if default tos, let them register
            if current_challenge.uses_default_tos?
        Severity: Minor
        Found in app/controllers/challenges_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

        There are no issues that match your filters.

        Category
        Status