Merge pull request #457 from koic/fix_rubocop_shopify_3_0_offenses
Fix RuboCop offenses detected with rubocop-shopify 3.0.0
This commit is contained in:
commit
1101900f31
10 changed files with 18 additions and 12 deletions
|
|
@ -16,3 +16,7 @@ Lint/IncompatibleIoSelectWithFiberScheduler:
|
||||||
|
|
||||||
Minitest/LiteralAsActualArgument:
|
Minitest/LiteralAsActualArgument:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
Naming/MethodName:
|
||||||
|
AllowedPatterns:
|
||||||
|
- '\Atest_'
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ module JsonRpcHandler
|
||||||
PARSE_ERROR = -32700
|
PARSE_ERROR = -32700
|
||||||
end
|
end
|
||||||
|
|
||||||
DEFAULT_ALLOWED_ID_CHARACTERS = /\A[a-zA-Z0-9_-]+\z/
|
DEFAULT_ALLOWED_ID_CHARACTERS = /\A[a-zA-Z0-9_-]+\z/.freeze
|
||||||
|
|
||||||
# Sentinel return value from a handler. When a handler returns this,
|
# Sentinel return value from a handler. When a handler returns this,
|
||||||
# `process_request` emits no JSON-RPC response for the request,
|
# `process_request` emits no JSON-RPC response for the request,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ module MCP
|
||||||
# Matches a single `key=value` pair inside an HTTP auth-scheme challenge.
|
# Matches a single `key=value` pair inside an HTTP auth-scheme challenge.
|
||||||
# `value` is either a quoted string (which can contain commas and spaces)
|
# `value` is either a quoted string (which can contain commas and spaces)
|
||||||
# or a bare token, per RFC 7235.
|
# or a bare token, per RFC 7235.
|
||||||
WWW_AUTH_PARAM_PATTERN = /\A([A-Za-z0-9_-]+)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|([^\s,]+))/
|
WWW_AUTH_PARAM_PATTERN = /\A([A-Za-z0-9_-]+)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|([^\s,]+))/.freeze
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
# Parses a `WWW-Authenticate` header and returns the parameters of
|
# Parses a `WWW-Authenticate` header and returns the parameters of
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ module MCP
|
||||||
LATEST_STABLE_PROTOCOL_VERSION = "2025-11-25"
|
LATEST_STABLE_PROTOCOL_VERSION = "2025-11-25"
|
||||||
SUPPORTED_STABLE_PROTOCOL_VERSIONS = [
|
SUPPORTED_STABLE_PROTOCOL_VERSIONS = [
|
||||||
LATEST_STABLE_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05",
|
LATEST_STABLE_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05",
|
||||||
]
|
].freeze
|
||||||
DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26"
|
DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26"
|
||||||
|
|
||||||
attr_writer :exception_reporter, :around_request
|
attr_writer :exception_reporter, :around_request
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
module MCP
|
module MCP
|
||||||
class Icon
|
class Icon
|
||||||
SUPPORTED_THEMES = ["light", "dark"]
|
SUPPORTED_THEMES = ["light", "dark"].freeze
|
||||||
|
|
||||||
attr_reader :mime_type, :sizes, :src, :theme
|
attr_reader :mime_type, :sizes, :src, :theme
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,7 @@ module MCP
|
||||||
rescue => e
|
rescue => e
|
||||||
already_reported = begin
|
already_reported = begin
|
||||||
!!exception_already_reported&.call(e)
|
!!exception_already_reported&.call(e)
|
||||||
# rubocop:disable Lint/RescueException
|
|
||||||
rescue Exception
|
rescue Exception
|
||||||
# rubocop:enable Lint/RescueException
|
|
||||||
# The predicate is expected to be side-effect-free and return a boolean.
|
# The predicate is expected to be side-effect-free and return a boolean.
|
||||||
# Any exception raised from it (including non-StandardError such as SystemExit)
|
# Any exception raised from it (including non-StandardError such as SystemExit)
|
||||||
# must not shadow the original exception.
|
# must not shadow the original exception.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ module MCP
|
||||||
# Applied after `Regexp.escape`, which turns `{` and `}` into `\{` and `\}`.
|
# Applied after `Regexp.escape`, which turns `{` and `}` into `\{` and `\}`.
|
||||||
# Variable names are restricted to valid Regexp named-group names,
|
# Variable names are restricted to valid Regexp named-group names,
|
||||||
# so RFC 6570 operator expressions (e.g. `{?query}`) stay literal and never match.
|
# so RFC 6570 operator expressions (e.g. `{?query}`) stay literal and never match.
|
||||||
VARIABLE_PATTERN = /\\\{([A-Za-z_]\w*)\\\}/
|
VARIABLE_PATTERN = /\\\{([A-Za-z_]\w*)\\\}/.freeze
|
||||||
|
|
||||||
attr_reader :uri_template_value
|
attr_reader :uri_template_value
|
||||||
attr_reader :title_value
|
attr_reader :title_value
|
||||||
|
|
|
||||||
|
|
@ -963,9 +963,7 @@ module MCP
|
||||||
end
|
end
|
||||||
|
|
||||||
def index_resources_by_uri(resources)
|
def index_resources_by_uri(resources)
|
||||||
resources.each_with_object({}) do |resource, hash|
|
resources.to_h { |resource| [resource.uri, resource] }
|
||||||
hash[resource.uri] = resource
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_tool_response(text)
|
def error_tool_response(text)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ module MCP
|
||||||
nil # Simulate end of input
|
nil # Simulate end of input
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_encoding(encoding) # rubocop:disable Naming/AccessorMethodName
|
def set_encoding(encoding)
|
||||||
# Mock implementation
|
# Mock implementation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1925,7 +1925,10 @@ module MCP
|
||||||
end
|
end
|
||||||
|
|
||||||
test "missing MCP-Protocol-Version header falls back to default for validation" do
|
test "missing MCP-Protocol-Version header falls back to default for validation" do
|
||||||
MCP::Configuration::SUPPORTED_STABLE_PROTOCOL_VERSIONS.stubs(:include?).returns(false)
|
# The constant is frozen, so swap it out instead of stubbing `include?` on it.
|
||||||
|
original_versions = MCP::Configuration::SUPPORTED_STABLE_PROTOCOL_VERSIONS
|
||||||
|
MCP::Configuration.send(:remove_const, :SUPPORTED_STABLE_PROTOCOL_VERSIONS)
|
||||||
|
MCP::Configuration.const_set(:SUPPORTED_STABLE_PROTOCOL_VERSIONS, [].freeze)
|
||||||
|
|
||||||
request = Rack::Request.new(
|
request = Rack::Request.new(
|
||||||
"REQUEST_METHOD" => "POST",
|
"REQUEST_METHOD" => "POST",
|
||||||
|
|
@ -1938,6 +1941,9 @@ module MCP
|
||||||
|
|
||||||
body = JSON.parse(response[2][0])
|
body = JSON.parse(response[2][0])
|
||||||
assert_includes body["error"]["message"], MCP::Configuration::DEFAULT_NEGOTIATED_PROTOCOL_VERSION
|
assert_includes body["error"]["message"], MCP::Configuration::DEFAULT_NEGOTIATED_PROTOCOL_VERSION
|
||||||
|
ensure
|
||||||
|
MCP::Configuration.send(:remove_const, :SUPPORTED_STABLE_PROTOCOL_VERSIONS)
|
||||||
|
MCP::Configuration.const_set(:SUPPORTED_STABLE_PROTOCOL_VERSIONS, original_versions)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "POST request with empty MCP-Protocol-Version header returns 400" do
|
test "POST request with empty MCP-Protocol-Version header returns 400" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue