Asymmetrik/node-rest-starter

View on GitHub

Showing 301 of 301 total issues

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

                return u
                    .save()
                    .then(() => {
                        assert.fail();
                    })
Severity: Major
Found in src/app/core/user/user.model.spec.ts and 1 other location - About 1 hr to fix
src/app/core/user/user.model.spec.ts on lines 284..291

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

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 validUser
                .save()
                .then(() => {
                    assert.fail();
                })
Severity: Major
Found in src/app/core/user/user.model.spec.ts and 1 other location - About 1 hr to fix
src/app/core/user/user.model.spec.ts on lines 301..308

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

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 begin with no teams', async () => {
            const teams = await Team.find({}).exec();
            teams.should.have.length(0);
        });
Severity: Major
Found in src/app/core/teams/team.model.spec.ts and 1 other location - About 1 hr to fix
src/app/core/teams/team.model.spec.ts on lines 87..90

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

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

            beforeEach(() => {
                const configGetStub = sandbox.stub(config, 'get');
                configGetStub.withArgs('teams.implicitMembers.enabled').returns(false);
                configGetStub.callThrough();
            });
Severity: Major
Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 1 hr to fix
src/app/core/teams/teams.service.spec.ts on lines 1236..1240

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

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

            beforeEach(() => {
                const configGetStub = sandbox.stub(config, 'get');
                configGetStub.withArgs('teams.implicitMembers.enabled').returns(false);
                configGetStub.callThrough();
            });
Severity: Major
Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 1 hr to fix
src/app/core/teams/teams.service.spec.ts on lines 898..902

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

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 begin with no users', async () => {
            const users = await User.find({}).exec();
            users.should.have.length(0);
        });
Severity: Major
Found in src/app/core/teams/team.model.spec.ts and 1 other location - About 1 hr to fix
src/app/core/teams/team.model.spec.ts on lines 64..67

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

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 updateRoles has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    updateRoles(user) {
        if (this.provider) {
            const strategy = this.getRoleStrategy();
            const isHybrid = strategy === 'hybrid';

Severity: Minor
Found in src/app/core/user/auth/user-authorization.service.ts - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function verify has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const verify = (role) => {
    return function (req, res, next) {
        // Grab the Authentication header
        const authentication = req.headers.authentication;
        if (null == authentication) {
Severity: Minor
Found in src/app/core/token-auth.server.service.ts - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function initMiddleware has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function initMiddleware(app: Express) {
    // Showing stack errors
    app.set('showStackError', true);

    // Should be placed before express.static
Severity: Minor
Found in src/lib/express.ts - About 1 hr to fix

    Function updateTeams has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async updateTeams(user: IUser) {
            const strategy = config.get('teams.implicitMembers.strategy');
            const nestedTeamsEnabled = config.get<boolean>('teams.nestedTeams');
    
            if (strategy === 'disabled' && !nestedTeamsEnabled) {
    Severity: Minor
    Found in src/app/core/teams/teams.service.ts - About 1 hr to fix

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

          login(user: UserDocument, req): Promise<IUser> {
              return new Promise((resolve, reject) => {
                  // Calls the login function (which goes to passport)
                  req.login(user, (err) => {
                      if (err) {
      Severity: Minor
      Found in src/app/core/user/auth/user-authentication.service.ts - About 1 hr to fix

        Function auditCopy has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        UserSchema.methods.auditCopy = function (userIP?: string) {
            const toReturn: Record<string, unknown> = {};
        
            const asObject = this.toObject();
        
        
        Severity: Minor
        Found in src/app/core/user/user.model.ts - About 1 hr to fix

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

          function clearDatabase() {
              return Promise.all([Team.deleteMany({}).exec(), User.deleteMany({}).exec()]);
          }
          Severity: Major
          Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 1 hr to fix
          src/app/core/user/auth/user-authentication.controller.spec.ts on lines 29..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 56.

          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

              afterEach(async () => {
                  await Promise.all([
                      User.deleteMany().exec(),
                      UserAgreement.deleteMany().exec()
                  ]);
          Severity: Major
          Found in src/app/core/user/eua/eua.service.spec.ts and 1 other location - About 1 hr to fix
          src/app/core/user/eua/eua.service.spec.ts on lines 11..16

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

          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

          function clearDatabase() {
              return Promise.all([
                  User.deleteMany({}).exec(),
                  CacheEntry.deleteMany({}).exec()
              ]);
          src/app/core/teams/teams.service.spec.ts on lines 22..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 56.

          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

              beforeEach(async () => {
                  await Promise.all([
                      User.deleteMany().exec(),
                      UserAgreement.deleteMany().exec()
                  ]);
          Severity: Major
          Found in src/app/core/user/eua/eua.service.spec.ts and 1 other location - About 1 hr to fix
          src/app/core/user/eua/eua.service.spec.ts on lines 18..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 56.

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

          export function containsSearchPlugin<
              EnforcedDocType,
              TModelType,
              TInstanceMethods
          >(
          Severity: Minor
          Found in src/app/common/mongoose/contains-search.plugin.ts - About 1 hr to fix

            Function requiresRoleHelper has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    const requiresRoleHelper = (method, testFunction) => {
                        describe(method, () => {
                            it('user not found', async () => {
                                sandbox.stub(teamsService, 'meetsRoleRequirement').resolves();
            
            
            Severity: Minor
            Found in src/app/core/teams/teams.controller.spec.ts - About 1 hr to fix

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

                          const input = {
                              hello: {
                                  there: 'you are',
                                  when: [{}, { something: 0 }, { $date: '2015-01-01T00:00:00.000Z' }]
                              },
              Severity: Minor
              Found in src/app/common/util.service.spec.ts and 1 other location - About 55 mins to fix
              src/app/common/util.service.spec.ts on lines 39..45

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

              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

                          const input = {
                              hello: {
                                  there: 'you are',
                                  when: [{}, { something: 0 }, { $obj: '000000000000000000000000' }]
                              },
              Severity: Minor
              Found in src/app/common/util.service.spec.ts and 1 other location - About 55 mins to fix
              src/app/common/util.service.spec.ts on lines 18..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 54.

              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