codeRIT/hackathon_manager

View on GitHub
app/controllers/questionnaires_controller.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

  def new
    if current_user.questionnaire.present?
      return redirect_to questionnaires_path
    end
    @questionnaire = Questionnaire.new
Severity: Minor
Found in app/controllers/questionnaires_controller.rb - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

        return true unless info["phone_number"].blank? || info["level_of_study"].blank? || info["major"].blank? ||
                           info["date_of_birth"].blank? || info["gender"].blank? || info["school"].blank? ||
                           info["school"]["name"].blank?
    Severity: Major
    Found in app/controllers/questionnaires_controller.rb - About 1 hr to fix

      Method new has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
      Open

        def new
          if current_user.questionnaire.present?
            return redirect_to questionnaires_path
          end
          @questionnaire = Questionnaire.new
      Severity: Minor
      Found in app/controllers/questionnaires_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

      Add empty line after guard clause.
      Open

          end

      This cop enforces empty line after guard clause

      Example:

      # bad
      def foo
        return if need_return?
        bar
      end
      
      # good
      def foo
        return if need_return?
      
        bar
      end
      
      # good
      def foo
        return if something?
        return if something_different?
      
        bar
      end
      
      # also good
      def foo
        if something?
          do_something
          return if need_return?
        end
      end

      Add empty line after guard clause.
      Open

          return "late_waitlist" if HackathonConfig['auto_late_waitlist']

      This cop enforces empty line after guard clause

      Example:

      # bad
      def foo
        return if need_return?
        bar
      end
      
      # good
      def foo
        return if need_return?
      
        bar
      end
      
      # good
      def foo
        return if something?
        return if something_different?
      
        bar
      end
      
      # also good
      def foo
        if something?
          do_something
          return if need_return?
        end
      end

      Add empty line after guard clause.
      Open

          end

      This cop enforces empty line after guard clause

      Example:

      # bad
      def foo
        return if need_return?
        bar
      end
      
      # good
      def foo
        return if need_return?
      
        bar
      end
      
      # good
      def foo
        return if something?
        return if something_different?
      
        bar
      end
      
      # also good
      def foo
        if something?
          do_something
          return if need_return?
        end
      end

      There are no issues that match your filters.

      Category
      Status