sharetribe/sharetribe

View on GitHub

Showing 700 of 1,230 total issues

Function errorValidator has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  errorValidator(values, field) {
    const currentDayIndex = field ? field[1] : null;
    const currentSlotIndex = field ? field[3] : null;
    const currentSlotProp = field ? field[4] : null;
    const currentSlot = field ? values.days[currentDayIndex].working_time_slots[currentSlotIndex] : null;
Severity: Minor
Found in client/app/components/sections/ListingWorkingHours/form.js - About 4 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 render has 109 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const tintedRGB = tint(this.props.color, TINT_PERCENTAGE);
    const listing = this.props.listing;
    const imageURL = listing.images.getIn([0, 'square', 'url']);
    const image2xURL = listing.images.getIn([0, 'square2x', 'url']);
Severity: Major
Found in client/app/components/composites/ListingCard/ListingCard.js - About 4 hrs to fix

    Class Report has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class StripeService::Report
    
      private
    
      attr_reader :tx, :exception
    Severity: Minor
    Found in app/services/stripe_service/report.rb - About 4 hrs to fix

      Method index has 107 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def index
          params = unsafe_params_hash.select{|k, v| v.present? }
      
          redirect_to landing_page_path and return if no_current_user_in_private_clp_enabled_marketplace?
      
      
      Severity: Major
      Found in app/controllers/homepage_controller.rb - About 4 hrs to fix

        Class ListingsController has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class ListingsController < ApplicationController
          class ListingDeleted < StandardError; end
        
          # Skip auth token check as current jQuery doesn't provide it automatically
          skip_before_action :verify_authenticity_token, :only => [:close, :update, :follow, :unfollow]
        Severity: Minor
        Found in app/controllers/listings_controller.rb - About 4 hrs to fix

          File landing_page_controller.rb has 339 lines of code (exceeds 250 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 4 hrs to fix

            Function analytics has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

            window.ST.analytics = (function(){
              var init = function(options) {
                $(document).ready(function() {
                  $(document).trigger('st-analytics:setup', options.analyticsData);
                  if (options.events) {
            Severity: Minor
            Found in app/assets/javascripts/analytics.js - About 4 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 init has 100 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              var init = function() {
                var socialFieldMap = $(".footer-social-container").map(function(id, entry) {
                  return {
                    id: $(entry).data("field-id"),
                    element: $(entry),
            Severity: Major
            Found in app/assets/javascripts/admin/footer_menu.js - About 4 hrs to fix

              Class StripeApiWrapper has 32 methods (exceeds 20 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 4 hrs to fix

                File test_merchant.rb has 332 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require_relative 'test_api'
                
                module PaypalService
                
                  module TestMerchant
                Severity: Minor
                Found in lib/services/paypal_service/test_merchant.rb - About 4 hrs to fix

                  Function errorValidator has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    errorValidator(values, field) {
                      const currentDayIndex = field ? field[1] : null;
                      const currentSlotIndex = field ? field[3] : null;
                      const currentSlotProp = field ? field[4] : null;
                      const currentSlot = field ? values.days[currentDayIndex].working_time_slots[currentSlotIndex] : null;
                  Severity: Major
                  Found in client/app/components/sections/ListingWorkingHours/form.js - About 3 hrs to fix

                    Function thumbnailStripe has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                    Open

                    ST.thumbnailStripe = function(images, opts) {
                      var container = $("#thumbnail-stripe");
                      var thumbnailTmpl = _.template($("#image-thumbnail-template").html());
                    
                      // Options
                    Severity: Minor
                    Found in app/assets/javascripts/thumbnail_stripe.js - About 3 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 render has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                    Open

                      render() {
                        const { location, marketplace_color1: marketplaceColor1 } = { ...DEFAULT_CONTEXT, ...this.props.marketplace };
                        const { loggedInUsername } = this.props.user || {};
                        const isAdmin = !!(this.props.user && this.props.user.isAdmin && loggedInUsername);
                    
                    
                    Severity: Minor
                    Found in client/app/components/sections/Topbar/Topbar.js - About 3 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

                    File people_controller.rb has 325 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    class PeopleController < Devise::RegistrationsController
                      include ConfigRecaptcha
                    
                      skip_before_action :verify_authenticity_token, :only => [:create]
                      skip_before_action :require_no_authentication, :only => [:new]
                    Severity: Minor
                    Found in app/controllers/people_controller.rb - About 3 hrs to fix

                      File entity_utils.rb has 325 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      module EntityUtils
                        module_function
                      
                        # Define an entity constructor Proc, which returns a Hash
                        #
                      Severity: Minor
                      Found in app/utils/entity_utils.rb - About 3 hrs to fix

                        Method update_payment_preferences has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def update_payment_preferences
                            currency = params[:payment_preferences_form]["marketplace_currency"] || @current_community.currency
                        
                            minimum_commission = @paypal_enabled ? (paypal_minimum_commissions_api.get(currency) || 0) : 0
                        
                        
                        Severity: Minor
                        Found in app/controllers/concerns/payments.rb - About 3 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

                        File payments.rb has 320 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module Payments
                          extend ActiveSupport::Concern
                        
                          def payment_index
                            render 'index', locals: form_locals
                        Severity: Minor
                        Found in app/controllers/concerns/payments.rb - About 3 hrs to fix

                          Class PersonMailer has 30 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          class PersonMailer < ActionMailer::Base # rubocop:disable Metrics/ClassLength
                            include MailUtils
                          
                            # Enable use of method to_date.
                            require 'active_support/core_ext'
                          Severity: Minor
                          Found in app/mailers/person_mailer.rb - About 3 hrs to fix

                            File homepage_controller.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            class HomepageController < ApplicationController
                            
                              before_action :save_current_path, :except => :sign_in
                            
                              APP_DEFAULT_VIEW_TYPE = "grid".freeze
                            Severity: Minor
                            Found in app/controllers/homepage_controller.rb - About 3 hrs to fix

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

                                def index
                                  params = unsafe_params_hash.select{|k, v| v.present? }
                              
                                  redirect_to landing_page_path and return if no_current_user_in_private_clp_enabled_marketplace?
                              
                              
                              Severity: Minor
                              Found in app/controllers/homepage_controller.rb - About 3 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

                              Severity
                              Category
                              Status
                              Source
                              Language