pupilfirst/pupilfirst

View on GitHub

Showing 226 of 226 total issues

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

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

    def query_authorized?
      return false if current_user.blank?

      return false if course&.school != current_school

Severity: Major
Found in app/graphql/mutations/create_submission_comment.rb and 3 other locations - About 45 mins to fix
app/graphql/mutations/create_moderation_report.rb on lines 33..44
app/graphql/mutations/create_reaction.rb on lines 23..34
app/queries/discussion_submissions_resolver.rb on lines 27..38

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

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 = sanitize_title(title.presence || target.title).truncate(120)
    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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def execute
      submission =
        TimelineEvent.transaction do
          timeline_event_params =
            (
Severity: Minor
Found in app/services/timeline_events/create_service.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

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

    def query_authorized?
      return false if current_user.blank?

      return false if course&.school != current_school

Severity: Major
Found in app/graphql/mutations/create_moderation_report.rb and 3 other locations - About 45 mins to fix
app/graphql/mutations/create_reaction.rb on lines 23..34
app/graphql/mutations/create_submission_comment.rb on lines 19..30
app/queries/discussion_submissions_resolver.rb on lines 27..38

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

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

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

  class DeletePostLike < GraphQL::Schema::Mutation
    argument :post_id, ID, required: true

    description "Delete a like for some post"

Severity: Major
Found in app/graphql/mutations/delete_post_like.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_account.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 DeleteTopicSubscription < GraphQL::Schema::Mutation
    argument :topic_id, ID, required: true

    description "Unsubscribe from a topic"

Severity: Major
Found in app/graphql/mutations/delete_topic_subscription.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/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

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

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

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

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

  def authorized?
    return false if current_user.blank?

    return false if course&.school != current_school

Severity: Major
Found in app/queries/discussion_submissions_resolver.rb and 3 other locations - About 45 mins to fix
app/graphql/mutations/create_moderation_report.rb on lines 33..44
app/graphql/mutations/create_reaction.rb on lines 23..34
app/graphql/mutations/create_submission_comment.rb on lines 19..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 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

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

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

    def query_authorized?
      return false if current_user.blank?

      return false if course&.school != current_school

Severity: Major
Found in app/graphql/mutations/create_reaction.rb and 3 other locations - About 45 mins to fix
app/graphql/mutations/create_moderation_report.rb on lines 33..44
app/graphql/mutations/create_submission_comment.rb on lines 19..30
app/queries/discussion_submissions_resolver.rb on lines 27..38

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 DeleteSchoolAdmin < GraphQL::Schema::Mutation
    argument :id, ID, required: true

    description "Delete a school admin"

Severity: Major
Found in app/graphql/mutations/delete_school_admin.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_account.rb on lines 2..20
app/graphql/mutations/delete_post_like.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 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

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

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

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

  class CreatePostLike < GraphQL::Schema::Mutation
    argument :post_id, ID, required: true

    description "Add a like for the post"

Severity: Major
Found in app/graphql/mutations/create_post_like.rb and 3 other locations - About 45 mins to fix
app/graphql/mutations/delete_account.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

Severity
Category
Status
Source
Language