Showing 48 of 75 total issues
Function setLogLevel
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Confirmed
export function setLogLevel(...levels: LogLevel[]) {
logLevels = levels
if (logLevels.includes(LogLevel.WEB_GROUP)) {
log.webgroup = (msg: string, ...rest: any[]): void => {
if (rest.length === 0) {
- 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
File WebChannel.ts
has 404 lines of code (exceeds 250 allowed). Consider refactoring. Confirmed
import { Observable, Subject } from 'rxjs'
import { Channel } from './Channel'
import {
extractHostnameAndPort,
Function constructor
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
constructor(options: WebGroupOptions = {}) {
const wc = new WebChannel(options)
wcs.set(this, wc)
/**
File FullMesh.ts
has 348 lines of code (exceeds 250 allowed). Consider refactoring. Confirmed
import { Channel, IChannelInitData, MAXIMUM_MISSED_HEARTBEAT } from '../../Channel'
import { isBrowser, log } from '../../misc/util'
import { fullMesh as proto } from '../../proto/index'
import { InWcMsg, WebChannel } from '../../WebChannel'
import { ConnectionError } from '../channelBuilder/ConnectionError'
Function setLogLevel
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
export function setLogLevel(...levels: LogLevel[]) {
logLevels = levels
if (logLevels.includes(LogLevel.WEB_GROUP)) {
log.webgroup = (msg: string, ...rest: any[]): void => {
if (rest.length === 0) {
File ChannelBuilder.ts
has 322 lines of code (exceeds 250 allowed). Consider refactoring. Confirmed
import { merge, Observable, Subject } from 'rxjs'
import { Channel } from '../../Channel'
import { isWebRTCSupported, isWebSocketSupported, log } from '../../misc/util'
import { channelBuilder as proto } from '../../proto/index'
Function handleMessage
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
private handleMessage(
streamId: number,
senderId: number,
recipientId: number,
msg: proto.Message
Function handleMessage
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
private handleMessage(
streamId: number,
senderId: number,
recipientId: number,
msg: proto.Message
- 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 constructor
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Confirmed
constructor(options: WebGroupOptions = {}) {
const wc = new WebChannel(options)
wcs.set(this, wc)
/**
- 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 initHandlers
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private initHandlers() {
// Configure handlers
this.wsOrDc.onmessage = ({ data }: { data: ArrayBuffer }) => {
try {
const msg = Message.decode(new Uint8Array(data))
- 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
WebChannel
has 27 functions (exceeds 20 allowed). Consider refactoring. Confirmed
export class WebChannel implements IStream<OutWcMessage, InWcMsg> {
public readonly STREAM_ID = 2
public members: number[]
public topologyEnum: TopologyEnum
public myId: number
Function constructor
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(wc: WebChannel) {
super(wc, FullMesh.SERVICE_ID, proto.Message)
this.adjacentMembers = new Map()
this.distantMembers = new Map()
this.antecedentId = 0
Function findRoutedChannel
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private findRoutedChannel(
distantMember: IDistantMember | undefined,
distance: number
): Channel | undefined {
if (distantMember) {
- 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 updateAntecedentId
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private updateAntecedentId() {
if (this.adjacentMembers.size > 0) {
let maxId = -1
let desiredId = -1
for (const id of this.wc.members) {
- 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 constructor
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
constructor(options: BotOptions) {
botServer = new BotServer(options)
/**
* Read-only NodeJS http server instance.
Function reconnectToSignaling
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private reconnectToSignaling() {
if (this.members.length === 1 && (!isVisible() || !isOnline())) {
this.internalLeave()
} else {
log.webgroup(`reconnect to Signaling server in ${REJOIN_TIMEOUT}ms`)
- 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 handleMessage
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
handleMessage(msg: proto.Message) {
if (msg.type) {
switch (msg.type) {
case 'offer':
log.webrtc('REMOTE OFFER', { offer: msg.offer })
Function connectToMembers
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private connectToMembers(ids: number[], adjacentId: number): Promise<void | void[]> {
const missingIds = ids.filter((id) => !this.adjacentMembers.has(id) && id !== this.wc.myId)
if (missingIds.length !== 0) {
log.topology(`TRY TO CONNECT to members`, missingIds)
const attempts: Array<Promise<void>> = []
Function setTopology
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
private setTopology(topologyEnum: TopologyEnum): void {
this.topologyEnum = topologyEnum
this.topology = new FullMesh(this)
this.topology.onState.subscribe((state: TopologyState) => {
log.webgroup('Topology state: ', TopologyState[state])
Function decodeUserMessage
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
decodeUserMessage(bytes: Uint8Array, senderId: number): UserDataType | undefined {
try {
const { length, type, contentType, full, chunk } = super.decode(bytes) as {
length: number
type: proto.Message.Type