concord-consortium/lara

View on GitHub
app/assets/javascripts/jquery.colorbox.js

Summary

Maintainability
F
1 wk
Test Coverage

File jquery.colorbox.js has 862 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*jslint browser: true, sloppy: true, todo: true, devel: true, white: true */
/*global $ */
/* [CC] This file has been modified substantially from its original version,
    so updating to a newer version of the library would be non-trivial. */
/*!
Severity: Major
Found in app/assets/javascripts/jquery.colorbox.js - About 2 days to fix

    Function load has 148 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function load () {
            var href, setResize, prep = publicMethod.prep, $inline, request = ++requests;
    
            active = true;
    
    
    Severity: Major
    Found in app/assets/javascripts/jquery.colorbox.js - About 5 hrs to fix

      Function prep has 121 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          publicMethod.prep = function (object) {
              if (!open) {
                  return;
              }
      
      
      Severity: Major
      Found in app/assets/javascripts/jquery.colorbox.js - About 4 hrs to fix

        Function position has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            publicMethod.position = function (speed, loadedCallback) {
                var
                css,
                top = 0,
                left = 0,
        Severity: Major
        Found in app/assets/javascripts/jquery.colorbox.js - About 2 hrs to fix

          Function launch has 69 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function launch(target) {
                  if (!closing) {
          
                      element = target;
          
          
          Severity: Major
          Found in app/assets/javascripts/jquery.colorbox.js - About 2 hrs to fix

            Function slideshow has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var slideshow = (function(){
                    var active,
                        className = prefix + "Slideshow_",
                        click = "click." + prefix,
                        timeOut;
            Severity: Major
            Found in app/assets/javascripts/jquery.colorbox.js - About 2 hrs to fix

              Function addBindings has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function addBindings() {
                      function clickHandler(e) {
                          // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt.
                          // See: http://jacklmoore.com/notes/click-events/
                          if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) {
              Severity: Minor
              Found in app/assets/javascripts/jquery.colorbox.js - About 1 hr to fix

                Function appendHTML has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function appendHTML() {
                        if (!$box && document.body) {
                            init = false;
                            $window = $(window);
                            $box = $tag(div).attr({
                Severity: Minor
                Found in app/assets/javascripts/jquery.colorbox.js - About 1 hr to fix

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

                      publicMethod.resize = function (options) {
                          var scrolltop;
                  
                          if (open) {
                              options = options || {};
                  Severity: Minor
                  Found in app/assets/javascripts/jquery.colorbox.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if (settings.maxw && (photo.width * percent) > settings.maxw) {
                                                    // Get a better percent
                                                    percent = settings.maxw / photo.width;
                                                }
                    Severity: Major
                    Found in app/assets/javascripts/jquery.colorbox.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if (settings.maxh && (photo.height * percent) > settings.maxh) {
                                                      // Get a better percent
                                                      percent = settings.maxh / photo.height;
                                                  }
                      Severity: Major
                      Found in app/assets/javascripts/jquery.colorbox.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                } else if (settings.maxw && photo.width < settings.maxw) {
                                                    // Expand photo to the max width
                                                    percent = settings.maxw / photo.width;
                                                    // Validate that we aren't over height
                                                    if (settings.maxh && (photo.height * percent) > settings.maxh) {
                        Severity: Major
                        Found in app/assets/javascripts/jquery.colorbox.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  } else if (settings.maxh && photo.height < settings.maxh) {
                                                      // Expand to the max height
                                                      percent = settings.maxh / photo.height;
                                                      // Validate that we aren't over width
                                                      if (settings.maxw && (photo.width * percent) > settings.maxw) {
                          Severity: Major
                          Found in app/assets/javascripts/jquery.colorbox.js - About 45 mins to fix

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

                                                    if (settings.maxw && photo.width > settings.maxw) {
                                                        // Reduce to the max width || max height
                                                        percent = (photo.width - settings.maxw) / photo.width;
                                                        if (photo.height - (photo.height * percent) > settings.maxh) {
                                                            // Still too big, do it by height
                            Severity: Major
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 1 day to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 1032..1058

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

                            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

                                                    if (settings.maxh && photo.height > settings.maxh) {
                                                        // Reduce to the max width || max height
                                                        percent = (photo.height - settings.maxh) / photo.height;
                                                        if (photo.width - (photo.width * percent) > settings.maxw) {
                                                            // Still too wide, use maxw
                            Severity: Major
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 1 day to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 1004..1030

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

                            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 getHeight() {
                                        settings.h = settings.h || $loaded.height();
                                        settings.h = settings.minh && settings.minh > settings.h ? settings.minh : settings.h;
                                        settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
                                        return settings.h;
                            Severity: Major
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 4 hrs to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 745..750

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

                            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 getWidth() {
                                        settings.w = settings.w || $loaded.width();
                                        settings.w = settings.minw && settings.minw > settings.w ? settings.minw : settings.w;
                                        settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
                                        return settings.w;
                            Severity: Major
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 4 hrs to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 751..756

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

                            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

                                    if (settings.minWidth) {
                                        settings.minw = setSize(settings.minWidth, 'x') - loadedWidth - interfaceWidth;
                                        settings.minw = settings.w && settings.w > settings.minw ? settings.w : settings.minw;
                                    }
                            Severity: Major
                            Found in app/assets/javascripts/jquery.colorbox.js and 2 other locations - About 2 hrs to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 929..932
                            app/assets/javascripts/jquery.colorbox.js on lines 933..936

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

                            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

                                    if (settings.maxHeight) {
                                        settings.maxh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
                                        settings.maxh = settings.h && settings.h < settings.maxh ? settings.h : settings.maxh;
                                    }
                            Severity: Major
                            Found in app/assets/javascripts/jquery.colorbox.js and 2 other locations - About 2 hrs to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 925..928
                            app/assets/javascripts/jquery.colorbox.js on lines 933..936

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

                            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

                                    if (settings.minHeight) {
                                        settings.minh = setSize(settings.minHeight, 'y') - loadedHeight - interfaceHeight;
                                        settings.minh = settings.h && settings.h > settings.minh ? settings.h : settings.minh;
                                    }
                            Severity: Major
                            Found in app/assets/javascripts/jquery.colorbox.js and 2 other locations - About 2 hrs to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 925..928
                            app/assets/javascripts/jquery.colorbox.js on lines 929..932

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

                            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

                                        $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = (parseInt($box[0].style.width,10) - interfaceWidth)+'px';
                            Severity: Major
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 2 hrs to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 643..643

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

                            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

                                        $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = (parseInt($box[0].style.height,10) - interfaceHeight)+'px';
                            Severity: Major
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 2 hrs to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 642..642

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

                            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

                                    settings.w = settings.width ?
                                            setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
                                            settings.innerWidth && setSize(settings.innerWidth, 'x');
                            Severity: Minor
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 55 mins to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 903..905

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

                            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

                                    settings.h = settings.height ?
                                            setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
                                            settings.innerHeight && setSize(settings.innerHeight, 'y');
                            Severity: Minor
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 55 mins to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 907..909

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

                            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

                                            interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();
                            Severity: Minor
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 35 mins to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 388..388

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

                            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

                                            interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
                            Severity: Minor
                            Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 35 mins to fix
                            app/assets/javascripts/jquery.colorbox.js on lines 387..387

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

                            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