Skip to content

Commit

Permalink
add rubocop-rails
Browse files Browse the repository at this point in the history
  • Loading branch information
rubygitflow committed Feb 28, 2024
1 parent 848628b commit 3a6532f
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
inherit_from:
- rubocop.rspec.yml
- rubocop.performance.yml
- rubocop.rails.yml
- rubocop.rake.yml
- rubocop.rspec.yml

AllCops:
Exclude:
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/credentials_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create
title: I18n.t('errors.credentials_are_invalid'),
detail: @mp_credential.credentials['errors']
}]
}, status: 400
}, status: :bad_request
end
end

Expand Down Expand Up @@ -63,7 +63,7 @@ def fetch_credential
code: 'error',
title: I18n.t('errors.not_found', class_name: 'MarketplaceCredential')
}]
}, status: 404
}, status: :not_found
else
@mp_credential
end
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ApplicationController < ActionController::API
code: 'error',
title: I18n.t('errors.unauthorized')
}]
}, status: 401
}, status: :unauthorized
end

rescue_from(MarketplaceAggregator::ForbiddenError) do
Expand All @@ -16,7 +16,7 @@ class ApplicationController < ActionController::API
code: 'error',
title: I18n.t('errors.forbidden')
}]
}, status: 403
}, status: :forbidden
end

def current_user
Expand All @@ -29,8 +29,8 @@ def current_user
end

def marketplace(attr)
@marketplace = Marketplace.find_by_name(attr.capitalize) ||
Marketplace.find_by_label(attr)
@marketplace = Marketplace.find_by(name: attr.capitalize) ||
Marketplace.find_by(label: attr)
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/services/ozon/products_downloader/importing_scheme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def find_price(item)
end

def find_barcodes(item)
item[:barcodes].blank? ? item[:barcode] : item[:barcodes]
item[:barcodes].presence || [item[:barcode]]
end

def find_skus(item)
Expand Down
4 changes: 2 additions & 2 deletions app/services/yandex/sleeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module Sleeper
# }
def do_sleep(headers, duration)
dt =
Time.parse(headers['X-RateLimit-Resource-Until']) -
Time.parse(headers['Date']) +
Time.parse(headers['X-RateLimit-Resource-Until']).to_f -
Time.parse(headers['Date']).to_f +
1
if dt > duration
Rails.logger.error I18n.t('errors.duration_of_rate_limit_has_been_changed',
Expand Down
4 changes: 2 additions & 2 deletions lib/ma_benchmarking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module MaBenchmarking
def benchmarking(log_string)
back_time = Time.now
back_time = Time.now.to_f
yield
Rails.logger.info format("(in %.3f sec) #{log_string.call}", Time.now - back_time)
Rails.logger.info format("(in %.3f sec) #{log_string.call}", Time.now.to_f - back_time)
end
end
2 changes: 1 addition & 1 deletion rubocop.performance.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require:
require:
- rubocop-performance

Performance/Caller:
Expand Down
45 changes: 45 additions & 0 deletions rubocop.rails.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require:
rubocop-rails

Rails:
Enabled: true

Rails/ApplicationJob:
Enabled: true

Rails/ApplicationRecord:
Enabled: true

Rails/CreateTableWithTimestamps:
Enabled: false

Rails/Delegate:
Enabled: false

Rails/HasAndBelongsToMany:
Enabled: false

Rails/HasManyOrHasOneDependent:
Enabled: false

Rails/HttpPositionalArguments:
Enabled: false

Rails/OutputSafety:
Enabled: false

Rails/RenderInline:
Enabled: false

Rails/SkipsModelValidations:
Enabled: false

Rails/UnknownEnv:
Environments:
- development
- test
- staging
- production

Rails/Validation:
Enabled: false
2 changes: 2 additions & 0 deletions rubocop.rake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require:
- rubocop-rake

0 comments on commit 3a6532f

Please sign in to comment.