ssube/isolex

View on GitHub

Showing 10 of 40 total issues

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

              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

                    Function getToken has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                    Open

                      @Handler(NOUN_TOKEN, CommandVerb.Get)
                      @CheckRBAC()
                      public async getToken(cmd: Command, ctx: Context): Promise<void> {
                        if (cmd.has('token')) {
                          try {
                    Severity: Minor
                    Found in src/controller/TokenController.ts - About 25 mins 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

                    Severity
                    Category
                    Status
                    Source
                    Language