aullman/opentok-editor

View on GitHub
opentok-editor.js

Summary

Maintainability
F
1 mo
Test Coverage

File opentok-editor.js has 1662 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 *    /\
 *   /  \ ot 0.0.15
 *  /    \ http://operational-transformation.github.com
 *  \    /
Severity: Major
Found in opentok-editor.js - About 4 days to fix

    Function TextOperation has a Cognitive Complexity of 207 (exceeds 5 allowed). Consider refactoring.
    Open

    ot.TextOperation = (function () {
      'use strict';
    
      // Constructor for new operations.
      function TextOperation () {
    Severity: Minor
    Found in opentok-editor.js - About 4 days 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 TextOperation has 393 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ot.TextOperation = (function () {
      'use strict';
    
      // Constructor for new operations.
      function TextOperation () {
    Severity: Major
    Found in opentok-editor.js - About 1 day to fix

      Function EditorClient has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
      Open

      ot.EditorClient = (function () {
        'use strict';
      
        var Client = ot.Client;
        var Selection = ot.Selection;
      Severity: Minor
      Found in opentok-editor.js - About 1 day 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 EditorClient has 273 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ot.EditorClient = (function () {
        'use strict';
      
        var Client = ot.Client;
        var Selection = ot.Selection;
      Severity: Major
      Found in opentok-editor.js - About 1 day to fix

        Function CodeMirrorAdapter has 257 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ot.CodeMirrorAdapter = (function (global) {
          'use strict';
        
          var TextOperation = ot.TextOperation;
          var Selection = ot.Selection;
        Severity: Major
        Found in opentok-editor.js - About 1 day to fix

          Function CodeMirrorAdapter has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
          Open

          ot.CodeMirrorAdapter = (function (global) {
            'use strict';
          
            var TextOperation = ot.TextOperation;
            var Selection = ot.Selection;
          Severity: Minor
          Found in opentok-editor.js - About 1 day 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 Selection has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

          ot.Selection = (function (global) {
            'use strict';
          
            var TextOperation = global.ot ? global.ot.TextOperation : require('./text-operation');
          
          
          Severity: Minor
          Found in opentok-editor.js - About 5 hrs 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 AjaxAdapter has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

          ot.AjaxAdapter = (function () {
            'use strict';
          
            function AjaxAdapter (path, ownUserName, revision) {
              if (path[path.length - 1] !== '/') { path += '/'; }
          Severity: Minor
          Found in opentok-editor.js - About 4 hrs 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 link has 103 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                link: function (scope, element, attrs) {
                  var opentokEditor = element.context.querySelector('div.opentok-editor'),
                      modeSelect = element.context.querySelector('select'),
                      myCodeMirror,
                      cmClient,
          Severity: Major
          Found in opentok-editor.js - About 4 hrs to fix

            Function AjaxAdapter has 98 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ot.AjaxAdapter = (function () {
              'use strict';
            
              function AjaxAdapter (path, ownUserName, revision) {
                if (path[path.length - 1] !== '/') { path += '/'; }
            Severity: Major
            Found in opentok-editor.js - About 3 hrs to fix

              Function Client has 93 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ot.Client = (function (global) {
                'use strict';
              
                // Client constructor
                function Client (revision) {
              Severity: Major
              Found in opentok-editor.js - About 3 hrs to fix

                Function transform has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  TextOperation.transform = function (operation1, operation2) {
                    if (operation1.baseLength !== operation2.baseLength) {
                      throw new Error("Both operations have to have the same base length");
                    }
                
                
                Severity: Major
                Found in opentok-editor.js - About 3 hrs to fix

                  Function compose has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    TextOperation.prototype.compose = function (operation2) {
                      var operation1 = this;
                      if (operation1.targetLength !== operation2.baseLength) {
                        throw new Error("The base length of the second operation has to be the target length of the first operation");
                      }
                  Severity: Major
                  Found in opentok-editor.js - About 3 hrs to fix

                    Function UndoManager has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                    ot.UndoManager = (function () {
                      'use strict';
                    
                      var NORMAL_STATE = 'normal';
                      var UNDOING_STATE = 'undoing';
                    Severity: Minor
                    Found in opentok-editor.js - About 3 hrs 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 Selection has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    ot.Selection = (function (global) {
                      'use strict';
                    
                      var TextOperation = global.ot ? global.ot.TextOperation : require('./text-operation');
                    
                    
                    Severity: Major
                    Found in opentok-editor.js - About 3 hrs to fix

                      Function UndoManager has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ot.UndoManager = (function () {
                        'use strict';
                      
                        var NORMAL_STATE = 'normal';
                        var UNDOING_STATE = 'undoing';
                      Severity: Major
                      Found in opentok-editor.js - About 2 hrs to fix

                        Function OpenTokAdapter has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        var OpenTokAdapter = (function () {
                          'use strict';
                        
                          function OpenTokAdapter (session, revision, doc, operations) {
                            OT.$.eventing(this);
                        Severity: Major
                        Found in opentok-editor.js - About 2 hrs to fix

                          Function WrappedOperation has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                          Open

                          ot.WrappedOperation = (function (global) {
                            'use strict';
                          
                            // A WrappedOperation contains an operation and corresponing metadata.
                            function WrappedOperation (operation, meta) {
                          Severity: Minor
                          Found in opentok-editor.js - About 2 hrs 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 EditorClient has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function EditorClient (revision, clients, serverAdapter, editorAdapter) {
                              Client.call(this, revision);
                              this.serverAdapter = serverAdapter;
                              this.editorAdapter = editorAdapter;
                              this.undoManager = new UndoManager();
                          Severity: Major
                          Found in opentok-editor.js - About 2 hrs to fix

                            Function WrappedOperation has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            ot.WrappedOperation = (function (global) {
                              'use strict';
                            
                              // A WrappedOperation contains an operation and corresponing metadata.
                              function WrappedOperation (operation, meta) {
                            Severity: Major
                            Found in opentok-editor.js - About 2 hrs to fix

                              Function operationFromCodeMirrorChanges has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                CodeMirrorAdapter.operationFromCodeMirrorChanges = function (changes, doc) {
                                  // Approach: Replay the changes, beginning with the most recent one, and
                                  // construct the operation and its inverse. We have to convert the position
                                  // in the pre-change coordinate system to an index. We have a method to
                                  // convert a position in the coordinate system after all changes to an index,
                              Severity: Major
                              Found in opentok-editor.js - About 2 hrs to fix

                                Function OpenTokAdapter has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  function OpenTokAdapter (session, revision, doc, operations) {
                                    OT.$.eventing(this);
                                    this.registerCallbacks = this.on;
                                    this.session = session;
                                
                                
                                Severity: Minor
                                Found in opentok-editor.js - About 1 hr to fix

                                  Function OpenTokAdapter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  var OpenTokAdapter = (function () {
                                    'use strict';
                                  
                                    function OpenTokAdapter (session, revision, doc, operations) {
                                      OT.$.eventing(this);
                                  Severity: Minor
                                  Found in opentok-editor.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 SocketIOAdapter has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  ot.SocketIOAdapter = (function () {
                                    'use strict';
                                  
                                    function SocketIOAdapter (socket) {
                                      this.socket = socket;
                                  Severity: Minor
                                  Found in opentok-editor.js - About 1 hr to fix

                                    Function handleResponse has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      AjaxAdapter.prototype.handleResponse = function (data) {
                                        var i;
                                        var operations = data.operations;
                                        for (i = 0; i < operations.length; i++) {
                                          if (operations[i].user === this.ownUserName) {
                                    Severity: Minor
                                    Found in opentok-editor.js - About 1 hr to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                            } else if (isRetain(op1) && isDelete(op2)) {
                                              if (op1 > -op2) {
                                                minl = -op2;
                                                op1 = op1 + op2;
                                                op2 = ops2[i2++];
                                      Severity: Major
                                      Found in opentok-editor.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                              } else if (isRetain(op1) && isDelete(op2)) {
                                                if (op1 > -op2) {
                                                  operation['delete'](op2);
                                                  op1 = op1 + op2;
                                                  op2 = ops2[i2++];
                                        Severity: Major
                                        Found in opentok-editor.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                  if (op1.length > op2) {
                                                    operation.insert(op1.slice(0, op2));
                                                    op1 = op1.slice(op2);
                                                    op2 = ops2[i2++];
                                                  } else if (op1.length === op2) {
                                          Severity: Major
                                          Found in opentok-editor.js - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                    if (-op1 > op2) {
                                                      minl = op2;
                                                      op1 = op1 + op2;
                                                      op2 = ops2[i2++];
                                                    } else if (-op1 === op2) {
                                            Severity: Major
                                            Found in opentok-editor.js - About 45 mins to fix

                                              Function OtherClient has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                function OtherClient (id, listEl, editorAdapter, name, selection) {
                                              Severity: Minor
                                              Found in opentok-editor.js - About 35 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                    return true;
                                                Severity: Major
                                                Found in opentok-editor.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                      return false;
                                                  Severity: Major
                                                  Found in opentok-editor.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                        return false;
                                                    Severity: Major
                                                    Found in opentok-editor.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                          return 0;
                                                      Severity: Major
                                                      Found in opentok-editor.js - About 30 mins to fix

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

                                                        (function () {
                                                          // Turns the Array of operation Objects into an Array of JSON stringifyable objects
                                                          var serialiseOps = function (operations) {
                                                            return operations.map(function (op) {
                                                              return {
                                                        Severity: Major
                                                        Found in opentok-editor.js and 1 other location - About 1 wk to fix
                                                        src/opentok-editor.js on lines 23..177

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

                                                        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

                                                        var OpenTokAdapter = (function () {
                                                          'use strict';
                                                        
                                                          function OpenTokAdapter (session, revision, doc, operations) {
                                                            OT.$.eventing(this);
                                                        Severity: Major
                                                        Found in opentok-editor.js and 1 other location - About 4 days to fix
                                                        src/opentok-adapter.js on lines 8..84

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

                                                        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

                                                        if (typeof ot === 'undefined' && typeof require !== 'undefined') {
                                                          // fixme: We have to make this a global because CodeMirrorAdapter and EditorClient
                                                          // attach themselves to the global ot
                                                          window.ot = require('ot');
                                                          ot.UndoManager = require('ot/lib/undo-manager.js');
                                                        Severity: Major
                                                        Found in opentok-editor.js and 1 other location - About 3 hrs to fix
                                                        src/opentok-editor.js on lines 7..17

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

                                                        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

                                                          CodeMirrorAdapter.prototype.trigger = function (event) {
                                                            var args = Array.prototype.slice.call(arguments, 1);
                                                            var action = this.callbacks && this.callbacks[event];
                                                            if (action) { action.apply(this, args); }
                                                          };
                                                        Severity: Major
                                                        Found in opentok-editor.js and 2 other locations - About 2 hrs to fix
                                                        opentok-editor.js on lines 1431..1435
                                                        opentok-editor.js on lines 1547..1551

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

                                                        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

                                                          AjaxAdapter.prototype.trigger = function (event) {
                                                            var args = Array.prototype.slice.call(arguments, 1);
                                                            var action = this.callbacks && this.callbacks[event];
                                                            if (action) { action.apply(this, args); }
                                                          };
                                                        Severity: Major
                                                        Found in opentok-editor.js and 2 other locations - About 2 hrs to fix
                                                        opentok-editor.js on lines 1348..1352
                                                        opentok-editor.js on lines 1431..1435

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

                                                        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

                                                          SocketIOAdapter.prototype.trigger = function (event) {
                                                            var args = Array.prototype.slice.call(arguments, 1);
                                                            var action = this.callbacks && this.callbacks[event];
                                                            if (action) { action.apply(this, args); }
                                                          };
                                                        Severity: Major
                                                        Found in opentok-editor.js and 2 other locations - About 2 hrs to fix
                                                        opentok-editor.js on lines 1348..1352
                                                        opentok-editor.js on lines 1547..1551

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

                                                        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

                                                          UndoManager.prototype.performUndo = function (fn) {
                                                            this.state = UNDOING_STATE;
                                                            if (this.undoStack.length === 0) { throw new Error("undo not possible"); }
                                                            fn(this.undoStack.pop());
                                                            this.state = NORMAL_STATE;
                                                        Severity: Major
                                                        Found in opentok-editor.js and 1 other location - About 2 hrs to fix
                                                        opentok-editor.js on lines 814..819

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

                                                        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

                                                          UndoManager.prototype.performRedo = function (fn) {
                                                            this.state = REDOING_STATE;
                                                            if (this.redoStack.length === 0) { throw new Error("redo not possible"); }
                                                            fn(this.redoStack.pop());
                                                            this.state = NORMAL_STATE;
                                                        Severity: Major
                                                        Found in opentok-editor.js and 1 other location - About 2 hrs to fix
                                                        opentok-editor.js on lines 806..811

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

                                                        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

                                                          EditorClient.prototype.redo = function () {
                                                            var self = this;
                                                            if (!this.undoManager.canRedo()) { return; }
                                                            this.undoManager.performRedo(function (o) { self.applyUnredo(o); });
                                                          };
                                                        Severity: Major
                                                        Found in opentok-editor.js and 1 other location - About 2 hrs to fix
                                                        opentok-editor.js on lines 1784..1788

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

                                                        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

                                                          EditorClient.prototype.undo = function () {
                                                            var self = this;
                                                            if (!this.undoManager.canUndo()) { return; }
                                                            this.undoManager.performUndo(function (o) { self.applyUnredo(o); });
                                                          };
                                                        Severity: Major
                                                        Found in opentok-editor.js and 1 other location - About 2 hrs to fix
                                                        opentok-editor.js on lines 1790..1794

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

                                                        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

                                                              inverse = inverse.compose(new TextOperation()
                                                                .retain(fromIndex)
                                                                ['delete'](sumLengths(change.text))
                                                                .insert(change.removed.join('\n'))
                                                                .retain(restLength)
                                                        Severity: Major
                                                        Found in opentok-editor.js and 1 other location - About 1 hr to fix
                                                        opentok-editor.js on lines 1169..1173

                                                        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

                                                              operation = new TextOperation()
                                                                .retain(fromIndex)
                                                                ['delete'](sumLengths(change.removed))
                                                                .insert(change.text.join('\n'))
                                                                .retain(restLength)
                                                        Severity: Major
                                                        Found in opentok-editor.js and 1 other location - About 1 hr to fix
                                                        opentok-editor.js on lines 1176..1180

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

                                                        if (typeof angular === 'undefined' && typeof require !== 'undefined') {
                                                          ng = require('angular');
                                                        } else {
                                                          ng = angular;
                                                        }
                                                        Severity: Major
                                                        Found in opentok-editor.js and 3 other locations - About 30 mins to fix
                                                        src/opentok-adapter.js on lines 2..6
                                                        src/opentok-editor.js on lines 2..6
                                                        opentok-editor.js on lines 1938..1942

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

                                                        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

                                                        if (typeof ot === 'undefined' && typeof require !== 'undefined') {
                                                          opTrans = require('ot');
                                                        } else {
                                                          opTrans = ot;
                                                        }
                                                        Severity: Major
                                                        Found in opentok-editor.js and 3 other locations - About 30 mins to fix
                                                        src/opentok-adapter.js on lines 2..6
                                                        src/opentok-editor.js on lines 2..6
                                                        opentok-editor.js on lines 2027..2031

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

                                                        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