andela/team-odd-bn-backend

View on GitHub

Showing 54 of 137 total issues

Function createAccomodation has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static async createAccomodation(req) {
    const { id: userId } = req.user;
    const {
      name,
      cityId,
Severity: Minor
Found in src/services/AccommodationService.js - About 1 hr to fix

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

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

      Function associate has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        users.associate = function(models) {
          users.hasMany(
            models.tripRequests,
            { targetKey: 'userId' },
            { onDelete: 'cascade' },
      Severity: Minor
      Found in src/database/models/user.js - About 1 hr to fix

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

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

          Function associate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            accommodations.associate = function(models) {
              accommodations.hasMany(models.accommodationImages,
                {targetKey: 'accommodationId',
                sourceKey:'id',
                 as:'imagesAccommodation'},
          Severity: Minor
          Found in src/database/models/accommodations.js - About 1 hr to fix

            Function operateAcceptOrReject has 39 lines of code (exceeds 25 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 }
            Severity: Minor
            Found in src/middlewares/approveOrReject.js - About 1 hr to fix

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

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

                Function createNewTrip has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static async createNewTrip(req, res, tripTypeId) {
                    try {
                      if (tripTypeId === 1) {
                        req.body.returnDate = null;
                      }
                Severity: Minor
                Found in src/helpers/TripHelper.js - About 1 hr to fix

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

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

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

                      up: (queryInterface, Sequelize) => {
                        return queryInterface.bulkInsert('roles', [
                          {
                            type: 'super admin',
                            createdAt: new Date(),
                    Severity: Minor
                    Found in src/database/seeders/20191103164828-roles.js - About 1 hr to fix

                      Function socialCallBack has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        static async socialCallBack(accessToken, refreshToken, profile, signupTypeParameter, done) {
                          try {
                            const data = {
                              id: profile.id,
                              firstName: profile.name.givenName,
                      Severity: Minor
                      Found in src/helpers/UserHelper.js - About 1 hr to fix

                        Function editTripRequestToUser has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          static async editTripRequestToUser(req) {
                            const itinerary = req.body.itinerary ? req.body.itinerary : [req.body];
                        
                            const findAllObjQuery = {
                              attributes: ['id'],
                        Severity: Minor
                        Found in src/services/TripService.js - About 1 hr to fix

                          Function addCommentNotification has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            static async addCommentNotification(req) {
                              const { user, params } = req;
                              const tripRequestInfoObject = {
                                where: {
                                  id: params.tripRequestId
                          Severity: Minor
                          Found in src/services/NotificationService.js - About 1 hr to fix

                            Function getSingleTrip has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              static async getSingleTrip(tripRequestId) {
                                const singleTripObject = {
                                  where: { id: tripRequestId },
                                  include: [
                                    {
                            Severity: Minor
                            Found in src/services/TripService.js - About 1 hr to fix

                              Function managerRequests has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  let managerRequests = managerUsers.map(async user => {
                                    const managerRequestsObj = {
                                      where: { userId: user.userId, statusId: 1 },
                                      attributes: ['id', 'updatedAt', 'createdAt'],
                                      order: [
                              Severity: Minor
                              Found in src/services/TripService.js - About 1 hr to fix

                                Function bookAccommodationService has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  static async bookAccommodationService(req, res) {
                                    try {
                                      const accommodationObj = {
                                        raw: true
                                      };
                                Severity: Minor
                                Found in src/services/BookingService.js - About 1 hr to fix

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

                                  module.exports = (sequelize, DataTypes) => {
                                    const tripRequests = sequelize.define('tripRequests', {
                                      userId: DataTypes.INTEGER,
                                      tripTypeId: DataTypes.INTEGER,
                                      statusId: DataTypes.STRING,
                                  Severity: Minor
                                  Found in src/database/models/tripRequests.js - About 1 hr to fix

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

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

                                      Function checkForSimilarRequests has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        static async checkForSimilarRequests(req, res, next) {
                                          const itinerary = req.body.itinerary ? req.body.itinerary : [req.body];
                                      
                                          const allCitiess = await trips.findAll({
                                            include: [{
                                      Severity: Minor
                                      Found in src/middlewares/ValidateTrip.js - About 1 hr to fix

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

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