testmycode/tmc-server

View on GitHub

Showing 278 of 278 total issues

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

  def show
    @exercise = Exercise.find(params[:id])
    @course = Course.lock('FOR SHARE').find(@exercise.course_id)
    @organization = @course.organization
    authorize! :read, @course
Severity: Minor
Found in app/controllers/exercises_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

File submissions_controller.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'submission_processor'

# Receives submissions and presents the full submission list and submission view.
# Also handles rerun requests.
class SubmissionsController < ApplicationController
Severity: Minor
Found in app/controllers/submissions_controller.rb - About 3 hrs to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

              def award_points
                submission = @review.submission
                exercise = submission.exercise
                course = exercise.course
                raise 'Exercise of submission has been moved or deleted' unless exercise
    Severity: Major
    Found in app/controllers/api/v8/core/courses/reviews_controller.rb and 1 other location - About 3 hrs to fix
    app/controllers/api/v8/core/submissions/reviews_controller.rb on lines 66..94

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 115.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                def award_points
                  submission = @review.submission
                  exercise = submission.exercise
                  course = exercise.course
                  raise 'Exercise of submission has been moved or deleted' unless exercise
    app/controllers/api/v8/core/courses/reviews_controller.rb on lines 133..161

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 115.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method parse_condition has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_condition(str)
          if DateAndTimeUtils.looks_like_date_or_time(str)
            time = DateAndTimeUtils.to_time(str)
            raise 'Date out of range' if time.year > 10_000 || time.year < 1 # Prevent database datetime overflow
            raise "You can't have multiple unlock dates for the same exercise" if @datetime_count > 0 # Multiple unlock dates don't work correctly
    Severity: Minor
    Found in app/models/unlock_spec.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 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def show
              @submission = Submission.find_by!(id: params[:id])
              unless @submission.processed?
                authorization_skip!
                sandbox_status = :created
    Severity: Major
    Found in app/controllers/api/v8/core/submissions_controller.rb - About 3 hrs to fix

      Method parse_condition has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def parse_condition(str)
            if DateAndTimeUtils.looks_like_date_or_time(str)
              time = DateAndTimeUtils.to_time(str)
              raise 'Date out of range' if time.year > 10_000 || time.year < 1 # Prevent database datetime overflow
              raise "You can't have multiple unlock dates for the same exercise" if @datetime_count > 0 # Multiple unlock dates don't work correctly
      Severity: Major
      Found in app/models/unlock_spec.rb - About 2 hrs to fix

        File user.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class User < ApplicationRecord
          include Comparable
          include Gravtastic
          include Swagger::Blocks
          gravtastic
        Severity: Minor
        Found in app/models/user.rb - About 2 hrs to fix

          Method show has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def show
              @course ||= @submission.course
              @exercise ||= @submission.exercise
              @organization = @course.organization
          
          
          Severity: Major
          Found in app/controllers/submissions_controller.rb - About 2 hrs to fix

            Method respond_with_error has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                def respond_with_error(msg, code = 500, exception = nil, extra_json_keys = {})
                  respond_to do |format|
                    format.html do
                      render 'shared/respond_with_error',
                             locals: { message: ERB::Util.html_escape(msg), exception: exception },
            Severity: Minor
            Found in app/controllers/application_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 submission_review_column has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              def submission_review_column(submission)
                if submission.reviewed?
                  if can? :create_review, submission.course
                    link_to 'Available', new_submission_review_path(submission)
                  else
            Severity: Minor
            Found in app/helpers/submissions_helper.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 refresh has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.refresh(course_template_refresh_task)
                course_template = course_template_refresh_task.course_template
                command = "#{self.langs_executable_path}/current refresh-course"\
                " --cache-path #{course_template.cache_path}"\
                " --cache-root #{Course.cache_root}"\
            Severity: Minor
            Found in lib/rust_langs_cli_executor.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 visible_to? has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

              def visible_to?(user, ignore_email_verification = false)
                if user.administrator?
                  true
                elsif !ignore_email_verification && !user.email_verified?
                  false
            Severity: Minor
            Found in app/models/solution.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 update_available_points has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                  def update_available_points
                    @rust_data['exercises'].each do |exercise|
                      added = []
                      removed = []
            
            
            Severity: Minor
            Found in lib/course_refresh_database_updater.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 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                      def create
                        unauthorize_guest!
            
                        @exercise = Exercise.find(params[:exercise_id])
                        authorize! :read, @exercise
            Severity: Major
            Found in app/controllers/api/v8/core/exercises/submissions_controller.rb - About 2 hrs to fix

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

                def index
                  if params[:course_id]
                    @course = Course.find(params[:course_id])
                    @parent = @course
                    @numeric_stats = @course.exercises.where(hidden: false).sort.map do |ex|
              Severity: Major
              Found in app/controllers/feedback_answers_controller.rb - About 2 hrs to fix

                Class ApplicationController has 22 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class ApplicationController < ActionController::Base
                  include BreadCrumbs
                
                  helper :all
                
                
                Severity: Minor
                Found in app/controllers/application_controller.rb - About 2 hrs to fix

                  Method show has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                            def show
                              authorization_skip!
                              organization = Organization.find_by!(slug: params[:organization_slug])
                              course = organization.courses.find_by(name: "#{params[:organization_slug]}-#{params[:course_name]}")
                              course = organization.courses.find_by!(name: params[:course_name]) unless course
                  Severity: Major
                  Found in app/controllers/api/v8/organizations/courses/exercises_controller.rb - About 2 hrs to fix

                    Method create has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def create
                        if !params[:submission] || !params[:submission][:file]
                          return respond_not_found('No ZIP file selected or failed to receive it')
                        end
                    
                    
                    Severity: Major
                    Found in app/controllers/submissions_controller.rb - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language