ssube/isolex

View on GitHub

Showing 39 of 40 total issues

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

  it('should reply with approval when checks pass', async () => {
    const { container, services } = await createServiceContainer();
    const createReview = reviewResponse();
    const pullGetter = pullGetResponse([]);

Severity: Major
Found in test/controller/github/TestApproveController.ts and 1 other location - About 7 hrs to fix
test/controller/github/TestApproveController.ts on lines 174..218

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

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 reply with errors when checks fail', async () => {
    const { container, services } = await createServiceContainer();
    const createReview = reviewResponse();
    const pullGetter = pullGetResponse([]);

Severity: Major
Found in test/controller/github/TestApproveController.ts and 1 other location - About 7 hrs to fix
test/controller/github/TestApproveController.ts on lines 128..172

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

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 reload config while running', async () => {
    const { bot, ctr } = await createBot(TEST_CONFIG_SERVICE);
    const { svc, spies } = await serviceSpy({});

    const [module] = ctr.getModules();
Severity: Major
Found in test/TestApp.ts and 1 other location - About 5 hrs to fix
test/TestApp.ts on lines 138..166

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

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 reset metrics while running', async () => {
    const { bot, ctr } = await createBot(TEST_CONFIG_SERVICE);
    const { svc, spies } = await serviceSpy({});

    const [module] = ctr.getModules();
Severity: Major
Found in test/TestApp.ts and 1 other location - About 5 hrs to fix
test/TestApp.ts on lines 168..196

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

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

  describe('any operator', async () => {
    it('should match a single string to itself', async () => {
      const match = createMatch({
        operator: RuleOperator.Any,
        values: [{ string: 'bar' }],
Severity: Major
Found in test/utils/TestMatchRules.ts and 1 other location - About 4 hrs to fix
test/utils/TestMatchRules.ts on lines 17..55

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

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

  describe('every operator', async () => {
    it('should match a single string to itself', async () => {
      const match = createMatch({
        operator: RuleOperator.Every,
        values: [{ string: 'bar' }],
Severity: Major
Found in test/utils/TestMatchRules.ts and 1 other location - About 4 hrs to fix
test/utils/TestMatchRules.ts on lines 111..149

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

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 fail when author is not trusted', async () => {
    const { container, services } = await createServiceContainer();
    const listForRef = checkResponse([]);
    const getCombinedStatusForRef = statusResponse([]);

Severity: Major
Found in test/controller/github/TestApproveController.ts and 1 other location - About 4 hrs to fix
test/controller/github/TestApproveController.ts on lines 298..339

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

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 handle projects with zero checks', async () => {
    const { container, services } = await createServiceContainer();
    const listForRef = checkResponse([]);
    const getCombinedStatusForRef = statusResponse([]);

Severity: Major
Found in test/controller/github/TestApproveController.ts and 1 other location - About 4 hrs to fix
test/controller/github/TestApproveController.ts on lines 255..296

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

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 TestApproveController.ts has 355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Octokit } from '@octokit/rest';
import { expect } from 'chai';
import { ineeda } from 'ineeda';
import { match, spy, stub } from 'sinon';

Severity: Minor
Found in test/controller/github/TestApproveController.ts - About 4 hrs to fix

    File GitlabEndpoint.ts has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { mustExist } from '@apextoaster/js-utils';
    import { Request, Response } from 'express';
    import { Inject } from 'noicejs';
    
    import { Endpoint, Handler } from '.';
    Severity: Minor
    Found in src/endpoint/GitlabEndpoint.ts - About 2 hrs to fix

      File Bot.ts has 277 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { ExternalModule, removeNone, isNone, mustExist, mustFind } from '@apextoaster/js-utils';
      import { Container, Inject, LogLevel } from 'noicejs';
      import { Registry } from 'prom-client';
      import { Subject } from 'rxjs';
      
      
      Severity: Minor
      Found in src/Bot.ts - About 2 hrs to fix

        File DiscordListener.ts has 257 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { doesExist, InvalidArgumentError, isNil, mustExist, NotFoundError } from '@apextoaster/js-utils';
        import {
          Channel,
          ChannelLogsQueryOptions,
          Client,
        Severity: Minor
        Found in src/listener/DiscordListener.ts - About 2 hrs to fix

          Function createEndpoint has 46 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

          export async function createEndpoint<
            TEndpoint extends BaseEndpoint<EndpointData>,
            TData extends EndpointData
          >(
            epType: Constructor<TEndpoint, BaseEndpointOptions<TData>>,
          Severity: Minor
          Found in test/helpers/request.ts - About 1 hr to fix

            Function setupPassport has 41 lines of code (exceeds 30 allowed). Consider refactoring.
            Open

              protected async setupPassport(): Promise<passport.Authenticator> {
                const auth = new passport.Passport();
                auth.use(new JwtStrategy({
                  audience: this.data.token.audience,
                  issuer: this.data.token.issuer,
            Severity: Minor
            Found in src/listener/ExpressListener.ts - About 1 hr to fix

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

                it('should get past messages', async () => {
                  const { container } = await createServiceContainer();
                  const sendMessage = spy();
                  const graph = await createService(container, GraphSchema, {
                    [INJECT_BOT]: ineeda<Bot>({
              Severity: Major
              Found in test/schema/TestGraph.ts and 1 other location - About 1 hr to fix
              test/schema/TestGraph.ts on lines 77..103

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

              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 get past commands', async () => {
                  const { container } = await createServiceContainer();
                  const sendMessage = spy();
                  const graph = await createService(container, GraphSchema, {
                    [INJECT_BOT]: ineeda<Bot>({
              Severity: Major
              Found in test/schema/TestGraph.ts and 1 other location - About 1 hr to fix
              test/schema/TestGraph.ts on lines 105..131

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

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

                protected async createTokenSession(data: JwtFields, done: VerifiedCallback) {
                  this.logger.debug({ data }, 'creating session from token');
                  const token = await this.tokenRepository.findOne({
                    id: data.jti,
                  }, {
              Severity: Minor
              Found in src/listener/ExpressListener.ts - About 1 hr to fix

                Function checkRef has 36 lines of code (exceeds 30 allowed). Consider refactoring.
                Open

                  public async checkRef(options: ProjectRef, author: string): Promise<RefResult> {
                    const results = await this.collectChecks(options);
                    const project = this.data.projects.find((it) => it.owner === options.owner && it.project === options.repo);
                    if (isNil(project)) {
                      return errorResult({
                Severity: Minor
                Found in src/controller/github/ApproveController.ts - About 1 hr to fix

                  Function approveRefOrRequest has 33 lines of code (exceeds 30 allowed). Consider refactoring.
                  Open

                    @Handler(NOUN_APPROVE, CommandVerb.Create)
                    @CheckRBAC()
                    public async approveRefOrRequest(cmd: Command, ctx: Context): Promise<void> {
                      const owner = cmd.getHeadOrDefault('owner', ctx.sourceUser.name);
                      const repo = cmd.getHead('project');
                  Severity: Minor
                  Found in src/controller/github/ApproveController.ts - About 1 hr to fix

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

                      describe('readiness route', async () => {
                        it('should succeed when storage is connected', async () => {
                          const endpoint = await createEndpoint(HealthEndpoint, true, true);
                          const { response, status } = createRequest();
                          await endpoint.getReadiness(ineeda<Request>({}), response);
                    Severity: Minor
                    Found in test/endpoint/TestHealthEndpoint.ts and 1 other location - About 50 mins to fix
                    test/endpoint/TestHealthEndpoint.ts on lines 44..58

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

                    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