andela/team-odd-bn-backend

View on GitHub

Showing 137 of 137 total issues

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'],
Severity: Minor
Found in src/services/TripService.js - About 1 hr to fix

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

            {
              model: ratings,
              as: 'ratings',
              include: [{
                model: users,
    Severity: Major
    Found in src/services/AccommodationService.js and 1 other location - About 1 hr to fix
    src/services/AccommodationService.js on lines 287..299

    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 59.

    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

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

            {
              model: ratings,
              as: 'ratings',
              include: [{
                model: users,
    Severity: Major
    Found in src/services/AccommodationService.js and 1 other location - About 1 hr to fix
    src/services/AccommodationService.js on lines 266..278

    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 59.

    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 up has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      up: (queryInterface, Sequelize) => {
        return queryInterface.bulkInsert('rooms',[
          {
            accommodationId: 1,
            name: 'maisai mara',
    Severity: Minor
    Found in src/database/seeders/20191204092003-rooms.js - About 1 hr to fix

      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,
      Severity: Minor
      Found in src/database/migrations/20191203155338-create-ratings.js - About 1 hr to fix

        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 = {
          Severity: Minor
          Found in src/services/NotificationService.js - About 1 hr to fix

            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'},
            Severity: Minor
            Found in src/database/models/tripRequests.js - About 1 hr to fix

              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,

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

                class StatusService {
                  /**
                 * Get all status
                 * @static
                 * @description GET /api/v1/status
                Severity: Major
                Found in src/services/StatusService.js and 1 other location - About 1 hr to fix
                src/services/CitiesServices.js on lines 8..24

                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 55.

                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

                class CitiesService {
                  /**
                 * Get all cities
                 * @static
                 * @description GET /api/v1/all-cities
                Severity: Major
                Found in src/services/CitiesServices.js and 1 other location - About 1 hr to fix
                src/services/StatusService.js on lines 9..25

                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 55.

                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 3 locations. Consider refactoring.
                Open

                  const booking = sequelize.define('booking', {
                    userId: DataTypes.INTEGER,
                    roomId: DataTypes.INTEGER,
                    checkInDate: DataTypes.DATE,
                    checkOutDate: DataTypes.DATE
                Severity: Major
                Found in src/database/models/booking.js and 2 other locations - About 1 hr to fix
                src/database/models/likes.js on lines 3..8
                src/database/models/ratings.js on lines 3..8

                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 55.

                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 3 locations. Consider refactoring.
                Open

                  const likes = sequelize.define('likes', {
                    userId: DataTypes.INTEGER,
                    accommodationId: DataTypes.INTEGER,
                    liked: DataTypes.BOOLEAN,
                    disliked: DataTypes.BOOLEAN
                Severity: Major
                Found in src/database/models/likes.js and 2 other locations - About 1 hr to fix
                src/database/models/booking.js on lines 3..8
                src/database/models/ratings.js on lines 3..8

                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 55.

                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

                Consider simplifying this complex logical expression.
                Open

                    if (key === 'originId'
                    || key === 'destinationId'
                    || key === 'startDate'
                    || key === 'returnDate'
                    || key === 'firstName'
                Severity: Major
                Found in src/middlewares/validateSearchQueries.js - About 1 hr to fix

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

                    const ratings = sequelize.define('ratings', {
                      userId: DataTypes.INTEGER,
                      accommodationId: DataTypes.INTEGER,
                      rating: DataTypes.INTEGER,
                      review: DataTypes.STRING
                  Severity: Major
                  Found in src/database/models/ratings.js and 2 other locations - About 1 hr to fix
                  src/database/models/booking.js on lines 3..8
                  src/database/models/likes.js on lines 3..8

                  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 55.

                  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

                        {
                          firstName: 'mailer',
                          lastName: 'manager',
                          email: 'manager.email@gmail.com',
                          password: '$2b$10$fZ7o3DAOl6nRk/nXJ.Fe1.DHmh9q5rByeodydnM22nmtIKBpw07yW',
                  Severity: Minor
                  Found in src/database/seeders/20191115043919-super-admin.js and 1 other location - About 55 mins to fix
                  src/database/seeders/20191115043919-super-admin.js on lines 7..17

                  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 53.

                  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

                        {
                          firstName: 'Mary',
                          lastName: 'Doe',
                          email: 'marydoe@gmail.com',
                          password: '$2b$10$fZ7o3DAOl6nRk/nXJ.Fe1.DHmh9q5rByeodydnM22nmtIKBpw07yW',
                  Severity: Minor
                  Found in src/database/seeders/20191104145912-users.js and 1 other location - About 55 mins to fix
                  src/database/seeders/20191104145912-users.js on lines 28..38

                  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 53.

                  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

                      return queryInterface.bulkInsert('users', [{
                          firstName: 'John',
                          lastName: 'Doe',
                          email: 'admin@gmail.com',
                          password: '$2b$10$fZ7o3DAOl6nRk/nXJ.Fe1.DHmh9q5rByeodydnM22nmtIKBpw07yW',
                  Severity: Minor
                  Found in src/database/seeders/20191115043919-super-admin.js and 1 other location - About 55 mins to fix
                  src/database/seeders/20191115043919-super-admin.js on lines 18..28

                  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 53.

                  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

                        {
                          firstName: 'myuser',
                          lastName: 'mytest',
                          email: 'mytest@myemail.com',
                          password: '$2b$10$fZ7o3DAOl6nRk/nXJ.Fe1.DHmh9q5rByeodydnM22nmtIKBpw07yW',
                  Severity: Minor
                  Found in src/database/seeders/20191104145912-users.js and 1 other location - About 55 mins to fix
                  src/database/seeders/20191104145912-users.js on lines 39..49

                  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 53.

                  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(
                        'ratings',
                        'userId',
                        {
                        type: Sequelize.INTEGER,
                  Severity: Minor
                  Found in src/database/migrations/20191203155339-modify-ratings.js and 1 other location - About 50 mins to fix
                  src/database/migrations/20191203089313-modify-accommodations.js on lines 5..17

                  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 52.

                  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