Showing 12 of 29 total issues
File index.ts
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
'use strict'
import { Logger, logger } from '../log.js'
import {
AddRequest,
Function castMessage
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
Open
export const castMessage = <T extends MethodRequest>(msg: MethodRequest): T => {
if (!('method' in msg)) throw new invalidRequest('No method')
const method = msg.method as EventType
const params = msg.params
switch (method) {
- 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 castMessage
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const castMessage = <T extends MethodRequest>(msg: MethodRequest): T => {
if (!('method' in msg)) throw new invalidRequest('No method')
const method = msg.method as EventType
const params = msg.params
switch (method) {
Function constructor
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(port: number | Socket, ip = '') {
super()
if (port instanceof Socket) {
this.socket = port
} else {
Function listen
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
listen() {
this.wsServer = new WsServer({
port: this.config.wsPort,
server: this.config.server,
path: this.config.wsPath,
Function createPathMatcher
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const createPathMatcher = (options: FetchParams) => {
if (!options.path) {
return () => true
}
const po = options.path
Function addEventListener
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
addEventListener(
method: string | symbol,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
listener: { (...args: any[]): void; call?: any }
) {
Function edgePos
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var edgePos = () => {
var x = Math.random()
var size = 0.8
if (Math.random() > 0.7) {
size = 0.4
Function renderBall
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var renderBall = (ball: ballEvent) => {
if (ball.event === 'Add') {
try {
balls[ball.path] = ball
svgContainer
Function createPathMatcher
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
export const createPathMatcher = (options: FetchParams) => {
if (!options.path) {
return () => true
}
const po = options.path
- 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
Avoid too many return
statements within this function. Open
Open
return msg as T
Avoid too many return
statements within this function. Open
Open
return msg as T