sharetribe/sharetribe

View on GitHub

Showing 700 of 1,230 total issues

File listings_controller.rb has 393 lines of code (exceeds 250 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 5 hrs to fix

    File form.js has 390 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { Component } from 'react';
    import PropTypes from 'prop-types';
    import { Form, StyledSelect, FormField, Checkbox } from 'react-form';
    import merge from 'lodash.merge';
    import { t } from '../../../utils/i18n';
    Severity: Minor
    Found in client/app/components/sections/ListingWorkingHours/form.js - About 5 hrs to fix

      Function thumbnailStripe has 132 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ST.thumbnailStripe = function(images, opts) {
        var container = $("#thumbnail-stripe");
        var thumbnailTmpl = _.template($("#image-thumbnail-template").html());
      
        // Options
      Severity: Major
      Found in app/assets/javascripts/thumbnail_stripe.js - About 5 hrs to fix

        Function utils has 132 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ST.utils = (function(_) {
        
          function findNextIndex(arr, fn) {
            if(arr.length < 2) {
              return -1;
        Severity: Major
        Found in app/assets/javascripts/utils.js - About 5 hrs to fix

          Method get_conversation_statuses has 132 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def get_conversation_statuses(conversation, is_author)
              statuses = if conversation.listing && !conversation.status.eql?("free")
                status_hash = {
                  paid: -> { {
                    both: [
          Severity: Major
          Found in app/helpers/transaction_helper.rb - About 5 hrs to fix

            File preauthorize_transactions_controller.rb has 383 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class PreauthorizeTransactionsController < ApplicationController
            
              before_action do |controller|
               controller.ensure_logged_in t("layouts.notifications.you_must_log_in_to_do_a_transaction")
              end
            Severity: Minor
            Found in app/controllers/preauthorize_transactions_controller.rb - About 5 hrs to fix

              File listing_presenter.rb has 382 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'fast-polylines'
              require 'base64'
              
              class ListingPresenter < MemoisticPresenter
                include ListingAvailabilityManage
              Severity: Minor
              Found in app/presenters/listing_presenter.rb - About 5 hrs to fix

                Function analytics has 128 lines of code (exceeds 25 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: Major
                Found in app/assets/javascripts/analytics.js - About 5 hrs to fix

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

                  module PaypalService::API
                  
                    class Payments
                  
                      # Include with_success for wrapping requests and responses
                  Severity: Minor
                  Found in app/services/paypal_service/api/payments.rb - About 5 hrs to fix

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

                      def price_break_down_locals(tx, conversation)
                        if tx.payment_process == :none && tx.unit_price.cents == 0 || conversation.starting_page == Conversation::LISTING
                          nil
                        else
                          localized_unit_type = tx.unit_type.present? ? ListingViewUtils.translate_unit(tx.unit_type, tx.unit_tr_key) : nil
                    Severity: Minor
                    Found in app/controllers/transactions_controller.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 _onDrop has 122 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _onDrop: function _onDrop(
                        /**Event*/
                        evt) {
                          var el = this.el,
                              options = this.options; // Get the index of the dragged element within its parent
                    Severity: Major
                    Found in app/assets/javascripts/admin2/sortable.js - About 4 hrs to fix

                      Function drop has 121 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            drop: function drop(_ref12) {
                              var evt = _ref12.originalEvent,
                                  rootEl = _ref12.rootEl,
                                  parentEl = _ref12.parentEl,
                                  sortable = _ref12.sortable,
                      Severity: Major
                      Found in app/assets/javascripts/admin2/sortable.js - About 4 hrs to fix

                        Function init has 120 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          var init = function(options) {
                            BANK_RULES = options.bank_rules;
                            window.ST.stripe_test_api_mode = options.stripe_test_mode;
                            stripeApi = Stripe(options.api_publishable_key);
                            add_validators();
                        Severity: Major
                        Found in app/assets/javascripts/stripe_form3.js - About 4 hrs to fix

                          Function AnimationStateManager has 119 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function AnimationStateManager() {
                              var animationStates = [],
                                  animationCallbackId;
                              return {
                                captureAnimationState: function captureAnimationState() {
                          Severity: Major
                          Found in app/assets/javascripts/admin2/sortable.js - About 4 hrs to fix

                            Class Transaction has 36 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            class Transaction < ApplicationRecord
                              include ExportTransaction
                              include Testimonials
                            
                              # While initiated is technically not a finished state it also
                            Severity: Minor
                            Found in app/models/transaction.rb - About 4 hrs to fix

                              Function initializeListingShapeForm has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                              Open

                              window.ST.initializeListingShapeForm = function(formId) {
                                $(formId).validate({
                                  errorPlacement: function(error, element) {
                                    if (element.hasClass("js-custom-unit-kind-radio")) {
                                      error.appendTo($(".js-custom-unit-kind-container"));
                              Severity: Minor
                              Found in app/assets/javascripts/admin/listing_shapes.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 initialize_new_listing_form has 114 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                module.initialize_new_listing_form = function(
                                  fileDefaultText,
                                  fileBtnText,
                                  locale,
                                  share_type_message,
                              Severity: Major
                              Found in app/assets/javascripts/listing_form.js - About 4 hrs to fix

                                Function GuideStatusPage has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const GuideStatusPage = (props) => {
                                
                                  const handleClick = function handleClick(e, page, path) {
                                    e.preventDefault();
                                    props.changePage(page, path);
                                Severity: Major
                                Found in client/app/components/sections/OnboardingGuide/GuideStatusPage.js - About 4 hrs to fix

                                  Function initializeLocationSearch has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    module.initializeLocationSearch = function initializeLocationSearch(selectors) {
                                      var searchInput = document.querySelector(selectors.search);
                                      var statusInput = document.querySelector(selectors.status);
                                      var coordinateInput = document.querySelector(selectors.coordinate);
                                      var boundingboxInput = document.querySelector(selectors.boundingbox);
                                  Severity: Major
                                  Found in app/assets/javascripts/location_search.js - About 4 hrs to fix

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

                                    window.ST.initializeListingShapeForm = function(formId) {
                                        $(formId).validate({
                                            errorPlacement: function(error, element) {
                                                if (element.hasClass("js-custom-unit-kind-radio")) {
                                                    error.appendTo($(".js-custom-unit-kind-container"));
                                    Severity: Minor
                                    Found in app/assets/javascripts/admin2/listing_shapes.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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language