andela/team-odd-bn-backend

View on GitHub

Showing 54 of 137 total issues

Validate has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class Validate {
  /**
    * Validate input
    * @static
    * @returns {object} errors
Severity: Minor
Found in src/middlewares/Validate.js - About 3 hrs to fix

    Function getUserTrips has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static async getUserTrips(req) {
        const { Op } = Sequelize;
        const { from, to, user } = req.query;
        const { id, roleId } = req.user;
        let userTripsObject, requests;
    Severity: Major
    Found in src/services/TripService.js - About 2 hrs to fix

      Function verifyEmailTemplate has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static verifyEmailTemplate(req, user) {
          const token = AuthenticateToken.signToken(user);
          const appUrl = `${req.protocol}://${req.headers.host}/api/v1/auth/verify-email/${user.id}/${token}`;
          const resendUrl = `${req.protocol}://${req.headers.host}/api/v1/auth/${user.id}/resend-email`;
          return {
      Severity: Major
      Found in src/helpers/EmailTemplates.js - About 2 hrs to fix

        Function addAccommodationLike has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          static async addAccommodationLike(req) {
            let setObject, displayMessage;
            let { like } = req.query;
            const { accommodationId } = req.params;
            const { id } = req.user;
        Severity: Minor
        Found in src/services/AccommodationService.js - About 2 hrs 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 getUserBookingReqService has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static async getUserBookingReqService(req) {
            const { bookingId: id } = req.params;
            const managerObj = {
              where: { managerId: req.user.id }
            };
        Severity: Major
        Found in src/services/BookingService.js - About 2 hrs to fix

          Function exports has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = (sequelize, DataTypes) => {
            const users = sequelize.define(
              'users',
              {
                firstName: DataTypes.STRING,
          Severity: Major
          Found in src/database/models/user.js - About 2 hrs to fix

            Function forgotPasswordTemplate has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static forgotPasswordTemplate(req, user) {
                const token = AuthenticateToken.signToken(user.dataValues);
            
                const appUrl = `${req.protocol}://${req.headers.host}`;
                return {
            Severity: Major
            Found in src/helpers/EmailTemplates.js - About 2 hrs to fix

              Function up has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                up: (queryInterface, Sequelize) => {
                  return queryInterface.bulkInsert('accommodations', [
                    {
                      name: 'serena hotel',
                      cityId: 3,
              Severity: Major
              Found in src/database/seeders/20191105144530-accommodations.js - About 2 hrs to fix

                Function up has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  up: (queryInterface, Sequelize) => {
                    return queryInterface.createTable('notifications', {
                      id: {
                        allowNull: false,
                        autoIncrement: true,
                Severity: Major
                Found in src/database/migrations/20191203223954-create-notifications.js - About 2 hrs to fix

                  File TripService.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import Sequelize, { Promise } from 'sequelize';
                  import {
                    tripRequests, trips, userProfile, users, accommodations, cities, tripTypes, status
                  } from '../database/models';
                  import TripHelper from '../helpers/TripHelper';
                  Severity: Minor
                  Found in src/services/TripService.js - About 2 hrs to fix

                    Function up has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      up: (queryInterface, Sequelize) => {
                        return queryInterface.createTable('trips', {
                          id: {
                            allowNull: false,
                            autoIncrement: true,
                    Severity: Major
                    Found in src/database/migrations/20191119162259-create-trips.js - About 2 hrs to fix

                      Function updateProfile has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        static async updateProfile(req) {
                          const { id } = req.user;
                          const userObject = {
                            where: {
                              id
                      Severity: Major
                      Found in src/services/UserService.js - About 2 hrs to fix

                        Function up has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          up: (queryInterface, Sequelize) => {
                            return queryInterface.createTable('userProfile', {
                              id: {
                                allowNull: false,
                                autoIncrement: true,
                        Severity: Major
                        Found in src/database/migrations/20191115165558-create-user-profile.js - About 2 hrs to fix

                          Function exports has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          module.exports = (sequelize, DataTypes) => {
                            const accommodations = sequelize.define('accommodations', {
                              userId: DataTypes.INTEGER,
                              name: DataTypes.STRING,
                              userId: DataTypes.INTEGER,
                          Severity: Major
                          Found in src/database/models/accommodations.js - About 2 hrs to fix

                            Function getAccommodations has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              static async getAccommodations(req) {
                                const getAccommodationsQueryObject = req.params.accommodationId
                                  ? {
                                    where: { id: req.params.accommodationId },
                                    include: [{
                            Severity: Minor
                            Found in src/services/AccommodationService.js - About 1 hr to fix

                              Function addAccommodationLike has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                static async addAccommodationLike(req) {
                                  let setObject, displayMessage;
                                  let { like } = req.query;
                                  const { accommodationId } = req.params;
                                  const { id } = req.user;
                              Severity: Minor
                              Found in src/services/AccommodationService.js - About 1 hr to fix

                                Function up has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  up: (queryInterface, Sequelize) => {
                                    return queryInterface.bulkInsert('users', [
                                      {
                                        firstName: 'John',
                                        lastName: 'Doe',
                                Severity: Minor
                                Found in src/database/seeders/20191104145912-users.js - About 1 hr to fix

                                  Function availtripRequestsToManager has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    static async availtripRequestsToManager(id) {
                                      const userObj = {
                                        where: { managerId: id },
                                        attributes: ['userId'],
                                        raw: true
                                  Severity: Minor
                                  Found in src/services/TripService.js - About 1 hr to fix

                                    Function up has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      up: (queryInterface, Sequelize) => {
                                        return queryInterface.createTable('likes', {
                                          id: {
                                            allowNull: false,
                                            autoIncrement: true,
                                    Severity: Minor
                                    Found in src/database/migrations/20191203152322-create-likes.js - About 1 hr to fix

                                      Function up has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        up: (queryInterface, Sequelize) => {
                                          return queryInterface.createTable('tripRequests', {
                                            id: {
                                              allowNull: false,
                                              autoIncrement: true,
                                      Severity: Minor
                                      Found in src/database/migrations/20191119091422-create-tripRequests.js - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language