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
}
- Read upRead up
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)
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,
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
- Read upRead up
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,
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: {
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: {
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
- Read upRead up
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
- Read upRead up
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"