IT61/it61-rails

View on GitHub

Showing 23 of 23 total issues

Function dropdown has 188 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  $.fn.dropdown = function (options) {
    var defaults = {
      inDuration: 300,
      outDuration: 225,
      constrain_width: false, // Does not change width of dropdown to that of the activator
Severity: Major
Found in app/assets/javascripts/components/dropdown.js - About 7 hrs to fix

    Method import_events has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

      def import_events
        puts "Importing events"
        Geocoder.configure(lookup: :yandex)
    
        use_old_db
    Severity: Minor
    Found in lib/tasks/importer/events_importer.rb - About 5 hrs 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

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

          function placeDropdown(eventType) {
            // Check for simultaneous focus and click events.
            if (eventType === 'focus') {
              isFocused = true;
            }
    Severity: Major
    Found in app/assets/javascripts/components/dropdown.js - About 2 hrs to fix

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

          xhr: function () {  // Custom XMLHttpRequest
            var myXhr = $.ajaxSettings.xhr();
            if (myXhr.upload) { // Check if upload property exists
              myXhr.upload.addEventListener('progress', function progressHandlingFunction() {
              }, false); // For handling the progress of the upload
      Severity: Major
      Found in app/assets/javascripts/image_loader.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/users/edit_event_manager.js on lines 11..18

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

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

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

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

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

      Refactorings

      Further Reading

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

            xhr: function () {  // Custom XMLHttpRequest
              var myXhr = $.ajaxSettings.xhr();
              if (myXhr.upload) { // Check if upload property exists
                myXhr.upload.addEventListener('progress', function progressHandlingFunction() {
                }, false); // For handling the progress of the upload
      Severity: Major
      Found in app/assets/javascripts/users/edit_event_manager.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/image_loader.js on lines 16..23

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

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

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

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

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

      Refactorings

      Further Reading

      Function imageImport has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      var imageImport = (function () {
        // Import image to Canvas when $setImage input changed
        var importImage = function ($croppedModalImage, $imageInput, $modal) {
          var files = $imageInput[0].files;
          var file;
      Severity: Minor
      Found in app/assets/javascripts/components/image_import.js - About 1 hr 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

      Method import_events has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def import_events
          puts "Importing events"
          Geocoder.configure(lookup: :yandex)
      
          use_old_db
      Severity: Minor
      Found in lib/tasks/importer/events_importer.rb - About 1 hr to fix

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

          $.fn.autocomplete = function (options) {
        
            var $container,
              _data = [],
              self = this.filter('input');
        Severity: Minor
        Found in app/assets/javascripts/components/autocomplete-input.js - About 1 hr to fix

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

          var imageImport = (function () {
            // Import image to Canvas when $setImage input changed
            var importImage = function ($croppedModalImage, $imageInput, $modal) {
              var files = $imageInput[0].files;
              var file;
          Severity: Minor
          Found in app/assets/javascripts/components/image_import.js - About 1 hr to fix

            Function bindGeocoder has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function bindGeocoder() {
                function addressValue() {
                  return $placeAddress.val();
                }
            
            
            Severity: Minor
            Found in app/assets/javascripts/events/place.js - About 1 hr to fix

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

              var cropper = (function () {
              
                var createCropper = function ($croppedModalImage, $currentImage, $form, onCropperCreated) {
                  $croppedModalImage.cropper({
                    background: false,
              Severity: Minor
              Found in app/assets/javascripts/components/image_crop.js - About 1 hr to fix

                Method all_providers has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def all_providers
                    {
                      facebook: {
                        name: t("socials.facebook"),
                        class: "fa fa-facebook",
                Severity: Minor
                Found in app/helpers/user_helper.rb - About 1 hr to fix

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

                    def import_social_accounts
                      puts "Importing social accounts"
                  
                      use_old_db
                      social_accounts = ActiveRecord::Base.connection.execute("SELECT * FROM authentications")
                  Severity: Minor
                  Found in lib/tasks/importer/social_accounts_importer.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

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

                                  if (!activates.is(e.target) && !origin.is(e.target) && (!origin.find(e.target).length)) {
                                    hideDropdown();
                                    $(document).unbind('click.' + activates.attr('id') + ' touchstart.' + activates.attr('id'));
                                  }
                  Severity: Minor
                  Found in app/assets/javascripts/components/dropdown.js and 1 other location - About 55 mins to fix
                  app/assets/javascripts/components/dropdown.js on lines 252..255

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

                  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

                              else if (origin.hasClass('active')) {
                                hideDropdown();
                                $(document).unbind('click.' + activates.attr('id') + ' touchstart.' + activates.attr('id'));
                              }
                  Severity: Minor
                  Found in app/assets/javascripts/components/dropdown.js and 1 other location - About 55 mins to fix
                  app/assets/javascripts/components/dropdown.js on lines 259..262

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

                  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

                  Function initCropper has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    initCropper: function($croppedModalImage, $imageInput, $modal, $uploadImage, $imageForm, $currentImage) {
                  Severity: Minor
                  Found in app/assets/javascripts/users/edit_event_manager.js - About 45 mins to fix

                    Method build_permalink has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def build_permalink
                          target_field_value = send(permalink_configuration[:target_field])
                    
                          return if permalink.present? || target_field_value.blank?
                          permalink_base = I18n.transliterate(target_field_value).parameterize.downcase
                    Severity: Minor
                    Found in lib/permalink_for/slug_implementation.rb - About 45 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

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

                        swing: function (x, t, b, c, d) {
                    Severity: Minor
                    Found in app/assets/javascripts/components/dropdown.js - About 35 mins to fix

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

                          easeOutQuad: function (x, t, b, c, d) {
                      Severity: Minor
                      Found in app/assets/javascripts/components/dropdown.js - About 35 mins to fix

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

                            easeOutCubic: function (x, t, b, c, d) {
                        Severity: Minor
                        Found in app/assets/javascripts/components/dropdown.js - About 35 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language