Gielert/NoodleJS

View on GitHub

Showing 40 of 40 total issues

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          unmute() {
              this.connection.writeProto('UserState', {session: this.user.session, actor: this.user.session, selfMute: false})
          }
      Severity: Major
      Found in src/Client.js and 1 other location - About 1 hr to fix
      src/Client.js on lines 190..192

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          mute() {
              this.connection.writeProto('UserState', {session: this.user.session, actor: this.user.session , selfMute: true})
          }
      Severity: Major
      Found in src/Client.js and 1 other location - About 1 hr to fix
      src/Client.js on lines 194..196

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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 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 _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 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

      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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                     } else {
                         this.voiceSequence += this.connection.writeAudio(
                             frame,
                             this.whisperId,
                             this.connection.codec,
      Severity: Minor
      Found in src/voice/DispatchStream.js and 1 other location - About 35 mins to fix
      src/voice/DispatchStream.js on lines 75..83

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                     if (this.frameQueue.length < 1)  {
                         this.voiceSequence += this.connection.writeAudio(
                             frame,
                             this.whisperId,
                             this.connection.codec,
      Severity: Minor
      Found in src/voice/DispatchStream.js and 1 other location - About 35 mins to fix
      src/voice/DispatchStream.js on lines 83..91

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              return this.client.connection
                  .writeProto('TextMessage', textMessage.toPacket())
                  .then(() => Promise.resolve(textMessage))
      Severity: Minor
      Found in src/structures/Channel.js and 1 other location - About 35 mins to fix
      src/structures/User.js on lines 40..42

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              return this.client.connection
                  .writeProto('TextMessage', textMessage.toPacket())
                  .then(() => Promise.resolve(textMessage))
      Severity: Minor
      Found in src/structures/User.js and 1 other location - About 35 mins to fix
      src/structures/Channel.js on lines 86..88

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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 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)
        Severity: Minor
        Found in src/handlers/UserState.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 fromVarInt has a Cognitive Complexity of 6 (exceeds 5 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 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