sharetribe/sharetribe

View on GitHub

Showing 1,230 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

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

        if (typeof document === 'object' && document.body) {
          if (this.state.mobileSearchOpen) {
            if (!document.body.classList.contains(css.mobileSearchOpen)) {
              document.body.classList.add(css.mobileSearchOpen);
            }
    Severity: Major
    Found in client/app/components/composites/SearchBar/SearchBar.js and 1 other location - About 4 hrs to fix
    client/app/components/composites/MenuMobile/MenuMobile.js on lines 35..43

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

    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 (typeof document === 'object' && document.body) {
          if (this.state.isOpen) {
            if (!document.body.classList.contains(css.menuMobileOpen)) {
              document.body.classList.add(css.menuMobileOpen);
            }
    Severity: Major
    Found in client/app/components/composites/MenuMobile/MenuMobile.js and 1 other location - About 4 hrs to fix
    client/app/components/composites/SearchBar/SearchBar.js on lines 179..187

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

    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

    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

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

          function splitcomplement(color) {
              var hsl = tinycolor(color).toHsl();
              var h = hsl.h;
              return [
                  tinycolor(color),
      Severity: Major
      Found in app/assets/javascripts/admin2/spectrum.js and 1 other location - About 4 hrs to fix
      app/assets/javascripts/admin2/spectrum.js on lines 1805..1813

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

      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

          function triad(color) {
              var hsl = tinycolor(color).toHsl();
              var h = hsl.h;
              return [
                  tinycolor(color),
      Severity: Major
      Found in app/assets/javascripts/admin2/spectrum.js and 1 other location - About 4 hrs to fix
      app/assets/javascripts/admin2/spectrum.js on lines 1826..1834

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

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

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

            def filtered_scope
              scope = resource_scope.includes(person: :emails)
              if params[:q].present?
                person_ids = Person
                  .search_name_or_email(community.id, "%#{params[:q]}%")
          Severity: Major
          Found in app/services/admin2/membership_service.rb and 1 other location - About 4 hrs to fix
          app/services/admin/communities/membership_service.rb on lines 195..220

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

          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

            def filtered_scope
              scope = resource_scope.includes(person: :emails)
              if params[:q].present?
                person_ids = Person
                  .search_name_or_email(community.id, "%#{params[:q]}%")
          Severity: Major
          Found in app/services/admin/communities/membership_service.rb and 1 other location - About 4 hrs to fix
          app/services/admin2/membership_service.rb on lines 187..212

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

          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

          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

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

              it('encodes/decodes Money', () => {
                const v = new Money({ value: '500', unit: 'USD' });
                const encoded = writer.write(v);
            
                expect(rawReader.read(encoded).tag).to.equal('mn');
            Severity: Major
            Found in client/app/specs/transitImmutableConverter.spec.js and 1 other location - About 4 hrs to fix
            client/app/specs/transitImmutableConverter.spec.js on lines 48..54

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

            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

              it('encodes/decodes Distances', () => {
                const v = new Distance({ value: '12.3', unit: 'km' });
                const encoded = writer.write(v);
            
                expect(rawReader.read(encoded).tag).to.equal('di');
            Severity: Major
            Found in client/app/specs/transitImmutableConverter.spec.js and 1 other location - About 4 hrs to fix
            client/app/specs/transitImmutableConverter.spec.js on lines 56..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 117.

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

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

                  set_express_checkout_authorization: PaypalAction.def_action(
                    input_transformer: -> (req, config) {
                      req_details = {
                        cppcartbordercolor: "FFFFFF",
                        cpplogoimage: req[:merchant_brand_logo_url] || "",
            Severity: Major
            Found in app/services/paypal_service/merchant_actions.rb and 1 other location - About 4 hrs to fix
            app/services/paypal_service/merchant_actions.rb on lines 179..221

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

            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

                  set_express_checkout_order: PaypalAction.def_action(
                    input_transformer: -> (req, config) {
                      req_details = {
                        cppcartbordercolor: "FFFFFF",
                        cpplogoimage: req[:merchant_brand_logo_url] || "",
            Severity: Major
            Found in app/services/paypal_service/merchant_actions.rb and 1 other location - About 4 hrs to fix
            app/services/paypal_service/merchant_actions.rb on lines 225..267

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

            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 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
                  Severity
                  Category
                  Status
                  Source
                  Language