Showing 64 of 226 total issues
Function updateService
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports.updateService = (req, res) => {
if (!req.user) {
return res.status(401).json({ message: 'You must be logged in to create a new service provider.' });
}
Function createImages
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
function createImages(uri, logo, images) {
var isIE = false;
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
- 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 seedAccomm
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function seedAccomm(numToGen) {
for (let i = 0; i < numToGen; i += 1) {
const randNum = randInt(0, SUBURBS.length);
const address = {
Function updateAmenities
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 }, {
Function geoloc
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function geoloc()
{
const oldLocValue = document.getElementById('location').value;
document.getElementById('location').value = 'Finding your location ...';
Function bedsAvailable
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports.bedsAvailable = (req, res) => {
if (!req.user) {
res.status(401).json({ message: 'You are not authorised to view this page.' });
return;
}
Function showLocation
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports.showLocation = (req, res) => {
Service.findOne(
{ uri: req.params.serviceUri },
'name description address amenities houseRules about img logo hours thankyouMessage stayLength',
).exec().then((service) => {
Function sendUploadToFirebase
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function sendUploadToFirebase(req, res, next) {
if (!req.file) {
return next();
}
Function seedUsers
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function seedUsers() {
for (let i = 0; i < NUM_USERS; i += 1) {
const year = Math.floor(2003 - randInt(0, 10)); // 15 to 25 y.o. as of 2018
const month = randInt(1, 12);
const day = randInt(1, 30);
Function updateRequests
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports.updateRequests = (req, res) => {
if (!req.user) {
res.status(401).json({ message: 'You are not authorised to view this page.' });
return;
}
Consider simplifying this complex logical expression. Open
Open
if (fname > 0 && lname > 0 && email > 0 && pass.length > 0 && con == pass && dob && gen > 0 && bool) $('#Reg').prop('disabled', false);else $('#Reg').prop('disabled', true);
Consider simplifying this complex logical expression. Open
Open
if (!req.body.fName
|| !req.body.lName
|| !req.body.email
|| !req.body.pwd
|| !req.body.day
Consider simplifying this complex logical expression. Open
Open
if (fname > 0 && lname > 0 && email > 0 && pass.length > 0 && con == pass && dob && gen > 0 && bool)
$('#Reg').prop('disabled', false);
else
$('#Reg').prop('disabled', true);
Function genOpeningHours
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function genOpeningHours() {
const startHours = choose(START_HOURS);
const endHours = choose(END_HOURS);
return {
mon: {
Function uploadImage
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports.uploadImage = (req, res) => {
if (req.file && req.file.storageObject) {
// Get the corresponding Service from the serviceUri and push the image
// reference to the list of images
Service.findOneAndUpdate(
Function geoloc
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function geoloc() {
var oldLocValue = document.getElementById('location').value;
document.getElementById('location').value = 'Finding your location ...';
if (!navigator.geolocation) {
Function uploadLogo
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports.uploadLogo = (req, res) => {
if (req.file && req.file.storageObject) {
// Get the corresponding Service from the serviceUri and update the logo reference
Service.findOneAndUpdate(
{ uri: req.params.serviceUri },
Function getImagesForService
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getImagesForService(service, serviceUri) {
return new Promise((resolve, reject) => {
let metadataCount = 0;
let listCount = 0;
const imageDict = [];
Function addPagination
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function addPagination(name, services) {
var numSegments = 1;
var numAdded = 0;
for (var i = 0; i < services.length; i++) {
Function dashboardClosedRequests
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports.dashboardClosedRequests = (req, res) => {
if (!req.user) {
res.status(401).json({ message: 'You are not authorised to view this page.' });
return;
}