JamesChevalier/Little-Corner

View on GitHub
app/assets/javascripts/lightbox.js

Summary

Maintainability
D
1 day
Test Coverage

File lightbox.js has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Open


/*
Lightbox v2.51
by Lokesh Dhakar - http://www.lokeshdhakar.com

Severity: Minor
Found in app/assets/javascripts/lightbox.js - About 2 hrs to fix

    Function build has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        Lightbox.prototype.build = function() {
          var $lightbox,
            _this = this;
          $("<div>", {
            id: 'lightboxOverlay'
    Severity: Major
    Found in app/assets/javascripts/lightbox.js - About 2 hrs to fix

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

          Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) {
            var $container, $lightbox, $outerContainer, containerBottomPadding, containerLeftPadding, containerRightPadding, containerTopPadding, newHeight, newWidth, oldHeight, oldWidth,
              _this = this;
            $lightbox = $('#lightbox');
            $outerContainer = $lightbox.find('.lb-outerContainer');
      Severity: Minor
      Found in app/assets/javascripts/lightbox.js - About 1 hr to fix

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

            Lightbox.prototype.start = function($link) {
              var $lightbox, $window, a, i, imageNumber, left, top, _len, _ref;
              $(window).on("resize", this.sizeOverlay);
              $('select, object, embed').css({
                visibility: "hidden"
        Severity: Minor
        Found in app/assets/javascripts/lightbox.js - About 1 hr to fix

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

                })), $('<div/>', {
                  "class": 'lb-loader'
                }).append($('<a/>', {
                  "class": 'lb-cancel'
                }).append($('<img/>', {
          Severity: Major
          Found in app/assets/javascripts/lightbox.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/lightbox.js on lines 120..126

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

          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

                })), $('<div/>', {
                  "class": 'lb-closeContainer'
                }).append($('<a/>', {
                  "class": 'lb-close'
                }).append($('<img/>', {
          Severity: Major
          Found in app/assets/javascripts/lightbox.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/lightbox.js on lines 104..110

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

          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

                $lightbox.find('.lb-prev').on('click', function(e) {
                  _this.changeImage(_this.currentImageIndex - 1);
                  return false;
                });
          Severity: Minor
          Found in app/assets/javascripts/lightbox.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/lightbox.js on lines 144..147

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

          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

                $lightbox.find('.lb-next').on('click', function(e) {
                  _this.changeImage(_this.currentImageIndex + 1);
                  return false;
                });
          Severity: Minor
          Found in app/assets/javascripts/lightbox.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/lightbox.js on lines 140..143

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

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

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

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

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

          Refactorings

          Further Reading

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

                $lightbox.hide().on('click', function(e) {
                  if ($(e.target).attr('id') === 'lightbox') _this.end();
                  return false;
                });
          Severity: Minor
          Found in app/assets/javascripts/lightbox.js and 1 other location - About 35 mins to fix
          app/assets/javascripts/lightbox.js on lines 136..139

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

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

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

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

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

          Refactorings

          Further Reading

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

                $lightbox.find('.lb-outerContainer').on('click', function(e) {
                  if ($(e.target).attr('id') === 'lightbox') _this.end();
                  return false;
                });
          Severity: Minor
          Found in app/assets/javascripts/lightbox.js and 1 other location - About 35 mins to fix
          app/assets/javascripts/lightbox.js on lines 132..135

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

          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 (this.album.length > this.currentImageIndex + 1) {
                  preloadNext = new Image;
                  preloadNext.src = this.album[this.currentImageIndex + 1].link;
                }
          Severity: Minor
          Found in app/assets/javascripts/lightbox.js and 1 other location - About 30 mins to fix
          app/assets/javascripts/lightbox.js on lines 297..300

          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 2 locations. Consider refactoring.
          Open

                if (this.currentImageIndex > 0) {
                  preloadPrev = new Image;
                  preloadPrev.src = this.album[this.currentImageIndex - 1].link;
                }
          Severity: Minor
          Found in app/assets/javascripts/lightbox.js and 1 other location - About 30 mins to fix
          app/assets/javascripts/lightbox.js on lines 293..296

          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

          There are no issues that match your filters.

          Category
          Status