Skip to content

Commit

Permalink
Merge pull request #1014 from Shopify/kos/update_rubocop_sorbet
Browse files Browse the repository at this point in the history
Update rubocop and sorbet gem versions
  • Loading branch information
mkevinosullivan committed Sep 16, 2022
2 parents 7a08ae9 + dd6bbe4 commit e3ec2ad
Show file tree
Hide file tree
Showing 30 changed files with 130 additions and 128 deletions.
44 changes: 23 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ GEM
multi_xml (>= 0.5.2)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
json (2.6.2)
jwt (2.4.1)
method_source (1.0.0)
mime-types (3.4.1)
Expand All @@ -61,38 +62,39 @@ GEM
parser (>= 2.6.4.0)
sorbet-runtime (>= 0.5.9204)
unparser
regexp_parser (2.2.0)
regexp_parser (2.5.0)
rexml (3.2.5)
rubocop (1.25.1)
rubocop (1.36.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.0.0)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.15.1, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1)
parser (>= 3.0.1.1)
rubocop-shopify (2.4.0)
rubocop (~> 1.24)
rubocop-sorbet (0.6.5)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
rubocop-shopify (2.10.1)
rubocop (~> 1.35)
rubocop-sorbet (0.6.11)
rubocop (>= 0.90.0)
ruby-progressbar (1.11.0)
securerandom (0.2.0)
sorbet (0.5.10297)
sorbet-static (= 0.5.10297)
sorbet-runtime (0.5.10297)
sorbet-static (0.5.10297-universal-darwin-21)
sorbet-static (0.5.10297-x86_64-linux)
sorbet-static-and-runtime (0.5.10297)
sorbet (= 0.5.10297)
sorbet-runtime (= 0.5.10297)
sorbet (0.5.10438)
sorbet-static (= 0.5.10438)
sorbet-runtime (0.5.10438)
sorbet-static (0.5.10438-universal-darwin-21)
sorbet-static (0.5.10438-x86_64-linux)
sorbet-static-and-runtime (0.5.10438)
sorbet (= 0.5.10438)
sorbet-runtime (= 0.5.10438)
spoom (1.1.11)
sorbet (>= 0.5.9204)
sorbet-runtime (>= 0.5.9204)
thor (>= 0.19.2)
tapioca (0.9.2)
tapioca (0.10.1)
bundler (>= 1.17.3)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
Expand All @@ -105,7 +107,7 @@ GEM
thor (1.2.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)
unicode-display_width (2.3.0)
unparser (0.6.5)
diff-lcs (~> 1.3)
parser (>= 3.1.0)
Expand All @@ -116,7 +118,7 @@ GEM
webrick (1.7.0)
yard (0.9.28)
webrick (~> 1.7.0)
yard-sorbet (0.6.1)
yard-sorbet (0.7.0)
sorbet-runtime (>= 0.5)
yard (>= 0.9)
zeitwerk (2.6.0)
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_api/auth/jwt_payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def shop
def validate_shop(shop)
Context.logger.warn(
"Deprecation notice: ShopifyAPI::Auth::JwtPayload.validate_shop no longer checks the given shop and always " \
"returns true. It will be removed in v11."
"returns true. It will be removed in v11.",
)
true
end
Expand Down
10 changes: 5 additions & 5 deletions lib/shopify_api/auth/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class << self
params(
shop: String,
redirect_path: String,
is_online: T.nilable(T::Boolean)
is_online: T.nilable(T::Boolean),
).returns(T::Hash[Symbol, T.any(String, SessionCookie)])
end
def begin_auth(shop:, redirect_path:, is_online: true)
Expand Down Expand Up @@ -45,7 +45,7 @@ def begin_auth(shop:, redirect_path:, is_online: true)
sig do
params(
cookies: T::Hash[String, String],
auth_query: AuthQuery
auth_query: AuthQuery,
).returns(T::Hash[Symbol, T.any(Session, SessionCookie)])
end
def validate_auth_callback(cookies:, auth_query:)
Expand Down Expand Up @@ -75,12 +75,12 @@ def validate_auth_callback(cookies:, auth_query:)
cookie = if Context.embedded?
SessionCookie.new(
value: "",
expires: Time.now
expires: Time.now,
)
else
SessionCookie.new(
value: session.id,
expires: session.online? ? session.expires : nil
expires: session.online? ? session.expires : nil,
)
end

