Showing 10 of 40 total issues
File TestApproveController.ts
has 355 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { Octokit } from '@octokit/rest';
import { expect } from 'chai';
import { ineeda } from 'ineeda';
import { match, spy, stub } from 'sinon';
File GitlabEndpoint.ts
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { mustExist } from '@apextoaster/js-utils';
import { Request, Response } from 'express';
import { Inject } from 'noicejs';
import { Endpoint, Handler } from '.';
File Bot.ts
has 277 lines of code (exceeds 250 allowed). Consider refactoring. Open
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';
File DiscordListener.ts
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { doesExist, InvalidArgumentError, isNil, mustExist, NotFoundError } from '@apextoaster/js-utils';
import {
Channel,
ChannelLogsQueryOptions,
Client,
Function createEndpoint
has 46 lines of code (exceeds 30 allowed). Consider refactoring. Open
Open
export async function createEndpoint<
TEndpoint extends BaseEndpoint<EndpointData>,
TData extends EndpointData
>(
epType: Constructor<TEndpoint, BaseEndpointOptions<TData>>,
Function setupPassport
has 41 lines of code (exceeds 30 allowed). Consider refactoring. Open
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,
Function createTokenSession
has 37 lines of code (exceeds 30 allowed). Consider refactoring. Open
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,
}, {
Function checkRef
has 36 lines of code (exceeds 30 allowed). Consider refactoring. Open
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({
Function approveRefOrRequest
has 33 lines of code (exceeds 30 allowed). Consider refactoring. Open
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');
Function getToken
has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring. Open
Open
@Handler(NOUN_TOKEN, CommandVerb.Get)
@CheckRBAC()
public async getToken(cmd: Command, ctx: Context): Promise<void> {
if (cmd.has('token')) {
try {
- Read upRead up
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"