pupilfirst/pupilfirst

View on GitHub

Showing 226 of 226 total issues

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

      primary: {
        50: 'rgb(var(--color-primary-50) / <alpha-value>)',
        100: 'rgb(var(--color-primary-100) / <alpha-value>)',
        200: 'rgb(var(--color-primary-200) / <alpha-value>)',
        300: 'rgb(var(--color-primary-300) / <alpha-value>)',
Severity: Major
Found in tailwind.config.js and 7 other locations - About 1 hr to fix
tailwind.config.js on lines 18..30
tailwind.config.js on lines 31..43
tailwind.config.js on lines 44..56
tailwind.config.js on lines 57..69
tailwind.config.js on lines 70..82
tailwind.config.js on lines 96..108
tailwind.config.js on lines 109..121

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

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

      yellow: {
        50: 'rgb(var(--color-yellow-50) / <alpha-value>)',
        100: 'rgb(var(--color-yellow-100) / <alpha-value>)',
        200: 'rgb(var(--color-yellow-200) / <alpha-value>)',
        300: 'rgb(var(--color-yellow-300) / <alpha-value>)',
Severity: Major
Found in tailwind.config.js and 7 other locations - About 1 hr to fix
tailwind.config.js on lines 18..30
tailwind.config.js on lines 44..56
tailwind.config.js on lines 57..69
tailwind.config.js on lines 70..82
tailwind.config.js on lines 83..95
tailwind.config.js on lines 96..108
tailwind.config.js on lines 109..121

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

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

      focusColor: {
        50: 'rgb(var(--color-focusColor-50) / <alpha-value>)',
        100: 'rgb(var(--color-focusColor-100) / <alpha-value>)',
        200: 'rgb(var(--color-focusColor-200) / <alpha-value>)',
        300: 'rgb(var(--color-focusColor-300) / <alpha-value>)',
Severity: Major
Found in tailwind.config.js and 7 other locations - About 1 hr to fix
tailwind.config.js on lines 18..30
tailwind.config.js on lines 31..43
tailwind.config.js on lines 44..56
tailwind.config.js on lines 57..69
tailwind.config.js on lines 70..82
tailwind.config.js on lines 83..95
tailwind.config.js on lines 96..108

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

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

      orange: {
        50: 'rgb(var(--color-orange-50) / <alpha-value>)',
        100: 'rgb(var(--color-orange-100) / <alpha-value>)',
        200: 'rgb(var(--color-orange-200) / <alpha-value>)',
        300: 'rgb(var(--color-orange-300) / <alpha-value>)',
Severity: Major
Found in tailwind.config.js and 7 other locations - About 1 hr to fix
tailwind.config.js on lines 18..30
tailwind.config.js on lines 31..43
tailwind.config.js on lines 57..69
tailwind.config.js on lines 70..82
tailwind.config.js on lines 83..95
tailwind.config.js on lines 96..108
tailwind.config.js on lines 109..121

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

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

      blue: {
        50: 'rgb(var(--color-blue-50) / <alpha-value>)',
        100: 'rgb(var(--color-blue-100) / <alpha-value>)',
        200: 'rgb(var(--color-blue-200) / <alpha-value>)',
        300: 'rgb(var(--color-blue-300) / <alpha-value>)',
Severity: Major
Found in tailwind.config.js and 7 other locations - About 1 hr to fix
tailwind.config.js on lines 18..30
tailwind.config.js on lines 31..43
tailwind.config.js on lines 44..56
tailwind.config.js on lines 70..82
tailwind.config.js on lines 83..95
tailwind.config.js on lines 96..108
tailwind.config.js on lines 109..121

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

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

    def create_branch(re_run)
      # Create a branch with the name submission-<student_id>
      branch_name_suffix = re_run ? "-#{Time.now.to_i}" : ""
      branch_name = "submission-#{@submission.id}#{branch_name_suffix}"
      repo_name = @submission.students.first.github_repository
Severity: Minor
Found in app/services/github/add_submission_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 execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def execute
      unless (
               target.visibility != Target::VISIBILITY_ARCHIVED &&
                 @assignment.milestone
             )
Severity: Minor
Found in app/services/schools/milestone_sort_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 execute has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def execute(re_run: false)
      unless github_configuration.configured? &&
               @submission.target.action_config.present?
        return
      end
Severity: Minor
Found in app/services/github/add_submission_service.rb - About 1 hr to fix

    Method sign_in_at_oauth_origin has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def sign_in_at_oauth_origin
          if user.present?
            user.regenerate_login_token
    
            encrypted_token =
    Severity: Minor
    Found in app/controllers/users/omniauth_callbacks_controller.rb - About 1 hr to fix

      Method courses has 30 lines of code (exceeds 25 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 1 hr to fix

        Method average_grades has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def average_grades
              @average_grades ||=
                begin
                  averaged =
                    TimelineEventGrade
        Severity: Minor
        Found in app/presenters/organisations/student_presenter.rb - About 1 hr to fix

          Method validate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def validate(_object, context, value)
                target = Target.find_by(id: value[:target_id])
                assignment = target.assignments.not_archived.first
                course = target.course
                student =
          Severity: Minor
          Found in app/graphql/concerns/validate_student_submission.rb - About 1 hr to fix

            Method courses has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def courses
                  @courses ||=
                    begin
                      if current_school_admin.present?
                        current_school
            Severity: Minor
            Found in app/presenters/users/dashboard_presenter.rb - About 1 hr to fix

              Method targets has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def targets(role: nil)
                  @targets ||=
                    begin
                      scope =
                        course.targets.live.includes(
              Severity: Minor
              Found in app/services/concerns/course_exportable.rb - About 1 hr to fix

                Method applicable_submissions has 29 lines of code (exceeds 25 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 1 hr to fix

                  Method create_quiz has 29 lines of code (exceeds 25 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 1 hr to fix

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

                      def prepare_courses
                        cohorts = @organisation.cohorts.includes(:course).uniq
                    
                        courses =
                          cohorts.each_with_object({}) do |cohort, courses|
                    Severity: Minor
                    Found in app/controllers/organisations_controller.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/queue_submission_report.rb - About 1 hr to fix

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

                            def create_video_resource(size, name, description)
                              data = {
                                upload: {
                                  approach: 'tus',
                                  size: size
                        Severity: Minor
                        Found in app/services/vimeo/api_service.rb - About 1 hr to fix

                          Function captureUnhandledRejections has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                captureUnhandledRejections: function (r, e, o) {
                                  if (r) {
                                    "function" == typeof r._rollbarURH &&
                                      r._rollbarURH.belongsToShim &&
                                      r.removeEventListener("unhandledrejection", r._rollbarURH);
                          Severity: Minor
                          Found in app/frontend/shared/utils/rollbar.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language