Expand Down Expand Up @@ -120,7 +120,7 @@ def create_new_session(session_params, shop)
associated_user_scope: associated_user_scope,
associated_user: associated_user,
expires: expires,
shopify_session_id: session_params[:session]
shopify_session_id: session_params[:session],
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_api/auth/oauth/auth_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AuthQuery
timestamp: String,
state: String,
host: String,
hmac: String
hmac: String,
).void
end
def initialize(code:, shop:, timestamp:, state:, host:, hmac:)
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_api/auth/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def online?
expires: T.nilable(Time),
is_online: T.nilable(T::Boolean),
associated_user: T.nilable(AssociatedUser),
shopify_session_id: T.nilable(String)
shopify_session_id: T.nilable(String),
).void
end
def initialize(shop:, id: nil, state: nil, access_token: "", scope: [], associated_user_scope: nil, expires: nil,
Expand Down
6 changes: 3 additions & 3 deletions lib/shopify_api/clients/graphql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(session:, base_path:)
query: String,
variables: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
headers: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
tries: Integer
tries: Integer,
).returns(HttpResponse)
end
def query(query:, variables: nil, headers: nil, tries: 1)
Expand All @@ -30,8 +30,8 @@ def query(query:, variables: nil, headers: nil, tries: 1)
query: nil,
extra_headers: headers,
body_type: "application/json",
tries: tries
)
tries: tries,
),
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/shopify_api/clients/graphql/storefront.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(shop, storefront_access_token)
id: shop,
shop: shop,
access_token: "",
is_online: false
is_online: false,
)
super(session: session, base_path: "/api")
@storefront_access_token = storefront_access_token
Expand All @@ -22,7 +22,7 @@ def initialize(shop, storefront_access_token)
query: String,
variables: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
headers: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
tries: Integer
tries: Integer,
).returns(HttpResponse)
end
def query(query:, variables: nil, headers: {}, tries: 1)
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_api/clients/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def request(request)
request_url(request),
headers: headers,
query: request.query,
body: request.body.class == Hash ? T.unsafe(request.body).to_json : request.body
body: request.body.class == Hash ? T.unsafe(request.body).to_json : request.body,
), HTTParty::Response)

body = res.body.empty? ? {} : JSON.parse(res.body)
Expand Down
20 changes: 10 additions & 10 deletions lib/shopify_api/clients/rest/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def initialize(session: nil)
body: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
query: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
headers: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
tries: T.nilable(Integer)
tries: T.nilable(Integer),
).returns(HttpResponse)
end
def get(path:, body: nil, query: nil, headers: nil, tries: 1)
request(
make_request(http_method: :get, path: path, body: body, query: query, headers: headers,
tries: T.must(tries))
tries: T.must(tries)),
)
end

Expand All @@ -34,13 +34,13 @@ def get(path:, body: nil, query: nil, headers: nil, tries: 1)
body: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
query: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
headers: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
tries: T.nilable(Integer)
tries: T.nilable(Integer),
).returns(HttpResponse)
end
def delete(path:, body: nil, query: nil, headers: nil, tries: 1)
request(
make_request(http_method: :delete, path: path, body: body, query: query, headers: headers,
tries: T.must(tries))
tries: T.must(tries)),
)
end

Expand All @@ -50,13 +50,13 @@ def delete(path:, body: nil, query: nil, headers: nil, tries: 1)
body: T::Hash[T.any(Symbol, String), T.untyped],
query: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
headers: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
tries: T.nilable(Integer)
tries: T.nilable(Integer),
).returns(HttpResponse)
end
def put(path:, body:, query: nil, headers: nil, tries: 1)
request(
make_request(http_method: :put, path: path, body: body, query: query, headers: headers,
tries: T.must(tries))
tries: T.must(tries)),
)
end

Expand All @@ -66,13 +66,13 @@ def put(path:, body:, query: nil, headers: nil, tries: 1)
body: T::Hash[T.any(Symbol, String), T.untyped],
query: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
headers: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
tries: T.nilable(Integer)
tries: T.nilable(Integer),
).returns(HttpResponse)
end
def post(path:, body:, query: nil, headers: nil, tries: 1)
request(
make_request(http_method: :post, path: path, body: body, query: query, headers: headers,
tries: T.must(tries))
tries: T.must(tries)),
)
end

