sharetribe/sharetribe

View on GitHub

Showing 700 of 1,230 total issues

Consider simplifying this complex logical expression.
Open

      if (tapEvt) {
        var options = this.options,
            fallbackTolerance = options.fallbackTolerance,
            fallbackOffset = options.fallbackOffset,
            touch = evt.touches ? evt.touches[0] : evt,
Severity: Critical
Found in app/assets/javascripts/admin2/sortable.js - About 3 hrs to fix

    Function Sortable has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function Sortable(el, options) {
        if (!(el && el.nodeType && el.nodeType === 1)) {
          throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
        }
    
    
    Severity: Major
    Found in app/assets/javascripts/admin2/sortable.js - About 3 hrs to fix

      Class LandingPageController has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class LandingPageController < ActionController::Metal
      
        # Shorthand for accessing CustomLandingPage service namespace
        CLP = CustomLandingPage
      
      
      Severity: Minor
      Found in app/controllers/landing_page_controller.rb - About 3 hrs to fix

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

        function initCategory() {
            $(document).off('click', ".edit-dropdown-list-option-trigger");
            $(document).on('click', '.edit-dropdown-list-option-trigger', function (event) {
                var container = $(this).closest('.categories-list').next('.edit-category-content'),
                    remove = $(this).closest('.categories-list').next('.edit-category-content').next('.remove-category-content');
        Severity: Major
        Found in app/assets/javascripts/admin2/landing_pages.js - About 2 hrs to fix

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

          ST.imageCarousel = function(images) {
            // Elements
            var tmpl = _.template($("#image-frame-template").html());
            var leftLink = $("#listing-image-navi-left");
            var rightLink = $("#listing-image-navi-right");
          Severity: Major
          Found in app/assets/javascripts/image_carousel.js - About 2 hrs to fix

            Method create has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                if new_listing_author != @current_user
                  logger.info "ADMIN ACTION: admin='#{@current_user.id}' create listing params=#{params.inspect}"
                end
                if show_location? && params[:listing][:origin_loc_attributes][:address].blank?
            Severity: Minor
            Found in app/controllers/listings_controller.rb - About 2 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 _onTapStart has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _onTapStart: function _onTapStart(
                /** Event|TouchEvent */
                evt) {
                  if (!evt.cancelable) return;
            
            
            Severity: Major
            Found in app/assets/javascripts/admin2/sortable.js - About 2 hrs to fix

              File stripe_api_wrapper.rb has 286 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class StripeService::API::StripeApiWrapper
                DEFAULT_MCC = 5734 # Computer Software Stores
                API_2019_12_03 = '2019-12-03'.freeze
                API_2019_02_19 = '2019-02-19'.freeze
              
              
              Severity: Minor
              Found in app/services/stripe_service/api/stripe_api_wrapper.rb - About 2 hrs to fix

                Method give_consent has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def give_consent
                    form_params = params[:form] || {}
                    values = Form.call(form_params.to_unsafe_hash)
                
                    invitation_check = -> {
                Severity: Major
                Found in app/controllers/community_memberships_controller.rb - About 2 hrs to fix

                  File icon_map.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  ICON_MAP = {
                      "ss-pika" => {
                  
                        # Default UI icons
                        "details" => "ss-page",
                  Severity: Minor
                  Found in app/view_utils/icon_map.rb - About 2 hrs to fix

                    Class CommunitiesController has 25 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Admin::CommunitiesController < Admin::AdminBaseController
                      include CommunitiesHelper
                    
                      before_action :ensure_white_label_plan, only: [:create_sender_address]
                    
                    
                    Severity: Minor
                    Found in app/controllers/admin/communities_controller.rb - About 2 hrs to fix

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

                      window.ST.renderImagePlaceholder = function() {
                        var template = $("#new-image-tmpl").html();
                        var element = $(template);
                        var previewImage = $("img", element).hide();
                        var removeLink = $('.fileupload-preview-remove-image', element);
                      Severity: Major
                      Found in app/assets/javascripts/image_uploader.js - About 2 hrs to fix

                        Method create_message_from_action has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def create_message_from_action(transition, old_state, author, starter, payment_sum, payment_gateway, community, show_sum)
                            preauthorize_accepted = ->(new_state) { new_state == "paid" && old_state == "preauthorized" }
                            post_pay_accepted = ->(new_state) {
                              # The condition here is simply "if new_state is paid", since due to migrations from old system there might be
                              # transitions in "paid" state without previous state.
                        Severity: Major
                        Found in app/view_utils/transaction_view_utils.rb - About 2 hrs to fix

                          Method analytics_data has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def analytics_data
                              user_is_admin = @current_user.try(:is_marketplace_admin?, @current_community)
                              {
                                community_ident: @current_community.try(:ident),
                                community_uuid: @current_community.try(:uuid_object).to_s,
                          Severity: Minor
                          Found in app/helpers/analytics_helper.rb - About 2 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

                          Method update has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def update
                              target_user = Person.find_by!(username: params[:id], community_id: @current_community.id)
                              if @current_user != target_user
                                logger.info "ADMIN ACTION: admin='#{@current_user.id}' update person='#{target_user.id}' params=#{params.inspect}"
                              end
                          Severity: Minor
                          Found in app/controllers/people_controller.rb - About 2 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

                          Method validate_booking has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def validate_booking(tx_params:, quantity_selector:, stripe_in_use:)
                                  per_hour = tx_params[:per_hour]
                                  if per_hour || [:day, :night].include?(quantity_selector)
                                    start_on, end_on = per_hour ? tx_params.values_at(:start_time, :end_time)  : tx_params.values_at(:start_on, :end_on)
                                    max_end_date = stripe_in_use ? APP_CONFIG.stripe_max_booking_date.days.from_now : 12.months.from_now
                          Severity: Minor
                          Found in app/services/transaction_service/validation.rb - About 2 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 addListingMarkers has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function addListingMarkers(listings, viewport) {
                            // Test requesting location data
                            // Now the request_path needs to also have a query string with the wanted parameters
                          
                            markerContents = [];
                          Severity: Major
                          Found in app/assets/javascripts/googlemaps.js - About 2 hrs to fix

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

                                  submitHandler: function(form) {
                                    removeSpaces();
                                    stripeFormData = $(form).serializeArray();
                                    var data = prepareData(options),
                                      documentFrontEl = $('#stripe_account_form_document_front'),
                            Severity: Major
                            Found in app/assets/javascripts/stripe_form3.js - About 2 hrs to fix

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

                                  function draggable(element, onmove, onstart, onstop) {
                                      onmove = onmove || function () { };
                                      onstart = onstart || function () { };
                                      onstop = onstop || function () { };
                                      var doc = document;
                              Severity: Major
                              Found in app/assets/javascripts/admin2/spectrum.js - About 2 hrs to fix

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

                                  function SwapPlugin() {
                                    function Swap() {
                                      this.defaults = {
                                        swapClass: 'sortable-swap-highlight'
                                      };
                                Severity: Major
                                Found in app/assets/javascripts/admin2/sortable.js - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language