ilios/frontend

View on GitHub
packages/ilios-common/addon/models/session.js

Summary

Maintainability
C
1 day
Test Coverage

File session.js has 504 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Model, { hasMany, belongsTo, attr } from '@ember-data/model';
import { DateTime } from 'luxon';
import sortableByPosition from 'ilios-common/utils/sortable-by-position';
import striptags from 'striptags';
import { filter } from 'rsvp';
Severity: Major
Found in packages/ilios-common/addon/models/session.js - About 1 day to fix

    Consider simplifying this complex logical expression.
    Open

        if (
          !this._offeringInstructorsData?.isResolved ||
          !this._offeringInstructorGroupsInstructors?.isResolved ||
          (this.isIndependentLearning && !this._ilmInstructorsData?.isResolved) ||
          (this.isIndependentLearning && !this._ilmSessionInstructorGroupsInstructorsData?.isResolved)
    Severity: Major
    Found in packages/ilios-common/addon/models/session.js - About 40 mins to fix

      Function requiredPublicationIssues has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        get requiredPublicationIssues() {
          const issues = [];
          if (this.isIndependentLearning) {
            if (!this._ilmSession?.dueDate) {
              issues.push('dueDate');
      Severity: Minor
      Found in packages/ilios-common/addon/models/session.js - 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

      Function allInstructors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        get allInstructors() {
          if (
            !this._offeringInstructorsData?.isResolved ||
            !this._offeringInstructorGroupsInstructors?.isResolved ||
            (this.isIndependentLearning && !this._ilmInstructorsData?.isResolved) ||
      Severity: Minor
      Found in packages/ilios-common/addon/models/session.js - About 25 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

      There are no issues that match your filters.

      Category
      Status