Skip to content

RUBY-17: Add frozen_string_literal magic comment to all files #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ Naming/VariableNumber:
########################################################################################################################
# TO FIX
########################################################################################################################
Style/FrozenStringLiteralComment:
Enabled: false

Layout/EmptyLineAfterGuardClause:
Enabled: false

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Next Release
Your contribution here.

* [#169](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/169): Add frozen_string_literal magic comment to all files - [@splittingred](https://github.com/splittingred)
* [#168](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/168): Move to CircleCI off of TravisCI - [@splittingred](https://github.com/splittingred)
* [#168](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/168): Explicitly declare development dependencies in gemspec - [@splittingred](https://github.com/splittingred)
* [#167](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/167): Changes handling of HTTP response headers to handle lowercased titles. - [@bc-zachary](https://github.com/bc-zachary).
Expand Down
9 changes: 2 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

group :development do
gem 'pry'
gem 'rspec'
gem 'rubocop'
gem 'simplecov'
end
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'bundler/gem_tasks'
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.verbose = false
Expand Down
2 changes: 1 addition & 1 deletion bigcommerce.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal : true
# frozen_string_literal: true

$LOAD_PATH.unshift(File.expand_path('lib', __dir__))
require 'bigcommerce/version'
Expand Down
18 changes: 16 additions & 2 deletions lib/bigcommerce/config.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
# frozen_string_literal: true

module Bigcommerce
class Config < Hashie::Mash
BC_API_ENDPOINT_ENV_KEY = 'BC_API_ENDPOINT'
DEFAULTS = {
base_url: 'https://api.bigcommerce.com'
}.freeze

##
# @return [String]
#
def api_url
return url if auth == 'legacy'

base = ENV['BC_API_ENDPOINT'].to_s.empty? ? DEFAULTS[:base_url] : ENV['BC_API_ENDPOINT']
"#{base}/stores/#{store_hash}/v2"
"#{base_url}/stores/#{store_hash}/v2"
end

private

##
# @return [String]
#
def base_url
ENV[BC_API_ENDPOINT_ENV_KEY].to_s.empty? ? DEFAULTS[:base_url] : ENV[BC_API_ENDPOINT_ENV_KEY]
end
end
end
5 changes: 4 additions & 1 deletion lib/bigcommerce/connection.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

module Bigcommerce
module Connection
LEGACY_AUTH_MODE = 'legacy'
HEADERS = {
'accept' => 'application/json',
'content-type' => 'application/json',
Expand All @@ -12,7 +15,7 @@ def self.build(config)
Faraday.new(url: config.api_url, ssl: ssl_options) do |conn|
conn.request :json
conn.headers = HEADERS
if config.auth == 'legacy'
if config.auth == LEGACY_AUTH_MODE
conn.use Faraday::Request::BasicAuthentication, config.username, config.api_key
else
conn.use Bigcommerce::Middleware::Auth, config
Expand Down
6 changes: 4 additions & 2 deletions lib/bigcommerce/exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ module HttpErrors
509 => Bigcommerce::BandwidthLimitExceeded
}.freeze

X_RETRY_AFTER_HEADER_KEY = 'x-retry-after'

def throw_http_exception!(code, env)
return unless ERRORS.key?(code)

response_headers = Faraday::Utils::Headers.new(env.response_headers)

unless response_headers['x-retry-after'].nil?
response_headers[:retry_after] = response_headers['x-retry-after'].to_i
unless response_headers[X_RETRY_AFTER_HEADER_KEY].nil?
response_headers[:retry_after] = response_headers[X_RETRY_AFTER_HEADER_KEY].to_i
end

raise ERRORS[code].new(response_headers), env.body
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/middleware/http_exception.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bigcommerce/exception'

module Bigcommerce
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'

module Bigcommerce
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resource_actions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Bigcommerce
class ResourceActions < Module
attr_reader :options
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/content/blog_post.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Blog Post
# Content entries in the store's blog.
# https://developer.bigcommerce.com/api/stores/v2/blog/posts
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/content/blog_tag.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Blog Tag
# Index of tags used on the store's blog.
# https://developer.bigcommerce.com/api/stores/v2/blog/tags
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/content/redirect.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Redirect
# Redirects are used to create custom URL paths that map to resources on the
# storefront (such as products, categories, brands, etc.) or manually defined
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/customers/customer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'jwt'
require 'securerandom'

Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/customers/customer_address.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Customer Address
# Postal addresses belonging to a customer.
# https://developer.bigcommerce.com/api/stores/v2/customers/addresses
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/customers/customer_group.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Customer Group
# Groups of customers who share the same level of access and discounts
# at a store.
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/geography/country.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Country
# Countries and territories, identified by their ISO 3166 country codes.
# https://developer.bigcommerce.com/api/stores/v2/countries
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/geography/state.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# State
# States and subdivisions belonging to countries.
# https://developer.bigcommerce.com/api/stores/v2/countries/states
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/marketing/banner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Banner
# HTML element on webpages to advertise discounts or other content relevant to shoppers.
# https://developer.bigcommerce.com/api/stores/v2/banners
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/marketing/coupon.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Coupon
# Category or product discounts that can be applied to orders for customers
# who enter a given code.
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/marketing/gift_certificates.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Gift Certificates
# Code that can be applied by customers to their order to provide full or partial payment.
# https://developer.bigcommerce.com/api/stores/v2/gift_certificates
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/orders/order.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Order
# Purchases from a store.
# https://developer.bigcommerce.com/api/stores/v2/orders
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/orders/order_coupon.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Order Coupon
# Coupons applied to an order.
# https://developer.bigcommerce.com/api/stores/v2/orders/coupons
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/orders/order_message.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Order Message
# Messages associated with an order.
# https://developer.bigcommerce.com/api/stores/v2/orders/messages
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/orders/order_product.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Order Product
# Product line items associated with an order.
# https://developer.bigcommerce.com/api/stores/v2/orders/products
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/orders/order_shipping_address.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Order Shipping Addresses
# Shipping addresses associated with an order.
# https://developer.bigcommerce.com/api/stores/v2/orders/shipping_addresses
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/orders/order_status.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Order Status
# Statuses that can be assigned to orders. Each status represents a state in
# the fulfilment workflow.
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/orders/order_tax.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Order Shipping Addresses
# Shipping addresses associated with an order.
# https://developer.bigcommerce.com/api/stores/v2/orders/shipping_addresses
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/orders/shipment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Order Shipment
# Shipping package consignments tracked from an order.
# https://developer.bigcommerce.com/api/stores/v2/orders/shipments
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/payments/payment_method.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Payment Method
# Enabled payment methods.
# https://developer.bigcommerce.com/api/stores/v2/payments/methods
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/brand.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Brand
# Brand facets for identifying and categorising products according
# to their manufacturer or company metonym.
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/bulk_pricing_rule.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Bulk Pricing Rule
# Bulk pricing rules applied to a product.
# https://developer.bigcommerce.com/api/stores/v2/products/discount_rules
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/category.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Category
# Index of hierarchical categories used to organise and group products.
# https://developer.bigcommerce.com/api/stores/v2/categories
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/configurable_field.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Configurable Field
# Configurable fields associated with a product.
# https://developer.bigcommerce.com/api/stores/v2/products/configurable_fields
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/custom_field.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Custom Field
# Custom fields associated with a product.
# https://developer.bigcommerce.com/api/stores/v2/products/custom_fields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Google Product Search Mapping
# Google Product Search mappings for a product.
# https://developer.bigcommerce.com/api/stores/v2/products/googleproductsearch
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/option.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Option
# Shared attributes that control value facets on a product.
# https://developer.bigcommerce.com/api/stores/v2/options
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/option_set.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Option Set
# A reusable set of option facets that can be applied to products.
# https://developer.bigcommerce.com/api/stores/v2/options_sets
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/option_set_option.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Option Set Option
# Options belonging to an option set.
# https://developer.bigcommerce.com/api/stores/v2/option_sets/options
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/option_value.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Option Value
# Values that can be selected for an option.
# https://developer.bigcommerce.com/api/stores/v2/options/values
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/product.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Product
# Catalog of saleable items in the store.
# https://developer.bigcommerce.com/api/stores/v2/products
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/product_image.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Product Image
# Images associated with a product.
# https://developer.bigcommerce.com/api/stores/v2/products/images
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/product_option.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Product Option
# Options associated directly with a product.
# https://developer.bigcommerce.com/api/stores/v2/products/options
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/product_review.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Product Review
# Options associated directly with a product.
# https://developer.bigcommerce.com/api/stores/v2/products/reviews
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/product_rule.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Product Rule
# Rules that modify the default behaviour of products.
# https://developer.bigcommerce.com/api/stores/v2/products/rules
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/product_video.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Product Video
# Embedded videos displayed on product listings.
# https://developer.bigcommerce.com/api/stores/v2/products/videos
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/products/sku.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# SKU
# Stock Keeping Unit identifiers associated with products.
# https://developer.bigcommerce.com/api/stores/v2/products/skus
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/resource.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bigcommerce/request'
require 'bigcommerce/resource_actions'
require 'bigcommerce/subresource_actions'
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/shipping/shipping_method.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Shipping Method
# List of enabled shipping methods.
# https://developer.bigcommerce.com/api/stores/v2/shipping/methods
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/store/store_information.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Store Information
# Metadata that describes the store.
# https://developer.bigcommerce.com/api/stores/v2/store_information
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/system/time.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Time
# Timestamp ping to check the system status.
# https://developer.bigcommerce.com/api/stores/v2/time
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/tax/tax_class.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Tax Class
# Tax classes are used to apply different tax rates for specific types
# of products and orders.
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/resources/webhooks/webhook.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Webhook
# Register and manage webhooks that connect events from a store to
# external URLs.
Expand Down
2 changes: 2 additions & 0 deletions lib/bigcommerce/subresource_actions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Bigcommerce
class SubresourceActions < ResourceActions
def included(base)
Expand Down
Loading