pupilfirst/pupilfirst

View on GitHub

Showing 226 of 226 total issues

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

  class DeleteAccount < GraphQL::Schema::Mutation
    argument :token, String, required: true

    description "Delete user account permanently"

Severity: Major
Found in app/graphql/mutations/delete_account.rb and 3 other locations - About 45 mins to fix
app/graphql/mutations/create_post_like.rb on lines 2..20
app/graphql/mutations/delete_post_like.rb on lines 2..20
app/graphql/mutations/delete_school_admin.rb on lines 2..20

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

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 4 locations. Consider refactoring.
Open

  class MarkNotification < GraphQL::Schema::Mutation
    argument :notification_id, ID, required: true

    description "Mark a notification as having been read"

Severity: Major
Found in app/graphql/mutations/mark_notification.rb and 3 other locations - About 45 mins to fix
app/graphql/mutations/delete_content_block.rb on lines 2..17
app/graphql/mutations/delete_topic_category.rb on lines 2..17
app/graphql/mutations/delete_topic_subscription.rb on lines 2..17

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

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 4 locations. Consider refactoring.
Open

  class DeleteContentBlock < GraphQL::Schema::Mutation
    argument :id, ID, required: true

    description "Deletes a target content block."

Severity: Major
Found in app/graphql/mutations/delete_content_block.rb and 3 other locations - About 45 mins to fix
app/graphql/mutations/delete_topic_category.rb on lines 2..17
app/graphql/mutations/delete_topic_subscription.rb on lines 2..17
app/graphql/mutations/mark_notification.rb on lines 2..17

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

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

      if @form.validate(params[:faculty].merge(school_id: current_school.id))
        faculty = @form.save
        render json: {
                 id: faculty.id.to_s,
                 image_url: faculty.user.image_or_avatar_url,
Severity: Minor
Found in app/controllers/schools/faculty_controller.rb and 1 other location - About 45 mins to fix
app/controllers/schools/faculty_controller.rb on lines 14..23

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

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

      if @form.validate(params[:faculty].merge(school_id: current_school.id))
        faculty = @form.save
        render json: {
                 id: faculty.id.to_s,
                 image_url: faculty.user.image_or_avatar_url,
Severity: Minor
Found in app/controllers/schools/faculty_controller.rb and 1 other location - About 45 mins to fix
app/controllers/schools/faculty_controller.rb on lines 30..39

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

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

Consider simplifying this complex logical expression.
Open

      if checklist.respond_to?(:all?) &&
           checklist.all? { |item|
             item["title"].is_a?(String) &&
               item["kind"].in?(Assignment.valid_checklist_kind_types) &&
               item["status"] == TimelineEvent::CHECKLIST_STATUS_NO_ANSWER &&
Severity: Major
Found in app/graphql/concerns/validate_student_submission.rb - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        if review_checklist.respond_to?(:all?) &&
             review_checklist.all? { |item|
               valid_title?(item["title"]) && item["result"].respond_to?(:all?) &&
                 item["result"].all? do |result|
                   valid_title?(result["title"]) &&
    Severity: Major
    Found in app/queries/update_review_checklist_mutator.rb - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if @checklist.respond_to?(:all?) &&
                   @checklist.all? { |item|
                     item["title"].is_a?(String) &&
                       item["kind"].in?(Assignment.valid_checklist_kind_types) &&
                       item["status"].in?(
      Severity: Major
      Found in app/graphql/mutations/create_grading.rb - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

              if (e.hasOwnProperty && e.hasOwnProperty("addEventListener")) {
                for (var n = e.addEventListener; n._rollbarOldAdd && n.belongsToShim; )
                  n = n._rollbarOldAdd;
                var t = function (e, o, t) {
                  n.call(this, e, r.wrap(o), t);
        Severity: Major
        Found in app/frontend/shared/utils/rollbar.js - About 40 mins to fix

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

              class Github
                attr_accessor :access_token, :organization_id, :default_team_id
          
                def initialize(school)
                  @github = school.configuration["github"].presence || {}
          Severity: Minor
          Found in app/models/schools/configuration.rb and 1 other location - About 40 mins to fix
          app/models/schools/configuration.rb on lines 18..30

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

          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 user_names
                BatchLoader::GraphQL
                  .for(object.id)
                  .batch do |submission_ids, loader|
                    TimelineEvent
          Severity: Minor
          Found in app/graphql/types/submission_info_type.rb and 1 other location - About 40 mins to fix
          app/graphql/types/discussion_submission_type.rb on lines 45..58

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

          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 user_names
                BatchLoader::GraphQL
                  .for(object.id)
                  .batch do |submission_ids, loader|
                    TimelineEvent
          Severity: Minor
          Found in app/graphql/types/discussion_submission_type.rb and 1 other location - About 40 mins to fix
          app/graphql/types/submission_info_type.rb on lines 38..51

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

          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 EmailSenderSignature
                attr_accessor :name, :email, :confirmed_at
          
                def initialize(school)
                  @ess = school.configuration["email_sender_signature"].presence || {}
          Severity: Minor
          Found in app/models/schools/configuration.rb and 1 other location - About 40 mins to fix
          app/models/schools/configuration.rb on lines 47..60

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

          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

          Function loadFull has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              (i.prototype.loadFull = function (r, e, o, n, t) {
          Severity: Minor
          Found in app/frontend/shared/utils/rollbar.js - About 35 mins to fix

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

                def personal_coaches
                  BatchLoader::GraphQL
                    .for(object.id)
                    .batch(default_value: []) do |student_ids, loader|
                      FacultyStudentEnrollment
            Severity: Minor
            Found in app/graphql/types/student_type.rb and 1 other location - About 35 mins to fix
            app/graphql/types/course_export_type.rb on lines 16..26

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

            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 cohorts
                  BatchLoader::GraphQL
                    .for(object.id)
                    .batch(default_value: []) do |course_export_ids, loader|
                      CourseExportsCohort
            Severity: Minor
            Found in app/graphql/types/course_export_type.rb and 1 other location - About 35 mins to fix
            app/graphql/types/student_type.rb on lines 78..88

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

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

                def oauth_callback
                  @email = email_from_auth_hash
            
                  if oauth_origin.present? && oauth_origin[:session_id]
                    if oauth_origin[:link_data].present?
            Severity: Minor
            Found in app/controllers/users/omniauth_callbacks_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

            Method assign has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def assign(faculty)
                  if faculty.school != @course.school
                    raise 'Faculty must in same school as course'
                  end
            
            
            Severity: Minor
            Found in app/services/cohorts/manage_reviewer_service.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

            Method first_five_topics_from_cache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def first_five_topics_from_cache(update_type, community_ids)
                topics = []
            
                @topic_details_cache[update_type].each do |topic|
                  next unless topic[:community_id].in?(community_ids)
            Severity: Minor
            Found in app/services/daily_digest_service.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

            Method target_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def target_type(target)
                assignment = target.assignments.not_archived.first
                if assignment
                  if assignment.evaluation_criteria.present?
                    "Graded"
            Severity: Minor
            Found in app/services/concerns/course_exportable.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

            Severity
            Category
            Status
            Source
            Language