socketio/socket.io

View on GitHub

Showing 158 of 158 total issues

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

    function Manager(uri, opts) {
      var _this;

      _classCallCheck(this, Manager);

Severity: Minor
Found in client-dist/socket.io.js - About 1 hr to fix

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

    socket.io.engine.on('data', (data) => console.log('[msgpack]' + ' size= ' + (typeof data === 'string' ? data.length : data.byteLength)));
    Severity: Major
    Found in examples/custom-parsers/src/client2.js and 3 other locations - About 1 hr to fix
    examples/custom-parsers/src/client1.js on lines 4..4
    examples/custom-parsers/src/client3.js on lines 7..7
    examples/custom-parsers/src/client4.js on lines 7..7

    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 60.

    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

        }, {
          key: "prependAny",
          value: function prependAny(listener) {
            this._anyListeners = this._anyListeners || [];
    
    
    Severity: Major
    Found in client-dist/socket.io.js and 1 other location - About 1 hr to fix
    client-dist/socket.io.js on lines 3585..3602

    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 60.

    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 4 locations. Consider refactoring.
    Open

    socket.io.engine.on('data', (data) => console.log('[custom]' + ' size= ' + (typeof data === 'string' ? data.length : data.byteLength)));
    Severity: Major
    Found in examples/custom-parsers/src/client4.js and 3 other locations - About 1 hr to fix
    examples/custom-parsers/src/client1.js on lines 4..4
    examples/custom-parsers/src/client2.js on lines 7..7
    examples/custom-parsers/src/client3.js on lines 7..7

    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 60.

    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

        }, {
          key: "onAny",
          value: function onAny(listener) {
            this._anyListeners = this._anyListeners || [];
    
    
    Severity: Major
    Found in client-dist/socket.io.js and 1 other location - About 1 hr to fix
    client-dist/socket.io.js on lines 3602..3618

    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 60.

    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 3 locations. Consider refactoring.
    Open

      public in(room: Room | Room[]): BroadcastOperator<EmitEvents, SocketData> {
        return new BroadcastOperator(this.adapter).in(room);
      }
    Severity: Major
    Found in lib/namespace.ts and 2 other locations - About 1 hr to fix
    lib/namespace.ts on lines 178..180
    lib/namespace.ts on lines 200..204

    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 60.

    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 3 locations. Consider refactoring.
    Open

      public except(
        room: Room | Room[]
      ): BroadcastOperator<EmitEvents, SocketData> {
        return new BroadcastOperator(this.adapter).except(room);
      }
    Severity: Major
    Found in lib/namespace.ts and 2 other locations - About 1 hr to fix
    lib/namespace.ts on lines 178..180
    lib/namespace.ts on lines 189..191

    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 60.

    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 4 locations. Consider refactoring.
    Open

    socket.io.engine.on('data', (data) => console.log('[default]' + ' size= ' + (typeof data === 'string' ? data.length : data.byteLength)));
    Severity: Major
    Found in examples/custom-parsers/src/client1.js and 3 other locations - About 1 hr to fix
    examples/custom-parsers/src/client2.js on lines 7..7
    examples/custom-parsers/src/client3.js on lines 7..7
    examples/custom-parsers/src/client4.js on lines 7..7

    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 60.

    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 4 locations. Consider refactoring.
    Open

    socket.io.engine.on('data', (data) => console.log('[json]' + ' size= ' + (typeof data === 'string' ? data.length : data.byteLength)));
    Severity: Major
    Found in examples/custom-parsers/src/client3.js and 3 other locations - About 1 hr to fix
    examples/custom-parsers/src/client1.js on lines 4..4
    examples/custom-parsers/src/client2.js on lines 7..7
    examples/custom-parsers/src/client4.js on lines 7..7

    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 60.

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

      public of(
        name: string | RegExp | ParentNspNameMatchFn,
        fn?: (
          socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>
        ) => void
    Severity: Minor
    Found in lib/index.ts - 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 3 locations. Consider refactoring.
    Open

      public to(room: Room | Room[]): BroadcastOperator<EmitEvents, SocketData> {
        return new BroadcastOperator(this.adapter).to(room);
      }
    Severity: Major
    Found in lib/namespace.ts and 2 other locations - About 1 hr to fix
    lib/namespace.ts on lines 189..191
    lib/namespace.ts on lines 200..204

    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 60.

    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 registerValidSW has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function registerValidSW(swUrl, config) {
      navigator.serviceWorker
        .register(swUrl)
        .then(registration => {
          registration.onupdatefound = () => {
    Severity: Minor
    Found in examples/create-react-app-example/src/serviceWorker.js - About 1 hr to fix

      Function onTransportOpen has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              var onTransportOpen = function onTransportOpen() {
                if (failed) return;
                transport.send([{
                  type: "ping",
                  data: "probe"
      Severity: Minor
      Found in client-dist/socket.io.js - About 1 hr to fix

        Function reconnect has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              value: function reconnect() {
                var _this3 = this;
        
                if (this._reconnecting || this.skipReconnect) return this;
                var self = this;
        Severity: Minor
        Found in client-dist/socket.io.js - About 1 hr to fix

          Function broadcast has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            Adapter.prototype.broadcast = function (packet, opts) {
              const useFastPublish = opts.rooms.size <= 1 && opts.except!.size === 0;
              if (!useFastPublish) {
                broadcast.call(this, packet, opts);
                return;
          Severity: Minor
          Found in lib/uws.ts - About 1 hr to fix

            Function close has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  value: function close() {
                    var _this6 = this;
            
                    var close = function close() {
                      _this6.onClose("forced close");
            Severity: Minor
            Found in client-dist/socket.io.js - About 1 hr to fix

              Function serveFile has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function serveFile(res /* : HttpResponse */, filepath: string) {
                const { size } = statSync(filepath);
                const readStream = createReadStream(filepath);
                const destroyReadStream = () => !readStream.destroyed && readStream.destroy();
              
              
              Severity: Minor
              Found in lib/uws.ts - About 1 hr to fix

                Function parseBinary has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  parseBinary (obj) {
                    let view = new Uint8Array(obj);
                    let packetId = view[0];
                    try {
                      let packet = {
                Severity: Minor
                Found in examples/custom-parsers/src/custom-parser.js - About 1 hr to fix

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

                    public to(room: Room | Room[]): BroadcastOperator<EmitEvents, SocketData> {
                      return this.newBroadcastOperator().to(room);
                    }
                  Severity: Major
                  Found in lib/socket.ts and 2 other locations - About 1 hr to fix
                  lib/socket.ts on lines 268..270
                  lib/socket.ts on lines 279..283

                  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 59.

                  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 3 locations. Consider refactoring.
                  Open

                    public in(room: Room | Room[]): BroadcastOperator<EmitEvents, SocketData> {
                      return this.newBroadcastOperator().in(room);
                    }
                  Severity: Major
                  Found in lib/socket.ts and 2 other locations - About 1 hr to fix
                  lib/socket.ts on lines 257..259
                  lib/socket.ts on lines 279..283

                  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 59.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language