wikimedia/mediawiki-extensions-UniversalLanguageSelector

View on GitHub
lib/rangy/rangy-core.js

Summary

Maintainability
F
2 wks
Test Coverage

File rangy-core.js has 2914 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Rangy, a cross-browser JavaScript range and selection library
 * https://github.com/timdown/rangy
 *
 * Copyright 2015, Tim Down
Severity: Major
Found in lib/rangy/rangy-core.js - About 1 wk to fix

    Function createPrototypeRange has 195 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function createPrototypeRange(constructor, boundaryUpdater) {
                function createBeforeAfterNodeSetter(isBefore, isStart) {
                    return function(node) {
                        assertValidNodeType(node, beforeAfterNodeTypes);
                        assertValidNodeType(getRootContainer(node), rootContainerNodeTypes);
    Severity: Major
    Found in lib/rangy/rangy-core.js - About 7 hrs to fix

      Function normalizeBoundaries has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                      normalizeBoundaries: function() {
                          assertRangeValid(this);
      
                          var sc = this.startContainer, so = this.startOffset, ec = this.endContainer, eo = this.endOffset;
      
      
      Severity: Major
      Found in lib/rangy/rangy-core.js - About 3 hrs to fix

        Function getTextRangeBoundaryPosition has 83 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    var getTextRangeBoundaryPosition = function(textRange, wholeRangeContainerElement, isStart, isCollapsed, startInfo) {
                        var workingRange = textRange.duplicate();
                        workingRange.collapse(isStart);
                        var containerElement = workingRange.parentElement();
        
        
        Severity: Major
        Found in lib/rangy/rangy-core.js - About 3 hrs to fix

          Function init has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function init() {
                  if (!isBrowser || api.initialized) {
                      return;
                  }
                  var testRange;
          Severity: Minor
          Found in lib/rangy/rangy-core.js - About 1 hr to fix

            Function addRange has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                            selProto.addRange = function(range, direction) {
                                if (implementsControlRange && implementsDocSelection && this.docSelection.type == CONTROL) {
                                    addRangeToControlSelection(this, range);
                                } else {
                                    if (isDirectionBackward(direction) && selectionHasExtend) {
            Severity: Minor
            Found in lib/rangy/rangy-core.js - About 1 hr to fix

              Function comparePoints has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      function comparePoints(nodeA, offsetA, nodeB, offsetB) {
                          // See http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Comparing
                          var nodeC, root, childA, childB, n;
                          if (nodeA == nodeB) {
                              // Case 1: nodes are the same
              Severity: Minor
              Found in lib/rangy/rangy-core.js - About 1 hr to fix

                Function moveToBookmark has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                            moveToBookmark: function(bookmark) {
                                var containerNode = bookmark.containerNode;
                                var charIndex = 0;
                                this.setStart(containerNode, 0);
                                this.collapse(true);
                Severity: Minor
                Found in lib/rangy/rangy-core.js - About 1 hr to fix

                  Function createBoundaryTextRange has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                              var createBoundaryTextRange = function(boundaryPosition, isStart) {
                                  var boundaryNode, boundaryParent, boundaryOffset = boundaryPosition.offset;
                                  var doc = dom.getDocument(boundaryPosition.node);
                                  var workingNode, childNodes, workingRange = getBody(doc).createTextRange();
                                  var nodeIsDataNode = isCharacterDataNode(boundaryPosition.node);
                  Severity: Minor
                  Found in lib/rangy/rangy-core.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                    if (comparison == -1 && boundaryNode && isCharacterDataNode(boundaryNode)) {
                                        // This is a character data node (text, comment, cdata). The working range is collapsed at the start of
                                        // the node containing the text range's boundary, so we move the end of the working range to the
                                        // boundary point and measure the length of its text to get the boundary's offset within the node.
                                        workingRange.setEndPoint(isStart ? "EndToStart" : "EndToEnd", textRange);
                    Severity: Major
                    Found in lib/rangy/rangy-core.js - About 1 hr to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for (var i = 0, len = sel.rangeCount; i < len; ++i) {
                                                  sel._ranges[i] = new api.WrappedRange(sel.nativeSelection.getRangeAt(i));
                                              }
                      Severity: Major
                      Found in lib/rangy/rangy-core.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (selectionSupportsMultipleRanges) {
                                                        previousRangeCount = this.rangeCount;
                                                    } else {
                                                        this.removeAllRanges();
                                                        previousRangeCount = 0;
                        Severity: Major
                        Found in lib/rangy/rangy-core.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                              if (ec == sibling) {
                                                                  ec = sc;
                                                                  eo += sc.length;
                                                              }
                          Severity: Major
                          Found in lib/rangy/rangy-core.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                        if (addRangeBackwardToNative) {
                                                            addRangeBackwardToNative(sel, originalSelectionRanges[i]);
                                                        } else {
                                                            api.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because the browser does not support Selection.extend");
                                                            sel.addRange(originalSelectionRanges[i]);
                            Severity: Major
                            Found in lib/rangy/rangy-core.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                          if (controlRange.length) {
                                                              doc = getDocument( controlRange.item(0) );
                                                          }
                              Severity: Major
                              Found in lib/rangy/rangy-core.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                            if (this.rangeCount == previousRangeCount + 1) {
                                                                // The range was added successfully
                                
                                                                // Check whether the range that we added to the selection is reflected in the last range extracted from
                                                                // the selection
                                Severity: Major
                                Found in lib/rangy/rangy-core.js - About 45 mins to fix

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

                                                  function updateNativeRange(range, startContainer, startOffset, endContainer, endOffset) {
                                  Severity: Minor
                                  Found in lib/rangy/rangy-core.js - About 35 mins to fix

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

                                                var getTextRangeBoundaryPosition = function(textRange, wholeRangeContainerElement, isStart, isCollapsed, startInfo) {
                                    Severity: Minor
                                    Found in lib/rangy/rangy-core.js - About 35 mins to fix

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

                                              function updateBoundaries(range, startContainer, startOffset, endContainer, endOffset) {
                                      Severity: Minor
                                      Found in lib/rangy/rangy-core.js - About 35 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                                    return 1;
                                        Severity: Major
                                        Found in lib/rangy/rangy-core.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      return node.nodeName;
                                          Severity: Major
                                          Found in lib/rangy/rangy-core.js - About 30 mins to fix

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

                                                        canSurroundContents: function() {
                                                            assertRangeValid(this);
                                                            assertNodeNotReadOnly(this.startContainer);
                                                            assertNodeNotReadOnly(this.endContainer);
                                            
                                            
                                            Severity: Major
                                            Found in lib/rangy/rangy-core.js and 1 other location - About 4 hrs to fix
                                            lib/rangy/rangy-core.js on lines 2008..2020

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

                                            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

                                                            canSurroundContents: function() {
                                                                assertRangeValid(this);
                                                                assertNodeNotReadOnly(this.startContainer);
                                                                assertNodeNotReadOnly(this.endContainer);
                                            
                                            
                                            Severity: Major
                                            Found in lib/rangy/rangy-core.js and 1 other location - About 4 hrs to fix
                                            lib/rangy/rangy-core.js on lines 1538..1550

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

                                            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

                                                                rangeProto.setStart = function(node, offset) {
                                                                    try {
                                                                        this.nativeRange.setStart(node, offset);
                                                                    } catch (ex) {
                                                                        this.nativeRange.setEnd(node, offset);
                                            Severity: Major
                                            Found in lib/rangy/rangy-core.js and 1 other location - About 2 hrs to fix
                                            lib/rangy/rangy-core.js on lines 2327..2335

                                            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

                                                                rangeProto.setEnd = function(node, offset) {
                                                                    try {
                                                                        this.nativeRange.setEnd(node, offset);
                                                                    } catch (ex) {
                                                                        this.nativeRange.setStart(node, offset);
                                            Severity: Major
                                            Found in lib/rangy/rangy-core.js and 1 other location - About 2 hrs to fix
                                            lib/rangy/rangy-core.js on lines 2317..2325

                                            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

                                                    function getIframeWindow(iframeEl) {
                                                        if (typeof iframeEl.contentWindow != UNDEF) {
                                                            return iframeEl.contentWindow;
                                                        } else if (typeof iframeEl.contentDocument != UNDEF) {
                                                            return iframeEl.contentDocument.defaultView;
                                            Severity: Major
                                            Found in lib/rangy/rangy-core.js and 1 other location - About 1 hr to fix
                                            lib/rangy/rangy-core.js on lines 666..674

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

                                            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

                                                    function getIframeDocument(iframeEl) {
                                                        if (typeof iframeEl.contentDocument != UNDEF) {
                                                            return iframeEl.contentDocument;
                                                        } else if (typeof iframeEl.contentWindow != UNDEF) {
                                                            return iframeEl.contentWindow.document;
                                            Severity: Major
                                            Found in lib/rangy/rangy-core.js and 1 other location - About 1 hr to fix
                                            lib/rangy/rangy-core.js on lines 676..684

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

                                            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