expertiza/expertiza

View on GitHub
app/controllers/submitted_content_controller.rb

Summary

Maintainability
B
6 hrs
Test Coverage
F
43%

Method submit_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def submit_file
    participant = AssignmentParticipant.find(params[:id])
    unless current_user_id?(participant.user_id)
      flash[:error] = "Authentication Error"
      redirect_to action: 'edit', id: participant.id
Severity: Minor
Found in app/controllers/submitted_content_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 submit_file has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def submit_file
    participant = AssignmentParticipant.find(params[:id])
    unless current_user_id?(participant.user_id)
      flash[:error] = "Authentication Error"
      redirect_to action: 'edit', id: participant.id
Severity: Major
Found in app/controllers/submitted_content_controller.rb - About 2 hrs to fix

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

      def download
        folder_name = params['current_folder']['name']
        file_name = params['download']
        raise 'Folder_name is nil.' if folder_name.nil?
        raise 'File_name is nil.' if file_name.nil?
    Severity: Minor
    Found in app/controllers/submitted_content_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 folder_action has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def folder_action
        @participant = AssignmentParticipant.find(params[:id])
        return unless current_user_id?(@participant.user_id)
    
        @current_folder = DisplayOption.new
    Severity: Minor
    Found in app/controllers/submitted_content_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 submit_hyperlink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def submit_hyperlink
        @participant = AssignmentParticipant.find(params[:id])
        return unless current_user_id?(@participant.user_id)
    
        team = @participant.team
    Severity: Minor
    Found in app/controllers/submitted_content_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

    unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
    Open

      file_extension = original_filename&.split('.')&.last&.downcase

    unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
    Open

      file_extension = original_filename&.split('.')&.last&.downcase

    There are no issues that match your filters.

    Category
    Status