Asymmetrik/node-rest-starter

View on GitHub

Showing 301 of 301 total issues

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

    describe('adminGetUser', () => {
        it('user is found', async () => {
            const req = {
                body: {},
                userParam: new User()
Severity: Major
Found in src/app/core/user/admin/user-admin.controller.spec.ts and 1 other location - About 2 hrs to fix
src/app/core/user/user.controller.spec.ts on lines 213..225

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

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

File default.js has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const contactEmail = process.env.CONTACT_EMAIL || 'noreply@bluehalo.com';

module.exports = {
Severity: Minor
Found in config/default.js - About 2 hrs to fix

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

    export const deleteTeam = async (req, res) => {
        await teamsService.delete(req.team);
    
        // Audit the team delete attempt
        await auditService.audit(
    Severity: Major
    Found in src/app/core/teams/teams.controller.ts and 1 other location - About 2 hrs to fix
    src/app/core/messages/message.controller.ts on lines 48..61

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

    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 deleteMessage = async (req, res) => {
        await messageService.delete(req.message);
    
        // Audit the message delete attempt
        await auditService.audit(
    Severity: Major
    Found in src/app/core/messages/message.controller.ts and 1 other location - About 2 hrs to fix
    src/app/core/teams/teams.controller.ts on lines 58..71

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

    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

    File user-authorization.service.spec.ts has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import mongoose from 'mongoose';
    import should from 'should';
    import { createSandbox } from 'sinon';
    
    import userAuthorizationService from './user-authorization.service';
    Severity: Minor
    Found in src/app/core/user/auth/user-authorization.service.spec.ts - About 2 hrs to fix

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

              const _user = new User({
                  teams: [
                      {
                          _id: '000000000000000000000001',
                          role: TeamRoles.Member
      Severity: Major
      Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 2 hrs to fix
      src/app/core/teams/teams.service.spec.ts on lines 1539..1562

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

      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

              const _user = new User({
                  teams: [
                      {
                          _id: '000000000000000000000001',
                          role: TeamRoles.Member
      Severity: Major
      Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 2 hrs to fix
      src/app/core/teams/teams.service.spec.ts on lines 1637..1660

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

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

          async getImplicitTeamIds(
              user: IUser,
              ...roles: TeamRoles[]
          ): Promise<Types.ObjectId[]> {
              // Validate the user input
      Severity: Major
      Found in src/app/core/teams/teams.service.ts - About 2 hrs to fix

        Function verify has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async verify(req, [primaryUserDn, proxiedUserDn, masqueradeUserDn], done) {
                // If there is no DN, we can't authenticate
                if (!primaryUserDn) {
                    return done(null, false, new BadRequestError('Missing certificate'));
                }
        Severity: Major
        Found in src/lib/strategies/proxy-pki.ts - About 2 hrs to fix

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

          export const hasAll = (...requirements: Array<RequirementFunction>) => {
              return (req, res, next) => {
                  Promise.resolve(requiresAll(requirements)(req, res, next))
                      .then(() => {
                          next();
          Severity: Major
          Found in src/app/common/express/auth-middleware.ts and 1 other location - About 2 hrs to fix
          src/app/common/express/auth-middleware.ts on lines 38..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 87.

          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

          function userSpec(key) {
              return new User({
                  name: `${key} Name`,
                  email: `${key}@mail.com`,
                  username: `${key}_username`,
          Severity: Major
          Found in src/app/core/user/user.service.spec.ts and 1 other location - About 2 hrs to fix
          src/app/core/user/admin/user-admin.controller.spec.ts on lines 14..23

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

          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 hasAny = (...requirements: Array<RequirementFunction>) => {
              return (req, res, next) => {
                  Promise.resolve(requiresAny(requirements)(req, res, next))
                      .then(() => {
                          next();
          Severity: Major
          Found in src/app/common/express/auth-middleware.ts and 1 other location - About 2 hrs to fix
          src/app/common/express/auth-middleware.ts on lines 25..33

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

          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

          function userSpec(key) {
              return new User({
                  name: `${key} Name`,
                  email: `${key}@mail.com`,
                  username: `${key}_username`,
          Severity: Major
          Found in src/app/core/user/admin/user-admin.controller.spec.ts and 1 other location - About 2 hrs to fix
          src/app/core/user/user.service.spec.ts on lines 10..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 87.

          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

          File user.model.spec.ts has 269 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import * as assert from 'assert';
          
          import { Types } from 'mongoose';
          import should from 'should';
          
          
          Severity: Minor
          Found in src/app/core/user/user.model.spec.ts - About 2 hrs to fix

            File user.controller.spec.ts has 267 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { assert, createSandbox } from 'sinon';
            
            import userAuthorizationService from './auth/user-authorization.service';
            import * as userController from './user.controller';
            import { User } from './user.model';
            Severity: Minor
            Found in src/app/core/user/user.controller.spec.ts - About 2 hrs to fix

              Function initSwaggerAPI has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function initSwaggerAPI(app: Express) {
                  // apiDocs must be enabled explicitly in the config
                  if (config.get<boolean>('apiDocs.enabled') !== true) {
                      return;
                  }
              Severity: Major
              Found in src/lib/express.ts - About 2 hrs to fix

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

                if (config.get('notificationExpires') === false) {
                    NotificationSchema.index({ created: -1 });
                } else {
                    NotificationSchema.index(
                        { created: -1 },
                Severity: Major
                Found in src/app/core/notifications/notification.model.ts and 1 other location - About 2 hrs to fix
                src/app/core/feedback/feedback.model.ts on lines 88..95

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

                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

                if (config.get('feedbackExpires') === false) {
                    FeedbackSchema.index({ created: -1 });
                } else {
                    FeedbackSchema.index(
                        { created: -1 },
                Severity: Major
                Found in src/app/core/feedback/feedback.model.ts and 1 other location - About 2 hrs to fix
                src/app/core/notifications/notification.model.ts on lines 73..80

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

                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

                            it('should find implicit teams for user with matching external roles (plain object)', async () => {
                                const teamIds = await teamsService.getImplicitTeamIds(user.implicit2);
                                should.exist(teamIds);
                                teamIds.should.be.Array();
                                teamIds.length.should.equal(2);
                Severity: Major
                Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 2 hrs to fix
                src/app/core/teams/teams.service.spec.ts on lines 1157..1162

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

                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

                            it('should find implicit teams for user with matching external roles (model object)', async () => {
                                const teamIds = await teamsService.getImplicitTeamIds(user.implicit2);
                                should.exist(teamIds);
                                teamIds.should.be.Array();
                                teamIds.length.should.equal(2);
                Severity: Major
                Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 2 hrs to fix
                src/app/core/teams/teams.service.spec.ts on lines 1164..1169

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

                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