Showing 64 of 226 total issues
Function dashboardOpenRequests
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.dashboardOpenRequests = (req, res) => {
if (!req.user) {
res.status(401).json({ message: 'You are not authorised to view this page.' });
return;
}
Function deleteImageFromService
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function deleteImageFromService(service, serviceUri, index) {
return new Promise((resolve, reject) => {
// Delete the image specified by 'index' from Firebase
bucket.file(service.img[index]).delete().then(() => {
// After deleting the image from Firebase, delete the image from MongoDB
Function index
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.index = (req, res) => {
// https://caolan.github.io/async/
async.parallel(
{
crisis: (callback) => { findService(callback, 'crisis'); },
Function submitPhoneNumber
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function submitPhoneNumber (form)
{
localStorage.number = form.elements.number.value;
localStorage.email = form.elements.email.value;
Array.from(document.forms).forEach(function(f) {
Function register
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports.register = (req, res, next) => {
if (!req.body.fName
|| !req.body.lName
|| !req.body.email
|| !req.body.pwd
- 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 updateAmenities
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports.updateAmenities = (req, res) => {
const amenity = findAmenityToUpdate(req.body.id, req.body.checkedState);
if (amenity) {
if (req.body.checkedState === 'true') {
Service.findOneAndUpdate({ uri: req.params.serviceUri }, {
- 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 addPagination
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function addPagination(name, services) {
var numSegments = 1;
var numAdded = 0;
for (var i = 0; i < services.length; i++) {
- 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 addPagination
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function addPagination(name, services) {
var numSegments = 1;
var numAdded = 0;
for (var i = 0; i < services.length; i++) {
- 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 notification
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports.notification = (number, email, message, subject, res, options) => {
if (email !== undefined) {
sendEmail(email, subject, message, res);
}
- 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
if (err) console.log(err);
Avoid too many return
statements within this function. Open
return {
label: 'SMOKING',
name: 'SMOKE',
icon: 'smoking_rooms',
};
Avoid too many return
statements within this function. Open
return {
label: 'KITCHEN',
name: 'KITCHEN',
icon: 'local_dining',
};
Avoid too many return
statements within this function. Open
return {
label: 'CURFEW',
name: 'CURFEW',
icon: 'schedule',
};
Avoid too many return
statements within this function. Open
return {
label: 'OUTDOOR/GARDEN',
name: 'OUTDOOR',
icon: 'local_florist',
};
Avoid too many return
statements within this function. Open
return {
label: 'GAMES/CONSOLE',
name: 'GAMES',
icon: 'videogame_asset',
};
Avoid too many return
statements within this function. Open
return {
label: 'STUDY',
name: 'STUDY',
icon: 'local_library',
};
Avoid too many return
statements within this function. Open
return {
label: 'BATHROOM SHARED',
name: 'BATHSHARED',
icon: 'wc',
};
Avoid too many return
statements within this function. Open
return {
label: 'AIR-CONDITIONING',
name: 'AIRCON',
icon: 'ac_unit',
};
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return {
label: 'PHONE',
name: 'PHONE',
icon: 'phone',
};