Showing 30 of 114 total issues
File authentication.ts
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Router, Request, Response } from "express";
import { readFileSync } from "fs";
import * as jwt from "jsonwebtoken";
import { ServerEvents, UserEvent } from "./server-events";
import { compareSync, hashSync } from "bcrypt";
Function applyCategoryEvent
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async applyCategoryEvent(categoryEvent: Event) {
await this.is.ready;
const newCategory = {
name: categoryEvent.data.categoryData?.name,
Function fetchAllInventoryThingStocks
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private async fetchAllInventoryThingStocks() {
console.log("fetch all Stocks");
// Wait for the other services to be ready
await this.ts.ready;
- 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"
Further reading
Function applyStockEvent
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async applyStockEvent(stockEvent: Event) {
await this.is.ready;
/**
* One date representing now
Function applyCategoryEvent
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private async applyCategoryEvent(categoryEvent: Event) {
await this.is.ready;
const newCategory = {
name: categoryEvent.data.categoryData?.name,
- 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"
Further reading
Function fetchAllInventoryCategories
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private async fetchAllInventoryCategories() {
// Wait for the other services to be ready
await this.is.ready;
await this.ess.ready;
- 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"
Further reading
Function fetchSingleInventoryEvents
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async fetchSingleInventoryEvents(
inventoryUuid: string
): Promise<void> {
let res: Event[] = await this.api
.get<Event[]>(this.baseUrl + "/events/" + inventoryUuid)
Function checkEventLegitimacy
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public checkEventLegitimacy(
event: InventoryEvent,
userUuid: string,
): boolean {
try {
Function ngOnInit
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async ngOnInit(): Promise<void> {
this.inventoryUuid = this.route.snapshot.params.inventoryUuid;
this.thingUuid = this.route.snapshot.params.thingUuid;
this.stockUuid = this.route.snapshot.params.stockUuid;
Function start
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async start() {
// Connect to the db
await db();
// Set the ports
Function updateInventoriesProjection
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public updateInventoriesProjection(event: InventoryEvent): Inventory {
// Make sure the event is about an inventory
if (event.data.itemType !== itemType.INVENTORY)
throw new Error(
"Cannot update inventoriesProjection with non-inventory event.",
Function fetchSingleInventoryEvents
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private async fetchSingleInventoryEvents(
inventoryUuid: string
): Promise<void> {
let res: Event[] = await this.api
.get<Event[]>(this.baseUrl + "/events/" + inventoryUuid)
- 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"
Further reading
Function deleteInventory
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async deleteInventory(): Promise<void> {
const dialogRef: MatDialogRef<any> = this.dialog.open(
DeleteConfirmationDialogComponent,
{
data: { inventory: this.inventory }
- 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"
Further reading
Function handleLogin
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async handleLogin(req: Request, res: Response) {
try {
/**
* The saltedPwdHash from the users projection
*/
Function updateInventoriesProjection
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private updateInventoriesProjection(event: Event): Inventory {
/**
* The inventory to be created or updated (ignored for delete events)
*/
const newInventory = {
Function handleRegister
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async handleRegister(req: Request, res: Response) {
// Check for duplicate email
if (
Authentication.usersProjection.find((user: User) => {
return user.email === req.body.email;
Function updateStock
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async updateStock(
stock: Stock,
inventoryUuid: string,
thingUuid: string
): Promise<void> {
Function exports
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
Function applyThingEvent
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private applyThingEvent(event: Event, inventoryUuid: string) {
/**
* The index of the event in the projection, if any
*/
const index = ThingService.inventoryTingsProjection[
Function updateUsersProjection
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static updateUsersProjection(event: UserEvent) {
const index = Authentication.usersProjection.findIndex(
(user: User) => user.uuid === event.data.userUuid,
);