actioncable/app/assets/javascripts/actioncable.js

Summary

Maintainability
F
3 wks
Test Coverage

File actioncable.js has 505 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function(global, factory) {
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define([ "exports" ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, 
  factory(global.ActionCable = {}));
})(this, (function(exports) {
  "use strict";
Severity: Major
Found in actioncable/app/assets/javascripts/actioncable.js - About 1 day to fix

    Function message has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        message(event) {
          if (!this.isProtocolSupported()) {
            return;
          }
          const {identifier: identifier, message: message, reason: reason, reconnect: reconnect, type: type} = JSON.parse(event.data);
    Severity: Minor
    Found in actioncable/app/assets/javascripts/actioncable.js - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

                return this.subscriptions.notify(identifier, "connected", {
                  reconnected: false
                });
      Severity: Major
      Found in actioncable/app/assets/javascripts/actioncable.js - About 30 mins to fix

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

          class Connection {
            constructor(consumer) {
              this.open = this.open.bind(this);
              this.consumer = consumer;
              this.subscriptions = this.consumer.subscriptions;
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 5 days to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 132..230
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 138..236

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

        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

          class ConnectionMonitor {
            constructor(connection) {
              this.visibilityDidChange = this.visibilityDidChange.bind(this);
              this.connection = connection;
              this.reconnectAttempts = 0;
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 5 days to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 20..109
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 19..108

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

        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

          class Subscriptions {
            constructor(consumer) {
              this.consumer = consumer;
              this.guarantor = new SubscriptionGuarantor(this);
              this.subscriptions = [];
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 4 days to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 367..441
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 379..453

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

        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

          Connection.prototype.events = {
            message(event) {
              if (!this.isProtocolSupported()) {
                return;
              }
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 3 other locations - About 3 days to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 232..300
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 240..308
        actioncable/app/javascript/action_cable/connection.js on lines 127..179

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

        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

          class SubscriptionGuarantor {
            constructor(subscriptions) {
              this.subscriptions = subscriptions;
              this.pendingSubscriptions = [];
            }
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 2 days to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 331..366
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 342..377

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

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

          class Consumer {
            constructor(url) {
              this._url = url;
              this.subscriptions = new Subscriptions(this);
              this.connection = new Connection(this);
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 3 other locations - About 1 day to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 442..471
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 455..484
        actioncable/app/javascript/action_cable/consumer.js on lines 30..63

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

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

          class Subscription {
            constructor(consumer, params = {}, mixin) {
              this.consumer = consumer;
              this.identifier = JSON.stringify(params);
              extend(this, mixin);
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 7 hrs to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 310..330
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 320..340

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

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

          function createWebSocketURL(url) {
            if (typeof url === "function") {
              url = url();
            }
            if (url && !/^wss?:/i.test(url)) {
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 4 hrs to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 472..485
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 486..499

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

        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

        (function(global, factory) {
          typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define([ "exports" ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, 
          factory(global.ActionCable = {}));
        })(this, (function(exports) {
          "use strict";
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 3 other locations - About 3 hrs to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 1..511
        activestorage/app/assets/javascripts/activestorage.js on lines 1..829
        guides/assets/javascripts/@hotwired--turbo.js on lines 5..3938

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

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

          var INTERNAL = {
            message_types: {
              welcome: "welcome",
              disconnect: "disconnect",
              ping: "ping",
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 2 hrs to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 112..128
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 114..130

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

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

          var logger = {
            log(...messages) {
              if (this.enabled) {
                messages.push(Date.now());
                adapters.logger.log("[ActionCable]", ...messages);
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 1 hr to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 10..17
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 6..13

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

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

          const extend = function(object, properties) {
            if (properties != null) {
              for (let key in properties) {
                const value = properties[key];
                object[key] = value;
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 1 hr to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 301..309
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 310..318

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

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

          function getConfig(name) {
            const element = document.head.querySelector(`meta[name='action-cable-${name}']`);
            if (element) {
              return element.getAttribute("content");
            }
        Severity: Major
        Found in actioncable/app/assets/javascripts/actioncable.js and 3 other locations - About 1 hr to fix
        actioncable/app/assets/javascripts/action_cable.js on lines 489..494
        actioncable/app/assets/javascripts/actioncable.esm.js on lines 505..510
        actioncable/app/javascript/action_cable/index.js on lines 28..33

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

        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

        There are no issues that match your filters.

        Category
        Status