pupilfirst/pupilfirst

View on GitHub

Showing 226 of 226 total issues

Method save_report has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def save_report
      SubmissionReport.transaction do
        report =
          SubmissionReport.find_by(
            submission_id: @params[:submission_id],
Severity: Minor
Found in app/graphql/mutations/queue_submission_report.rb - About 1 hr to fix

    Method save_report has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def save_report
          SubmissionReport.transaction do
            report =
              SubmissionReport.find_by(
                submission_id: @params[:submission_id],
    Severity: Minor
    Found in app/graphql/mutations/conclude_submission_report.rb - About 1 hr to fix

      Method save_report has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def save_report
            SubmissionReport.transaction do
              report =
                SubmissionReport.find_by(
                  submission_id: @params[:submission_id],
      Severity: Minor
      Found in app/graphql/mutations/begin_processing_submission_report.rb - About 1 hr to fix

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

            def taggings
              BatchLoader::GraphQL
                .for(object.id)
                .batch do |user_ids, loader|
                  tags =
        Severity: Major
        Found in app/graphql/types/user_type.rb and 1 other location - About 1 hr to fix
        app/graphql/types/student_type.rb on lines 59..74

        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 51.

        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

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

            def taggings
              BatchLoader::GraphQL
                .for(object.id)
                .batch do |student_ids, loader|
                  tags =
        Severity: Major
        Found in app/graphql/types/student_type.rb and 1 other location - About 1 hr to fix
        app/graphql/types/user_type.rb on lines 59..74

        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 51.

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

            def sanitize_students(students)
              team_sizes = {}
        
              students.select do |student|
                if student.team_name.present?
        Severity: Minor
        Found in app/services/cohorts/add_students_service.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 compute_grading_for_submissions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def compute_grading_for_submissions(target, team_ids)
              submissions(target)
                .order(:created_at)
                .distinct
                .each_with_object(Array.new(team_ids.length)) do |submission, grading|
        Severity: Minor
        Found in app/services/course_exports/prepare_teams_export_service.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 toggle_standing has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def toggle_standing
            authorize current_school
        
            standing_enabled = params[:enable_standing] == "true"
        
        
        Severity: Minor
        Found in app/controllers/schools_controller.rb - About 1 hr to fix

          Method update_student_details has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def update_student_details
                if student&.name != @params[:name].strip
                  Users::LogUsernameUpdateService.new(
                    current_user,
                    @params[:name],
          Severity: Minor
          Found in app/graphql/mutations/update_student_details.rb - About 1 hr to fix

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

              class ArchiveCoachNote < GraphQL::Schema::Mutation
                argument :id, ID, required: true
            
                description "Archives a coach note for student"
            
            
            Severity: Major
            Found in app/graphql/mutations/archive_coach_note.rb and 4 other locations - About 1 hr to fix
            app/graphql/mutations/create_topic_subscription.rb on lines 2..18
            app/graphql/mutations/dropout_student.rb on lines 2..22
            app/graphql/mutations/lock_topic.rb on lines 2..18
            app/graphql/mutations/unlock_topic.rb on lines 2..18

            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 49.

            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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

              class CreateTopicSubscription < GraphQL::Schema::Mutation
                argument :topic_id, ID, required: true
            
                description "Create a topic subscription."
            
            
            Severity: Major
            Found in app/graphql/mutations/create_topic_subscription.rb and 4 other locations - About 1 hr to fix
            app/graphql/mutations/archive_coach_note.rb on lines 2..18
            app/graphql/mutations/dropout_student.rb on lines 2..22
            app/graphql/mutations/lock_topic.rb on lines 2..18
            app/graphql/mutations/unlock_topic.rb on lines 2..18

            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 49.

            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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

              class LockTopic < GraphQL::Schema::Mutation
                argument :id, ID, required: true
            
                description "Lock a topic in community."
            
            
            Severity: Major
            Found in app/graphql/mutations/lock_topic.rb and 4 other locations - About 1 hr to fix
            app/graphql/mutations/archive_coach_note.rb on lines 2..18
            app/graphql/mutations/create_topic_subscription.rb on lines 2..18
            app/graphql/mutations/dropout_student.rb on lines 2..22
            app/graphql/mutations/unlock_topic.rb on lines 2..18

            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 49.

            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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

              class DropoutStudent < GraphQL::Schema::Mutation
                argument :id, ID, required: true
            
                description 'Mark student as exited'
            
            
            Severity: Major
            Found in app/graphql/mutations/dropout_student.rb and 4 other locations - About 1 hr to fix
            app/graphql/mutations/archive_coach_note.rb on lines 2..18
            app/graphql/mutations/create_topic_subscription.rb on lines 2..18
            app/graphql/mutations/lock_topic.rb on lines 2..18
            app/graphql/mutations/unlock_topic.rb on lines 2..18

            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 49.

            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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

              class UnlockTopic < GraphQL::Schema::Mutation
                argument :id, ID, required: true
            
                description "Unlock a topic in community."
            
            
            Severity: Major
            Found in app/graphql/mutations/unlock_topic.rb and 4 other locations - About 1 hr to fix
            app/graphql/mutations/archive_coach_note.rb on lines 2..18
            app/graphql/mutations/create_topic_subscription.rb on lines 2..18
            app/graphql/mutations/dropout_student.rb on lines 2..22
            app/graphql/mutations/lock_topic.rb on lines 2..18

            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 49.

            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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              class UnmarkPostAsSolution < GraphQL::Schema::Mutation
                argument :id, ID, required: true
            
                description "Unmark a community post as a solution"
            
            
            Severity: Major
            Found in app/graphql/mutations/unmark_post_as_solution.rb and 2 other locations - About 1 hr to fix
            app/graphql/mutations/delete_certificate.rb on lines 2..21
            app/graphql/mutations/mark_post_as_solution.rb on lines 2..21

            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 49.

            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

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

              class DeleteCourseAuthor < GraphQL::Schema::Mutation
                argument :id, ID, required: true
            
                description "Delete a course author"
            
            
            Severity: Major
            Found in app/graphql/mutations/delete_course_author.rb and 1 other location - About 1 hr to fix
            app/graphql/mutations/initiate_account_deletion.rb on lines 2..21

            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 49.

            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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              class DeleteCertificate < GraphQL::Schema::Mutation
                argument :id, ID, required: true
            
                description "Delete an un-issued certificate"
            
            
            Severity: Major
            Found in app/graphql/mutations/delete_certificate.rb and 2 other locations - About 1 hr to fix
            app/graphql/mutations/mark_post_as_solution.rb on lines 2..21
            app/graphql/mutations/unmark_post_as_solution.rb on lines 2..21

            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 49.

            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

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

              class InitiateAccountDeletion < GraphQL::Schema::Mutation
                argument :email, String, required: true
            
                description "Delete user account"
            
            
            Severity: Major
            Found in app/graphql/mutations/initiate_account_deletion.rb and 1 other location - About 1 hr to fix
            app/graphql/mutations/delete_course_author.rb on lines 2..21

            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 49.

            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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              class MarkPostAsSolution < GraphQL::Schema::Mutation
                argument :id, ID, required: true
            
                description "Mark a community post as a solution"
            
            
            Severity: Major
            Found in app/graphql/mutations/mark_post_as_solution.rb and 2 other locations - About 1 hr to fix
            app/graphql/mutations/delete_certificate.rb on lines 2..21
            app/graphql/mutations/unmark_post_as_solution.rb on lines 2..21

            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 49.

            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 create_submission has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def create_submission
                submission =
                  TimelineEvent.transaction do
                    target
                      .timeline_events
            Severity: Minor
            Found in app/queries/create_quiz_submission_mutator.rb - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language