Semantic-Org/Semantic-UI

View on GitHub
examples/assets/library/iframe.js

Summary

Maintainability
F
6 days
Test Coverage

File iframe.js has 837 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * File: iframeResizer.js
 * Desc: Force iframes to size to content.
 * Requires: iframeResizer.contentWindow.js to be loaded into the target frame.
 * Doc: https://github.com/davidjbradshaw/iframe-resizer
Severity: Major
Found in examples/assets/library/iframe.js - About 2 days to fix

    Function iFrameListener has 318 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function iFrameListener(event) {
        function resizeIFrame() {
          function resize() {
            setSize(messageData);
            setPagePosition(iframeId);
    Severity: Major
    Found in examples/assets/library/iframe.js - About 1 day to fix

      Function setupIFrame has 129 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function setupIFrame(iframe,options) {
          function setLimits() {
            function addStyle(style) {
              if ((Infinity !== settings[iframeId][style]) && (0 !== settings[iframeId][style])) {
                iframe.style[style] = settings[iframeId][style] + 'px';
      Severity: Major
      Found in examples/assets/library/iframe.js - About 5 hrs to fix

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

          function factory() {
            function init(options,element) {
              function chkType() {
                if(!element.tagName) {
                  throw new TypeError('Object is not a valid DOM element');
        Severity: Minor
        Found in examples/assets/library/iframe.js - About 1 hr to fix

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

            function fixHiddenIFrames() {
              function checkIFrames() {
                function checkIFrame(settingId) {
                  function chkDimension(dimension) {
                    return '0px' === (settings[settingId] && settings[settingId].iframe.style[dimension]);
          Severity: Minor
          Found in examples/assets/library/iframe.js - About 1 hr to fix

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

                function actionMsg() {
            
                  if(settings[iframeId] && settings[iframeId].firstRun) firstRun();
            
                  switch(messageData.type) {
            Severity: Minor
            Found in examples/assets/library/iframe.js - About 1 hr to fix

              Function isMessageFromIFrame has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function isMessageFromIFrame() {
                    function checkAllowedOrigin() {
                      function checkList() {
                        var
                          i = 0,
              Severity: Minor
              Found in examples/assets/library/iframe.js - About 1 hr to fix

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

                  function trigger(calleeMsg, msg, iframe, id, noResponseWarning) {
                    function postMessageToIFrame() {
                      var target = settings[id] && settings[id].targetOrigin;
                      log(id,'[' + calleeMsg + '] Sending msg to iframe['+id+'] ('+msg+') targetOrigin: '+target);
                      iframe.contentWindow.postMessage( msgId + msg, target );
                Severity: Minor
                Found in examples/assets/library/iframe.js - About 1 hr to fix

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

                      function findTarget(location) {
                        function jumpToTarget() {
                          var jumpPosition = getElementPosition(target);
                  
                          log(iframeId,'Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y);
                  Severity: Minor
                  Found in examples/assets/library/iframe.js - About 1 hr to fix

                    Function scrollRequestFromChild has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function scrollRequestFromChild(addOffset) {
                          /* istanbul ignore next */  //Not testable in Karma
                          function reposition() {
                            pagePosition = newPosition;
                            scrollTo();
                    Severity: Minor
                    Found in examples/assets/library/iframe.js - About 1 hr to fix

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

                        function trigger(calleeMsg, msg, iframe, id, noResponseWarning) {
                      Severity: Minor
                      Found in examples/assets/library/iframe.js - About 35 mins to fix

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

                          function addEventListener(obj,evt,func) {
                            /* istanbul ignore else */ // Not testable in PhantonJS
                            if ('addEventListener' in window) {
                              obj.addEventListener(evt,func, false);
                            } else if ('attachEvent' in window) {//IE
                        Severity: Major
                        Found in examples/assets/library/iframe.js and 3 other locations - About 1 hr to fix
                        examples/assets/library/iframe-content.js on lines 72..79
                        examples/assets/library/iframe-content.js on lines 81..88
                        examples/assets/library/iframe.js on lines 72..79

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

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

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

                          function removeEventListener(el,evt,func) {
                            /* istanbul ignore else */ // Not testable in phantonJS
                            if ('removeEventListener' in window) {
                              el.removeEventListener(evt,func, false);
                            } else if ('detachEvent' in window) { //IE
                        Severity: Major
                        Found in examples/assets/library/iframe.js and 3 other locations - About 1 hr to fix
                        examples/assets/library/iframe-content.js on lines 72..79
                        examples/assets/library/iframe-content.js on lines 81..88
                        examples/assets/library/iframe.js on lines 63..70

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

                        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

                              pagePosition = {
                                x: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft,
                                y: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop
                              };
                        Severity: Major
                        Found in examples/assets/library/iframe.js and 1 other location - About 1 hr to fix
                        examples/assets/library/iframe-content.js on lines 390..393

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

                        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