Gielert/NoodleJS

View on GitHub

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

Severity: Minor
Found in src/structures/Channel.js - About 1 hr to fix

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;
Severity: Minor
Found in src/structures/Collection.js - About 1 hr to fix

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

Severity: Minor
Found in src/structures/Channel.js - About 1 hr to fix

    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;
    Severity: Minor
    Found in src/Connection.js - About 1 hr to fix

      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 = {
      Severity: Minor
      Found in src/Util.js - About 1 hr to fix

        Function constructor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            constructor(options = {}) {
                super()
        
                /**
                 * The options the client is instantiated with
        Severity: Minor
        Found in src/Client.js - About 1 hr to fix

          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()
          Severity: Minor
          Found in src/voice/DispatchStream.js - About 1 hr to fix

          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()
          Severity: Minor
          Found in src/voice/DispatchStream.js - About 1 hr to fix

            Function toVarint has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                static toVarint(i) {
            
                    var arr = [];
                    if( i < 0 ) {
                        i = ~i;
            Severity: Minor
            Found in src/Util.js - About 1 hr to fix

              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
              Severity: Minor
              Found in src/Connection.js - About 1 hr to fix

                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')
                        }
                
                
                Severity: Minor
                Found in src/Client.js - About 1 hr to fix

                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
                Severity: Minor
                Found in src/Connection.js - About 1 hr to fix

                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;
                Severity: Minor
                Found in src/Util.js - About 55 mins to fix

                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
                
                
                Severity: Minor
                Found in src/structures/TextMessage.js - About 55 mins to fix

                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)
                Severity: Minor
                Found in src/voice/DispatchStream.js - About 55 mins to fix

                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;
                Severity: Minor
                Found in src/Connection.js - About 35 mins to fix

                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',
                Severity: Minor
                Found in src/structures/User.js - About 35 mins to fix

                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}]})
                Severity: Major
                Found in src/Client.js - About 30 mins to fix

                  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)
                  Severity: Minor
                  Found in src/handlers/ChannelState.js - About 25 mins to fix

                  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 mergeDefault has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static mergeDefault(def, given) {
                          if (!given) return def;
                          for (const key in def) {
                              if (!{}.hasOwnProperty.call(given, key)) {
                                  given[key] = def[key];
                  Severity: Minor
                  Found in src/Util.js - About 25 mins to fix

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language