aullman/opentok-editor

View on GitHub

Showing 59 of 59 total issues

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

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 src/opentok-editor.js and 1 other location - About 3 hrs to fix
opentok-editor.js on lines 2032..2042

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

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

      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

      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 src/opentok-adapter.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

          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

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

                var OpenTokAdapter = (function () {
                  'use strict';
                
                  function OpenTokAdapter (session, revision, doc, operations) {
                    OT.$.eventing(this);
                Severity: Minor
                Found in src/opentok-adapter.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 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 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 src/opentok-adapter.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language