public-market/spree_batch_api

View on GitHub

Showing 49 of 49 total issues

Complex method describe(creation)::context#with known isbn (223.0)
Open

    context 'with known isbn' do
      subject(:product) { variant.product }

      it { expect(product).not_to be_nil }
      it { expect(product).to be_persisted }

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Class DefaultVariantProvider has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

      class DefaultVariantProvider < Spree::BaseAction # rubocop:disable Metrics/ClassLength
        KEYWORDS_DELIMITER = ' '.freeze
        VALIDATION_SCHEMA =
          ::Dry::Validation.Schema do
            required(:sku).filled(:str?)
Severity: Minor
Found in app/actions/spree/inventory/providers/default_variant_provider.rb - About 4 hrs to fix

    Complex method describe(creation)::context#when variant already exists (69.3)
    Open

        context 'when variant already exists' do
          let(:isbn) { '9780979728303' }
    
          before do
            described_class.call(item_json)

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Assignment Branch Condition size for build_option_value is too high. [26.78/15]
    Open

        def build_option_value(opt_name, opt_value)
          # no option values on master
          return if is_master
    
          option_type = Spree::OptionType.where(name: opt_name).first_or_initialize do |o|

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Complex method context(when user is authorized)::context#when has content (49.9)
    Open

        context 'when has content' do
          let(:content) { File.read(File.join(Dir.pwd, 'spec/fixtures', 'inventory.csv')) }
    
          it { is_expected.to have_http_status(:ok) }
          it { expect(json).to include(status: 'completed') }
    Severity: Minor
    Found in spec/requests/inventory_spec.rb by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Complex method context(when upload csv)::describe#perform worker (48.2)
    Open

        describe 'perform worker' do
          before { perform }
    
          it { expect(Spree::Product.count).to eq(5) }
          it { expect(Spree::Variant.count).to eq(10) }

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Method has too many lines. [17/10]
    Open

        def build_option_value(opt_name, opt_value)
          # no option values on master
          return if is_master
    
          option_type = Spree::OptionType.where(name: opt_name).first_or_initialize do |o|

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Complex method context#when pass 1 item (40.3)
    Open

      context 'when pass 1 item' do
        let(:items) { [item] }
    
        it { expect(upload.total).to eq(1) }
        it { expect(upload.reload.processed).to eq(1) }

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Complex method context#when json have wrong items (40.2)
    Open

      context 'when json have wrong items' do
        let(:payload) { '{ "items": [{"id": "some"}] }' }
    
        before do
          call

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Assignment Branch Condition size for update_variant is too high. [17.52/15]
    Open

            def update_variant(variant, item)
              variant.price = variant.cost_price = item[:price]
              variant.notes = item[:notes] if variant.respond_to?(:notes)
              update_variant_hook(variant, item)
              variant.build_options(variant_options(item))

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Complex method context#when have error (38.6)
    Open

      context 'when have error' do
        let(:items) { [{ ean: 'UNKNOWN' }] }
    
        it { expect(upload.total).to eq(1) }
        it { expect(upload.reload.processed).to eq(1) }

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Method has too many lines. [11/10]
    Open

        def perform(upload_item_id)
          item = UploadItem.find(upload_item_id)
          upload = item.upload
    
          options = item.options

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for perform is too high. [16.52/15]
    Open

        def perform(upload_item_id)
          item = UploadItem.find(upload_item_id)
          upload = item.upload
    
          options = item.options

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Complex method describe(validation)::it#raises exception (36.7)
    Open

        it 'raises exception' do
          expect { variant }.to raise_error(Spree::ImportError).with_message(include(':sku=>["is missing"]'))
          expect { variant }.to raise_error(Spree::ImportError).with_message(include(':quantity=>["must be filled"]'))
          expect { variant }.to raise_error(Spree::ImportError).with_message(include(':price=>["must be filled"]'))

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Assignment Branch Condition size for call is too high. [15.94/15]
    Open

          def call # rubocop:disable Metrics/MethodLength
            total = 0
            args = []
    
            map_items do |item_json, index|

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Complex method context#when file is correct (34.9)
    Open

      context 'when file is correct' do
        let(:local_file) { File.join(Dir.pwd, 'spec/fixtures', 'inventory.csv') }
    
        before { call }
    
    

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Complex method context(when provider is specified)::context#with existing provider (34.1)
    Open

        context 'with existing provider' do
          class RealSellerVariantProvider < Spree::Inventory::Providers::Fake::VariantProvider; end
    
          let(:opts) { { file_path: '', product_type: :fake, provider: :real_seller } }
    
    

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Complex method Spree::VariantDecorator#build_option_value (33.1)
    Open

        def build_option_value(opt_name, opt_value)
          # no option values on master
          return if is_master
    
          option_type = Spree::OptionType.where(name: opt_name).first_or_initialize do |o|
    Severity: Minor
    Found in app/models/spree/variant_decorator.rb by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Complex method Spree::UploadInventoryWorker#upload_action (29.4)
    Open

        def upload_action(local_file, format) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
          case format
          when 'json'
            payload = File.read(local_file)
            Inventory::JsonImportAction.call(payload, upload: upload, options: options)

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

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

              def call
                return if isbn == UNKNOWN_ISBN
    
                {
                  title: book_title,
    Severity: Minor
    Found in app/actions/spree/inventory/providers/fake/metadata_provider.rb - About 1 hr to fix
      Severity
      Category
      Status
      Source
      Language