andela/team-odd-bn-backend

View on GitHub

Showing 137 of 137 total issues

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

    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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    {
                      model: status,
                      where: {
                        ...searchQueryParams.status && {
                          status: {
            Severity: Major
            Found in src/services/commonSearchQueries.js and 1 other location - About 1 hr to fix
            src/services/commonSearchQueries.js on lines 47..57

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 67.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    {
                      model: tripTypes,
                      where: {
                        ...searchQueryParams.tripType && {
                          tripType: {
            Severity: Major
            Found in src/services/commonSearchQueries.js and 1 other location - About 1 hr to fix
            src/services/commonSearchQueries.js on lines 36..46

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 67.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  module.exports = {
                    up: (queryInterface, Sequelize) => {
                      return queryInterface.removeColumn('notifications', 'managerId');
                    },
                  
                  
                  src/database/migrations/20191115165559-modify-user-profile.js on lines 3..15

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 65.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  module.exports = {
                    up: (queryInterface, Sequelize) => {
                      return queryInterface.removeColumn('userProfile', 'isVerified');
                      
                    },
                  src/database/migrations/20191203223955-modify-notifications.js on lines 3..11

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 65.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          static async isRequester(req, res, next) {
                            const dbRoleId = await UserHelper.userRoleType(req, roles);
                            if (dbRoleId !== 7) {
                              return Response.errorMessage(req, res, 'you are not a requester', 403);
                            }
                        Severity: Major
                        Found in src/middlewares/VerifyUserRoles.js and 3 other locations - About 1 hr to fix
                        src/middlewares/VerifyUserRoles.js on lines 41..47
                        src/middlewares/VerifyUserRoles.js on lines 58..64
                        src/middlewares/VerifyUserRoles.js on lines 92..98

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 64.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                                queryInterface.addColumn('notifications', 'commentsId', {
                                  type: Sequelize.INTEGER,
                                  onDelete: 'CASCADE',
                                  onUpdate: 'CASCADE',
                                  allowNull: true,
                        src/database/migrations/20191210102155-add-notification-accomodation-comment.js on lines 16..26

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 64.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          static async isTravelTeamMember(req, res, next) {
                            const dbRoleId = await UserHelper.userRoleType(req, roles);
                            if (dbRoleId !== 5) {
                              return Response.errorMessage(req, res, 'you are not a travel team member', 403);
                            }
                        Severity: Major
                        Found in src/middlewares/VerifyUserRoles.js and 3 other locations - About 1 hr to fix
                        src/middlewares/VerifyUserRoles.js on lines 58..64
                        src/middlewares/VerifyUserRoles.js on lines 75..81
                        src/middlewares/VerifyUserRoles.js on lines 92..98

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 64.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          static async isManager(req, res, next) {
                            const dbRoleId = await UserHelper.userRoleType(req, roles);
                            if (dbRoleId !== 6) {
                              return Response.errorMessage(req, res, 'you are not manager', 403);
                            }
                        Severity: Major
                        Found in src/middlewares/VerifyUserRoles.js and 3 other locations - About 1 hr to fix
                        src/middlewares/VerifyUserRoles.js on lines 41..47
                        src/middlewares/VerifyUserRoles.js on lines 58..64
                        src/middlewares/VerifyUserRoles.js on lines 75..81

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 64.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                                queryInterface.addColumn('notifications', 'accommodationsId', {
                                  type: Sequelize.INTEGER,
                                  onDelete: 'CASCADE',
                                  onUpdate: 'CASCADE',
                                  allowNull: true,
                        src/database/migrations/20191210102155-add-notification-accomodation-comment.js on lines 5..15

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 64.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language