aullman/opentok-editor

View on GitHub

Showing 59 of 59 total issues

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

      Function exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(config) {
        config.set({
      
          // base path that will be used to resolve all patterns (eg. files, exclude)
          basePath: '',
      Severity: Minor
      Found in karma.conf.js - About 1 hr to fix

        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

        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

                    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 src/opentok-editor.js and 3 other locations - About 30 mins to fix
                    src/opentok-adapter.js on lines 2..6
                    opentok-editor.js on lines 1938..1942
                    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

                    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 src/opentok-adapter.js and 3 other locations - About 30 mins to fix
                    src/opentok-editor.js on lines 2..6
                    opentok-editor.js on lines 1938..1942
                    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

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

                          Severity
                          Category
                          Status
                          Source
                          Language