andela/codepirates-ah-backend

View on GitHub

Showing 142 of 142 total issues

Function signup has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static async signup(req, res) {
    const newUser = req.body;
    newUser.email = req.body.email.toLowerCase();
    try {
      const theUser = await UserService.findOne(req.body.email, '');
Severity: Minor
Found in src/controllers/user.controller.js - About 1 hr to fix

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

    export const facebookConfig = {
      clientID: process.env.FACEBOOK_ID,
      clientSecret: process.env.FACEBOOK_SECRET,
      callbackURL: process.env.BACKEND_URL + process.env.FACEBOOK_CALLBACK_URL,
      profileFields: ['id', 'name', 'email', 'photos']
    Severity: Major
    Found in src/config/oauth.js and 1 other location - About 1 hr to fix
    src/config/oauth.js on lines 14..19

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

    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

    export const twitterConfig = {
      consumerKey: process.env.TWITTER_ID,
      consumerSecret: process.env.TWITTER_SECRET,
      callbackURL: process.env.BACKEND_URL + process.env.TWITTER_CALLBACK_URL,
      profileFields: ['id', 'name', 'email', 'photos']
    Severity: Major
    Found in src/config/oauth.js and 1 other location - About 1 hr to fix
    src/config/oauth.js on lines 7..12

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

    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 45 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/migrations/20190816132215-create-likes.js - About 1 hr to fix

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

        static async login(req, res) {
          try {
            let theUser;
      
            if (req.body.email) {
      Severity: Minor
      Found in src/controllers/user.controller.js - About 1 hr to fix

        Function up has 45 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/migrations/20190816101310-create-comment.js - About 1 hr to fix

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

          module.exports = (sequelize, DataTypes) => {
            const user = sequelize.define('user', {
              firstname: DataTypes.STRING,
              lastname: DataTypes.STRING,
              email: DataTypes.STRING,
          Severity: Minor
          Found in src/models/user.js - About 1 hr to fix

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

              static async notifyViaEmailAndPush(req, res, slug) {
                try {
                  const followedUser = await models.user.findOne({ where: { email: req.auth.email } });
                  const myFollowers = await models.Follow.findAll({
                    where: { followedUserId: followedUser.id },
            Severity: Minor
            Found in src/services/notification.service.js - About 1 hr to fix

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

                  {
                    slug: 'first',
                    title: 'title1',
                    description: 'description1',
                    body: 'body1',
              Severity: Major
              Found in src/seeders/20190816064246-test-articles.js and 4 other locations - About 1 hr to fix
              src/seeders/20190814094408-demo-article.js on lines 6..19
              src/seeders/20190816064246-test-articles.js on lines 19..32
              src/seeders/20190816064246-test-articles.js on lines 33..46
              src/seeders/20190816064246-test-articles.js on lines 47..60

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

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

                  {
                    slug: 'fourth',
                    title: 'title4',
                    description: 'description4',
                    body: 'body4',
              Severity: Major
              Found in src/seeders/20190816064246-test-articles.js and 4 other locations - About 1 hr to fix
              src/seeders/20190814094408-demo-article.js on lines 6..19
              src/seeders/20190816064246-test-articles.js on lines 5..18
              src/seeders/20190816064246-test-articles.js on lines 19..32
              src/seeders/20190816064246-test-articles.js on lines 33..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 70.

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

                    {
                      slug: 'fakeslug',
                      title: 'faketitle',
                      description: 'fakedescription',
                      body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
              Severity: Major
              Found in src/seeders/20190814094408-demo-article.js and 4 other locations - About 1 hr to fix
              src/seeders/20190816064246-test-articles.js on lines 5..18
              src/seeders/20190816064246-test-articles.js on lines 19..32
              src/seeders/20190816064246-test-articles.js on lines 33..46
              src/seeders/20190816064246-test-articles.js on lines 47..60

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

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

                  {
                    slug: 'third',
                    title: 'title3',
                    description: 'description3',
                    body: 'body3',
              Severity: Major
              Found in src/seeders/20190816064246-test-articles.js and 4 other locations - About 1 hr to fix
              src/seeders/20190814094408-demo-article.js on lines 6..19
              src/seeders/20190816064246-test-articles.js on lines 5..18
              src/seeders/20190816064246-test-articles.js on lines 19..32
              src/seeders/20190816064246-test-articles.js on lines 47..60

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

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

                  {
                    slug: 'second',
                    title: 'title2',
                    description: 'description2',
                    body: 'body2',
              Severity: Major
              Found in src/seeders/20190816064246-test-articles.js and 4 other locations - About 1 hr to fix
              src/seeders/20190814094408-demo-article.js on lines 6..19
              src/seeders/20190816064246-test-articles.js on lines 5..18
              src/seeders/20190816064246-test-articles.js on lines 33..46
              src/seeders/20190816064246-test-articles.js on lines 47..60

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

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

                static async handlePasswordReset(req, res) {
                  // verify token and if its not expired
                  const { token } = req.params;
                  const tokenDecoded = Helper.verifyToken(token);
                  if (tokenDecoded === 'invalid token') {
              Severity: Minor
              Found in src/controllers/user.controller.js - About 1 hr to fix

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

                  static async updateArticle(slug, fieldToupdate) {
                    try {
                      const results = await db.update(fieldToupdate, { where: { slug }, returning: true });
                      return results;
                    } catch (error) {
                Severity: Major
                Found in src/services/article.service.js and 1 other location - About 1 hr to fix
                src/services/comments.service.js on lines 58..65

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

                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

                  static async updateComment(id, updateComments) {
                    try {
                      const results = await database.update(updateComments, { where: { id }, returning: true });
                      return results;
                    } catch (error) {
                Severity: Major
                Found in src/services/comments.service.js and 1 other location - About 1 hr to fix
                src/services/article.service.js on lines 67..74

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

                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

                  google_new: {
                    id: '100027718370607337396',
                    displayName: 'Three Four',
                    name: { familyName: 'Three', givenName: 'Four' },
                    emails: [{ value: 'thirtyfour@gmail.com', verified: true }],
                Severity: Major
                Found in src/mock-data.js and 1 other location - About 1 hr to fix
                src/mock-data.js on lines 22..34

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

                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

                  google_existing: {
                    id: '100027718370607337396',
                    displayName: 'Admin Admin',
                    name: { familyName: 'Admin', givenName: 'Admin' },
                    emails: [{ value: 'admin@gmail.com', verified: true }],
                Severity: Major
                Found in src/mock-data.js and 1 other location - About 1 hr to fix
                src/mock-data.js on lines 67..79

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

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

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

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

                    static async login(req, res) {
                      data = req.user;
                      const type = data.provider;
                      try {
                        let user;
                  Severity: Minor
                  Found in src/controllers/social.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language