Showing 54 of 137 total issues
Function validateSearchQueries
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const validateSearchQueries = (req, res, next) => {
const { query } = req;
const allKeys = Object.keys(query);
if (allKeys.length === 0) {
return Response.errorMessage(req, res, 'Please provide a search query key parameter', 400);
Function getUserRequests
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async getUserRequests(req) {
const requestsUsersObject = {
where: { userId: req.user.id },
order: [
['updatedAt', 'DESC'],
Function up
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
up: (queryInterface, Sequelize) => {
return queryInterface.bulkInsert('rooms',[
{
accommodationId: 1,
name: 'maisai mara',
Function up
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('ratings', {
id: {
allowNull: false,
autoIncrement: true,
Function up
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('accommodationImages', {
id: {
allowNull: false,
autoIncrement: true,
Function newBookingNotification
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async newBookingNotification(req) {
const userQueryObject = {
where: { id: req.user.id }
};
const travelAdminQueryObject = {
Function associate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
tripRequests.associate = function(models) {
tripRequests.belongsTo(
models.users,
{foreignKey: 'userId'},
{ onDelete: 'cascade'},
Function up
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) => {
return Promise.all([
queryInterface.addColumn('notifications', 'commentsId', {
type: Sequelize.INTEGER,
Consider simplifying this complex logical expression. Open
if (key === 'originId'
|| key === 'destinationId'
|| key === 'startDate'
|| key === 'returnDate'
|| key === 'firstName'
Function findMostTraveledDestination
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static async findMostTraveledDestination() {
const destinationObj = {
attributes: ['destinationId'], raw: true
};
const getAllDestinations = await CommonQueries.findAll(trips, destinationObj);
- 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
Consider simplifying this complex logical expression. Open
if (query.originId === ''
|| query.destinationId === ''
|| query.startDate === ''
|| query.returnDate === ''
|| query.firstName === ''
Function isLoggedViaSocialLogin
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const isLoggedViaSocialLogin = async (req, res, next) => {
const { email } = req.body;
if (email) {
const findSignupType = await users.findOne({ where: { email } });
if (findSignupType) {
- 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 validateSearchQueries
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const validateSearchQueries = (req, res, next) => {
const { query } = req;
const allKeys = Object.keys(query);
if (allKeys.length === 0) {
return Response.errorMessage(req, res, 'Please provide a search query key parameter', 400);
- 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 operateAcceptOrReject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const operateAcceptOrReject = async (req, res, next) => {
const { id } = req.user;
const { tripRequestId } = req.params;
const users = await userProfiles.findAll({
where: { managerId: id }
- 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"