cvut/fittable

View on GitHub
src/callbacks/sirius.js

Summary

Maintainability
D
2 days
Test Coverage

Function dataCallback has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

function dataCallback ({calendarType, dateFrom, dateTo, calendarId}, callback) {
  // FIXME: until `me` is a valid shortcut on Sirius
  if (calendarId === 'me' && calendarType === 'people') {
    calendarId = username
  }
Severity: Minor
Found in src/callbacks/sirius.js - About 1 day 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 requestHandler has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function requestHandler (request) {
    if (request.readyState === XMLHttpRequest.DONE) {
      if (request.status === 200) {
        // Request successful
        const ajaxresult = JSON.parse(request.responseText)
Severity: Major
Found in src/callbacks/sirius.js - About 3 hrs to fix

    Function data has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            const data = responseEvents.map(event => {
              // And add new event to array
              const newEvent = {
                id: event.id,
                name: event.name,
    Severity: Minor
    Found in src/callbacks/sirius.js - About 1 hr to fix

      Function fetchUserCallback has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      function fetchUserCallback (cb) {
        function requestHandler (request) {
          if (request.readyState === XMLHttpRequest.DONE) {
            if (request.status === 200) {
              // Request successful
      Severity: Minor
      Found in src/callbacks/sirius.js - 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

      Avoid deeply nested control flow statements.
      Open

                  for (let i = 0; i < ajaxresult.linked.schedule_exceptions.length; i++) {
                    // Add exceptions link full name
                    linknames.exceptions.push({
                      id: ajaxresult.linked.schedule_exceptions[i].id,
                      type: ajaxresult.linked.schedule_exceptions[i].exception_type,
      Severity: Major
      Found in src/callbacks/sirius.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    for (let i = 0; i < ajaxresult.linked.teachers.length; i++) {
                      // Add teacher link full name
                      linknames.teachers.push({
                        id: ajaxresult.linked.teachers[i].id,
                        name: {
        Severity: Major
        Found in src/callbacks/sirius.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      for (let i = 0; i < ajaxresult.linked.courses.length; i++) {
                        // Add course link full name
                        linknames.courses.push({
                          id: ajaxresult.linked.courses[i].id,
                          name: {
          Severity: Major
          Found in src/callbacks/sirius.js - About 45 mins to fix

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

            function semesterDataCallback (callback) {
              function requestHandler (request) {
                if (request.readyState === XMLHttpRequest.DONE) {
            
                  // Request successful
            Severity: Minor
            Found in src/callbacks/sirius.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 searchCallback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function searchCallback (query, callback) {
              function requestHandler (request) {
                if (request.readyState === XMLHttpRequest.DONE) {
                  if (request.status === 200) {
                    // Request successful
            Severity: Minor
            Found in src/callbacks/sirius.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