Showing 22 of 40 total issues
Function setup
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
setup(data) {
if (data.channelId == null)
return
- 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 find
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
find(propOrFn, value) {
if (typeof propOrFn === 'string') {
if (typeof value === 'undefined') throw new Error('Value must be specified.');
for (const item of this.values()) {
if (item[propOrFn] === value) return item;
- 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 setup
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
setup(data) {
if (data.channelId == null)
return
Function fromVarInt
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
static fromVarInt(buf) {
// TODO: 111110__ + varint Negative recursive varint
// TODO: 111111xx Byte-inverted negative two bit number (~xx)
var retVal = {
Function readAudio
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
readAudio(data) {
// Packet format:
// https://github.com/mumble-voip/mumble-protocol/blob/master/voice_data.rst#packet-format
const audioType = (data[0] & 0xE0) >> 5;
const audioTarget = data[0] & 0x1F;
Function constructor
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(options = {}) {
super()
/**
* The options the client is instantiated with
Function _processAudioBuffer
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
_processAudioBuffer() {
if(!this.lastWrite ||
this.lastWrite + 20 * Constants.Audio.frameLength < Date.now()) {
this.voiceSequence = this.connection.voiceSequence
this.lastWrite = Date.now()
- 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 _processAudioBuffer
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_processAudioBuffer() {
if(!this.lastWrite ||
this.lastWrite + 20 * Constants.Audio.frameLength < Date.now()) {
this.voiceSequence = this.connection.voiceSequence
this.lastWrite = Date.now()
Function toVarint
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static toVarint(i) {
var arr = [];
if( i < 0 ) {
i = ~i;
Function writeAudio
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
writeAudio(packet, whisperTarget, codec, voiceSequence, final) {
packet = this.currentEncoder.encode(packet)
const type = codec === Connection.codec().Opus ? 4 : 0
const target = whisperTarget || 0
Function setupVoiceTarget
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
setupVoiceTarget(targetId, userIds, channelId) {
if (targetId < 4 || targetId > 30) {
return Promise.reject('targetId must be between 3 and 30')
}
- 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 writeAudio
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
writeAudio(packet, whisperTarget, codec, voiceSequence, final) {
packet = this.currentEncoder.encode(packet)
const type = codec === Connection.codec().Opus ? 4 : 0
const target = whisperTarget || 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
Function toPacket
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
toPacket() {
let packet = {}
packet.message = this.content
- 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 toVarint
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static toVarint(i) {
var arr = [];
if( i < 0 ) {
i = ~i;
- 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 _write
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
_write(chunk, encoding, next) {
while(true) {
if(this.frameQueue.length >= Constants.Audio.frameLength) {
this.processObserver.once('written', () => {
this._write(chunk, encoding, next)
- 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 readAudio
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
readAudio(data) {
// Packet format:
// https://github.com/mumble-voip/mumble-protocol/blob/master/voice_data.rst#packet-format
const audioType = (data[0] & 0xE0) >> 5;
const audioTarget = data[0] & 0x1F;
- 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 setup
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
setup(data) {
for (const prop of [
'session', 'name', 'mute', 'deaf',
'suppress', 'selfMute', 'selfDeaf', 'texture', 'pluginContext',
'pluginIdentity', 'comment', 'hash', 'commentHash', 'textureHash',
- 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
return this.connection.writeProto('VoiceTarget', {id: targetId, targets: [{channelId: channelId}]})
Function handle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
handle(data) {
let user = this.client.users.get(data.session)
if (user) {
const oldUser = Util.cloneObject(user)
- 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 handle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
handle(data) {
let channel = this.client.channels.get(data.channelId)
if(channel) {
const oldChannel = Util.cloneObject(channel)
- 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"