pupilfirst/pupilfirst

View on GitHub

Showing 122 of 226 total issues

Method update_coach_enrollments has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def update_coach_enrollments
      course =
        authorize(
          scope.find(params[:course_id]),
          policy_class: Schools::CoursePolicy
Severity: Minor
Found in app/controllers/schools/courses_controller.rb - About 1 hr to fix

    Method execute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def execute(assignment_params)
          Assignment.transaction do
            @assignment.role = assignment_params[:role]
            @assignment.completion_instructions =
              assignment_params[:completion_instructions]
    Severity: Minor
    Found in app/services/assignments/update_service.rb - About 1 hr to fix

      Method target_rows has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def target_rows
            values =
              targets.map do |target|
                milestone = milestone?(target)
      
      
      Severity: Minor
      Found in app/services/course_exports/prepare_students_export_service.rb - About 1 hr to fix

        Method target_rows has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def target_rows
              values =
                team_targets.map do |target|
                  milestone = milestone?(target)
        
        
        Severity: Minor
        Found in app/services/course_exports/prepare_teams_export_service.rb - About 1 hr to fix

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

              def create_quiz(assignments)
                assignments.each do |old_assignment, new_assignment|
                  next unless old_assignment.quiz?
          
                  # create quiz
          Severity: Minor
          Found in app/services/levels/clone_service.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 grade has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def grade
                TimelineEvent.transaction do
                  if passed?
                    evaluation_criteria.each do |criterion|
                      TimelineEventGrade.create!(
          Severity: Minor
          Found in app/graphql/mutations/create_grading.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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def execute
                raise "user is a school admin" if @user.school_admin.present?
          
                if @user.discord_user_id.present?
                  Discord::ClearRolesService.new(
          Severity: Minor
          Found in app/services/users/delete_account_service.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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def execute(period_from, period_to)
                students = @course.students.active.where(excluded_from_leaderboard: false)
                log("Recording leaderboard entries for #{students.count} students in Course##{@course.id}...")
          
                LeaderboardEntry.transaction do
          Severity: Minor
          Found in app/services/courses/create_leaderboard_entries_service.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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def execute
              debug_value = {}
              cache_new_and_popular_topics
              cache_older_topics_with_recent_activity
          
          
          Severity: Minor
          Found in app/services/daily_digest_service.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 courses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def courses
                if current_user.blank?
                  current_school
                    .courses
                    .live
          Severity: Minor
          Found in app/presenters/layouts/course_nav_presenter.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

          Avoid deeply nested control flow statements.
          Open

                                  for (a = n.args || [], i = 0; i < a.length; ++i)
                                    if ("function" == typeof (l = a[i])) {
                                      l(e);
                                      break;
                                    }
          Severity: Major
          Found in app/frontend/shared/utils/rollbar.js - About 45 mins to fix

            Method authorized? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def authorized?
                return false if current_user.blank?
            
                # Has access to school
                return false unless course&.school == current_school && student.present?
            Severity: Minor
            Found in app/queries/concerns/authorize_student.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 course_link has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def course_link(course)
                  return if course.nil?
            
                  default_path = view.curriculum_course_path(course)
            
            
            Severity: Minor
            Found in app/presenters/layouts/course_nav_presenter.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 checklist_data_should_not_be_mutated has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def checklist_data_should_not_be_mutated
                    old_checklist =
                      @submission.checklist.map do |c|
                        [
                          c["title"],
            Severity: Minor
            Found in app/graphql/mutations/create_grading.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 query_authorized? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def query_authorized?
                return false if current_user.blank?
            
                # Has access to school
                return false unless course&.school == current_school && student.present?
            Severity: Minor
            Found in app/graphql/concerns/query_authorize_student.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 active? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def active?(key, user = nil)
                  return true if overridden?
            
                  feature = find_by(key: key)
            
            
            Severity: Minor
            Found in app/models/feature.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 create_vimeo_video has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def create_vimeo_video
                vimeo_api = Vimeo::ApiService.new(current_school)
                video_title = title.presence || target.title
                response = vimeo_api.create_video(size, video_title, description)
            
            
            Severity: Minor
            Found in app/queries/create_vimeo_video_mutator.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

            Function audioRecorder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function audioRecorder(authenticity_token, attachingCB) {
              const [state, setState] = useState({
                recording: false,
                url: undefined,
                blob: undefined,

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

              def applicable_submissions
                stage_1 = course.timeline_events.not_auto_verified.live
            
                # Filter by target
                stage_2 =
            Severity: Minor
            Found in app/queries/submissions_resolver.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 stringify_ids has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def stringify_ids(hash)
                hash.keys.each_with_object({}) do |key, result|
                  string_key = key.to_s
                  original_value = hash[key]
            
            
            Severity: Minor
            Found in lib/stringify_ids.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

            Severity
            Category
            Status
            Source
            Language