JamesChevalier/Little-Corner

View on GitHub

Showing 18 of 18 total issues

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

                })), $('<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

          Method index has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              @foursquare_badges      = Rails.cache.fetch('foursquare_badges', expires_in: 12.hours, race_condition_ttl: 10) do
                foursquare_connection = Foursquare2::Client.new(client_id: FOURSQUARE_CLIENT_ID,
                                                                client_secret: FOURSQUARE_CLIENT_SECRET,
                                                                oauth_token: FOURSQUARE_OAUTH_TOKEN,
          Severity: Minor
          Found in app/controllers/foursquare_controller.rb - About 55 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          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

          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

              @timeline  = Rails.cache.fetch('timeline', expires_in: 1.hour, race_condition_ttl: 10) do
                client = Twitter::REST::Client.new do |config|
                  config.consumer_key        = TWITTER_CONSUMER_KEY
                  config.consumer_secret     = TWITTER_CONSUMER_SECRET
                  config.access_token        = TWITTER_ACCESS_TOKEN
          Severity: Minor
          Found in app/controllers/twitter_controller.rb and 1 other location - About 35 mins to fix
          app/controllers/twitter_controller.rb on lines 14..22

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

          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

              @favorites = Rails.cache.fetch('favorites', expires_in: 1.hour, race_condition_ttl: 10) do
                client = Twitter::REST::Client.new do |config|
                  config.consumer_key        = TWITTER_CONSUMER_KEY
                  config.consumer_secret     = TWITTER_CONSUMER_SECRET
                  config.access_token        = TWITTER_ACCESS_TOKEN
          Severity: Minor
          Found in app/controllers/twitter_controller.rb and 1 other location - About 35 mins to fix
          app/controllers/twitter_controller.rb on lines 4..12

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

          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

          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

          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

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

              @foursquare_mayorships  = Rails.cache.fetch('foursquare_mayorships', expires_in: 12.hours, race_condition_ttl: 10) do
                foursquare_connection = Foursquare2::Client.new(client_id: FOURSQUARE_CLIENT_ID,
                                                                client_secret: FOURSQUARE_CLIENT_SECRET,
                                                                oauth_token: FOURSQUARE_OAUTH_TOKEN,
                                                                api_version: '20140201') unless foursquare_connection
          Severity: Minor
          Found in app/controllers/foursquare_controller.rb and 2 other locations - About 25 mins to fix
          app/controllers/foursquare_controller.rb on lines 43..48
          app/controllers/foursquare_controller.rb on lines 57..62

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

          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

              @foursquare_tips        = Rails.cache.fetch('foursquare_tips', expires_in: 12.hours, race_condition_ttl: 10) do
                foursquare_connection = Foursquare2::Client.new(client_id: FOURSQUARE_CLIENT_ID,
                                                                client_secret: FOURSQUARE_CLIENT_SECRET,
                                                                oauth_token: FOURSQUARE_OAUTH_TOKEN,
                                                                api_version: '20140201') unless foursquare_connection
          Severity: Minor
          Found in app/controllers/foursquare_controller.rb and 2 other locations - About 25 mins to fix
          app/controllers/foursquare_controller.rb on lines 43..48
          app/controllers/foursquare_controller.rb on lines 50..55

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

          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

              @foursquare_badges      = Rails.cache.fetch('foursquare_badges', expires_in: 12.hours, race_condition_ttl: 10) do
                foursquare_connection = Foursquare2::Client.new(client_id: FOURSQUARE_CLIENT_ID,
                                                                client_secret: FOURSQUARE_CLIENT_SECRET,
                                                                oauth_token: FOURSQUARE_OAUTH_TOKEN,
                                                                api_version: '20140201') unless foursquare_connection
          Severity: Minor
          Found in app/controllers/foursquare_controller.rb and 2 other locations - About 25 mins to fix
          app/controllers/foursquare_controller.rb on lines 50..55
          app/controllers/foursquare_controller.rb on lines 57..62

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

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

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

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

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

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language