cloudspokes/cs-website-cms

View on GitHub
app/controllers/admin/challenges_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method update has a Cognitive Complexity of 20 (exceeds 5 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 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 create has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create

    data = {}
    data[:name] = params[:name]
    data[:description] = '<p>Your 
Severity: Major
Found in app/controllers/admin/challenges_controller.rb - About 2 hrs to fix

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

        def edit
      
          # move the existing assets to a new array
          @current_assets = @challenge.assets || []
          # this array will only contain new assets being uploaded  
      Severity: Minor
      Found in app/controllers/admin/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

      There are no issues that match your filters.

      Category
      Status