radgrad/radgrad2

View on GitHub
app/imports/api/level/LevelProcessor.ts

Summary

Maintainability
D
1 day
Test Coverage

Function getLevelCriteriaStringMarkdown has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

export const getLevelCriteriaStringMarkdown = (level: string): string => {
  if (!(['six', 'five', 'four', 'three', 'two'].includes(level))) {
    throw new Meteor.Error(`${level} is not a valid level`);
  }
  const criteria = Meteor.settings.public.level[level];
Severity: Minor
Found in app/imports/api/level/LevelProcessor.ts - About 3 hrs 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

  } else if (earnedICE.i >= 80 &&
    earnedICE.c >= 80 &&
    earnedICE.e >= 80 &&
    numReviews >= 1 &&
    plannedICE.i >= 100 &&
Severity: Critical
Found in app/imports/api/level/LevelProcessor.ts - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

      if (earnedICE.i >= 100 &&
        earnedICE.c >= 100 &&
        earnedICE.e >= 100 &&
        numReviews >= 6 &&
        plannedICE.i >= 100 &&
    Severity: Critical
    Found in app/imports/api/level/LevelProcessor.ts - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

        } else if (earnedICE.i >= 30 &&
          earnedICE.c >= 36 &&
          earnedICE.e >= 30 &&
          numReviews >= 0 &&
          plannedICE.i >= 100 &&
      Severity: Critical
      Found in app/imports/api/level/LevelProcessor.ts - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

          } else if (earnedICE.i >= Meteor.settings.public.level.two.earnedICE.i &&
            earnedICE.c >= Meteor.settings.public.level.two.earnedICE.c &&
            earnedICE.e >= Meteor.settings.public.level.two.earnedICE.e &&
            numReviews >= Meteor.settings.public.level.two.reviews &&
            plannedICE.i >= Meteor.settings.public.level.two.plannedICE.i &&
        Severity: Major
        Found in app/imports/api/level/LevelProcessor.ts - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

            } else if (earnedICE.i >= Meteor.settings.public.level.three.earnedICE.i &&
              earnedICE.c >= Meteor.settings.public.level.three.earnedICE.c &&
              earnedICE.e >= Meteor.settings.public.level.three.earnedICE.e &&
              numReviews >= Meteor.settings.public.level.three.reviews &&
              plannedICE.i >= Meteor.settings.public.level.three.plannedICE.i &&
          Severity: Major
          Found in app/imports/api/level/LevelProcessor.ts - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

              if (earnedICE.i >= Meteor.settings.public.level.six.earnedICE.i &&
                earnedICE.c >= Meteor.settings.public.level.six.earnedICE.c &&
                earnedICE.e >= Meteor.settings.public.level.six.earnedICE.e &&
                numReviews >= Meteor.settings.public.level.six.reviews &&
                plannedICE.i >= Meteor.settings.public.level.six.plannedICE.i &&
            Severity: Major
            Found in app/imports/api/level/LevelProcessor.ts - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                } else if (earnedICE.i >= Meteor.settings.public.level.five.earnedICE.i &&
                  earnedICE.c >= Meteor.settings.public.level.five.earnedICE.c &&
                  earnedICE.e >= Meteor.settings.public.level.five.earnedICE.e &&
                  numReviews >= Meteor.settings.public.level.five.reviews &&
                  plannedICE.i >= Meteor.settings.public.level.five.plannedICE.i &&
              Severity: Major
              Found in app/imports/api/level/LevelProcessor.ts - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                  } else if (earnedICE.i >= Meteor.settings.public.level.four.earnedICE.i &&
                    earnedICE.c >= Meteor.settings.public.level.four.earnedICE.c &&
                    earnedICE.e >= Meteor.settings.public.level.four.earnedICE.e &&
                    numReviews >= Meteor.settings.public.level.four.reviews &&
                    plannedICE.i >= Meteor.settings.public.level.four.plannedICE.i &&
                Severity: Major
                Found in app/imports/api/level/LevelProcessor.ts - About 1 hr to fix

                  Function defaultCalcLevel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const defaultCalcLevel = (studentID: string): number => {
                    const instances = _.concat(CourseInstances.find({ studentID })
                      .fetch(),
                    OpportunityInstances.find({ studentID })
                      .fetch());
                  Severity: Minor
                  Found in app/imports/api/level/LevelProcessor.ts - 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 testCalcLevel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const testCalcLevel = (studentID: string): number => {
                    const instances = _.concat(CourseInstances.find({ studentID })
                      .fetch(),
                    OpportunityInstances.find({ studentID })
                      .fetch());
                  Severity: Minor
                  Found in app/imports/api/level/LevelProcessor.ts - 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

                  There are no issues that match your filters.

                  Category
                  Status