testmycode/tmc-server

View on GitHub
app/controllers/participants_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method index_csv has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def index_csv
      CSV.generate(force_quotes: true) do |csv|
        title_row = (@ordinary_fields + @extra_fields.map(&:name)).select { |f| @visible_columns.include?(f) }.map(&:humanize)

        if @group_completion
Severity: Minor
Found in app/controllers/participants_controller.rb - About 3 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 show has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    @user = User.find(params[:id])
    authorize! :view_participant_information, @user
    # TODO: bit ugly -- and now it's even worse!
    @awarded_points =
Severity: Minor
Found in app/controllers/participants_controller.rb - About 1 hr to fix

    Method index has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def index
        if @organization.nil?
          authorize! :view, :participants_list
          courses = Course.all
          users = User.all
    Severity: Minor
    Found in app/controllers/participants_controller.rb - About 1 hr to fix

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

        def show
          @user = User.find(params[:id])
          authorize! :view_participant_information, @user
          # TODO: bit ugly -- and now it's even worse!
          @awarded_points =
      Severity: Minor
      Found in app/controllers/participants_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 index_csv has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def index_csv
            CSV.generate(force_quotes: true) do |csv|
              title_row = (@ordinary_fields + @extra_fields.map(&:name)).select { |f| @visible_columns.include?(f) }.map(&:humanize)
      
              if @group_completion
      Severity: Minor
      Found in app/controllers/participants_controller.rb - About 1 hr to fix

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

            def index_json_data
              result = []
              @participants.each do |user|
                record = { id: user.id, username: user.login, email: user.email }
                @extra_fields.each do |field|
        Severity: Minor
        Found in app/controllers/participants_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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            if @organization.nil?
              authorize! :view, :participants_list
              courses = Course.all
              users = User.all
        Severity: Minor
        Found in app/controllers/participants_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