src/Channel.ts
Function initHandlers
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
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
Function constructor
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(
wc: WebChannel,
wsOrDc: WebSocket | RTCDataChannel,
type: number,
id: number,
Function initHandlers
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private initHandlers() {
// Configure handlers
this.wsOrDc.onmessage = ({ data }: { data: ArrayBuffer }) => {
try {
const msg = Message.decode(new Uint8Array(data))
Function handleInitMessage
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private handleInitMessage(msg: proto.Message) {
switch (msg.type) {
case 'initPing': {
log.channel(`${this.wc.myId} received InitPing`)
const { topology, wcId, senderId, members, key } = msg.initPing as proto.Data
Function constructor
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
constructor(
wc: WebChannel,
wsOrDc: WebSocket | RTCDataChannel,
type: number,
id: number,
- 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
TODO found Open
Open
// TODO: implement when there are more than one topology implementation
- Exclude checks
TODO found Open
Open
// TODO: this is a rare case, when the joining peer id equals to the
- Exclude checks