pupilfirst/pupilfirst

View on GitHub
app/graphql/mutations/create_grading.rb

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%

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

    def grade
      TimelineEvent.transaction do
        if passed?
          evaluation_criteria.each do |criterion|
            TimelineEventGrade.create!(
Severity: Minor
Found in app/graphql/mutations/create_grading.rb - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method 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

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

    There are no issues that match your filters.

    Category
    Status