Expand All @@ -98,7 +98,7 @@ def request_url(request)
body: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
query: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
headers: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
tries: Integer
tries: Integer,
).returns(HttpRequest)
end
def make_request(http_method:, path:, body:, query:, headers:, tries:)
Expand All @@ -109,7 +109,7 @@ def make_request(http_method:, path:, body:, query:, headers:, tries:)
query: query,
extra_headers: headers,
body_type: body.nil? ? nil : "application/json",
tries: tries
tries: tries,
)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/shopify_api/rest/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def read_only_attributes
http_method: Symbol,
operation: Symbol,
entity: T.nilable(Base),
ids: T::Hash[Symbol, T.any(Integer, String)]
ids: T::Hash[Symbol, T.any(Integer, String)],
).returns(T.nilable(String))
end
def get_path(http_method:, operation:, entity: nil, ids: {})
Expand Down Expand Up @@ -297,7 +297,7 @@ def to_hash(saving = false)
element_hash = get_element_hash(
get_property(attribute),
T.unsafe(self.class.has_one[attribute]),
saving
saving,
)
hash[attribute.to_s] = element_hash if element_hash || @forced_nils[attribute.to_s]
elsif !get_property(attribute).nil? || @forced_nils[attribute.to_s]
Expand All @@ -312,7 +312,7 @@ def to_hash(saving = false)
def delete(params: {})
@client.delete(
path: T.must(self.class.get_path(http_method: :delete, operation: :delete, entity: self)),
query: params.compact
query: params.compact,
)
rescue ShopifyAPI::Errors::HttpResponseError => e
@errors.errors << e
Expand Down
4 changes: 2 additions & 2 deletions lib/shopify_api/utils/graphql_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class << self
headers: T::Hash[String, T.untyped],
body: String,
cookies: T.nilable(T::Hash[String, String]),
tries: Integer
tries: Integer,
).returns(Clients::HttpResponse)
end
def proxy_query(headers:, body:, cookies: nil, tries: 1)
Expand All @@ -21,7 +21,7 @@ def proxy_query(headers:, body:, cookies: nil, tries: 1)
normalized_headers = HttpUtils.normalize_headers(headers)

session = Utils::SessionUtils.load_current_session(
auth_header: normalized_headers["authorization"], cookies: cookies, is_online: true
auth_header: normalized_headers["authorization"], cookies: cookies, is_online: true,
)

if session.nil? || !session.online?
Expand Down
10 changes: 5 additions & 5 deletions lib/shopify_api/utils/session_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class << self
params(
auth_header: T.nilable(String),
cookies: T.nilable(T::Hash[String, String]),
is_online: T::Boolean
is_online: T::Boolean,
).returns(T.nilable(Auth::Session))
end
def load_current_session(auth_header: nil, cookies: nil, is_online: false)
Expand All @@ -29,7 +29,7 @@ def load_current_session(auth_header: nil, cookies: nil, is_online: false)
params(
auth_header: T.nilable(String),
cookies: T.nilable(T::Hash[String, String]),
is_online: T::Boolean
is_online: T::Boolean,
).returns(T::Boolean)
end
def delete_current_session(auth_header: nil, cookies: nil, is_online: false)
Expand All @@ -55,7 +55,7 @@ def load_offline_session(shop:, include_expired: false)

sig do
params(
shop: String
shop: String,
).returns(T::Boolean)
end
def delete_offline_session(shop:)
Expand All @@ -74,15 +74,15 @@ def load_private_session
Auth::Session.new(
shop: T.must(Context.private_shop),
access_token: Context.api_secret_key,
scope: Context.scope.to_a
scope: Context.scope.to_a,
)
end

sig do
params(
auth_header: T.nilable(String),
cookies: T.nilable(T::Hash[String, String]),
online: T::Boolean
online: T::Boolean,
).returns(T.nilable(String))
end
def current_session_id(auth_header, cookies, online)
Expand Down
Loading

0 comments on commit e3ec2ad

Please sign in to comment.