Skip to content
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
4 changes: 1 addition & 3 deletions lib/active_job/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ module SQSSendMessageParametersAccessor
extend ActiveSupport::Concern

included do
# @!attribute [rw] sqs_send_message_parameters
# @return [Hash] the SQS send message parameters
# @return [Hash] the SQS send message parameters
attr_accessor :sqs_send_message_parameters
end
end
Expand All @@ -26,7 +25,6 @@ def initialize(*arguments)
super(*arguments)
self.sqs_send_message_parameters = {}
end
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)

# Enqueues the job with optional SQS-specific parameters
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ShoryukenConcurrentSendAdapter < ShoryukenAdapter
# @param success_handler [Proc, nil] callback for successful enqueues
# @param error_handler [Proc, nil] callback for failed enqueues
def initialize(success_handler = nil, error_handler = nil)
super() if defined?(super)
@success_handler = success_handler
@error_handler = error_handler
end
Expand Down
2 changes: 1 addition & 1 deletion lib/shoryuken/active_job/current_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def deserialize(attrs)
end

class << self
# @return [Hash{String => String}] registered CurrentAttributes classes mapped to keys
# @return [Hash{String => String}] serialization keys mapped to CurrentAttributes class names
attr_reader :cattrs

# Register CurrentAttributes classes to persist across job execution.
Expand Down
4 changes: 2 additions & 2 deletions lib/shoryuken/logging/pretty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Logging
#
# Output format: "TIMESTAMP PID TID-THREAD_ID CONTEXT SEVERITY: MESSAGE"
#
# @example Output
# "2023-08-15T10:30:45Z 12345 TID-abc123 MyWorker/queue1/msg-456 INFO: Processing message"
# @example Sample output
# # 2023-08-15T10:30:45Z 12345 TID-abc123 MyWorker/queue1/msg-456 INFO: Processing message
class Pretty < Base
# Formats a log message with timestamp and full context information.
#
Expand Down
4 changes: 2 additions & 2 deletions lib/shoryuken/logging/without_timestamp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Logging
#
# Output format: "pid=PID tid=THREAD_ID CONTEXT SEVERITY: MESSAGE"
#
# @example Output
# "pid=12345 tid=abc123 MyWorker/queue1/msg-456 INFO: Processing message"
# @example Sample output
# # pid=12345 tid=abc123 MyWorker/queue1/msg-456 INFO: Processing message
class WithoutTimestamp < Base
# Formats a log message without timestamp information.
#
Expand Down
3 changes: 1 addition & 2 deletions lib/shoryuken/middleware/chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,8 @@ def clear
# with control passed through yielding.
#
# @param args [Array] arguments to pass to each middleware
# @param final_action [Proc] the final action to perform after all middleware (provided as a block)
# @param final_action [Proc] the final action to perform after all middleware
# @return [void]
# @yield the final action to perform after all middleware
def invoke(*args, &final_action)
chain = retrieve.dup
traverse_chain = lambda do
Expand Down
4 changes: 2 additions & 2 deletions lib/shoryuken/middleware/server/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ module Server
class ActiveRecord
# Processes a message and clears database connections afterwards
#
# @param _args [Array] middleware call arguments (unused)
# @param _args [Array<Object>] middleware call arguments (unused)
# @yield continues to the next middleware in the chain
# @return [void]
# @return [Object] return value from the next middleware or worker in the chain
def call(*_args)
yield
ensure
Expand Down
2 changes: 2 additions & 0 deletions lib/shoryuken/middleware/server/exponential_backoff_retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class ExponentialBackoffRetry
# @param _body [Object] the parsed message body (unused)
# @yield continues to the next middleware in the chain
# @return [void]
# @raise [StandardError] re-raises the original exception if retry intervals are not configured
# or if retry limit is exceeded
def call(worker, _queue, sqs_msg, _body)
return yield unless worker.class.exponential_backoff?

Expand Down
45 changes: 15 additions & 30 deletions lib/shoryuken/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,28 @@ class Options
}
}.freeze

# @!attribute [rw] active_job_queue_name_prefixing
# @return [Boolean] whether to enable ActiveJob queue name prefixing
# @!attribute [rw] cache_visibility_timeout
# @return [Boolean] whether to cache SQS visibility timeout
# @!attribute [rw] groups
# @return [Hash{String => Hash}] the configured processing groups
# @!attribute [rw] launcher_executor
# @return [Object] the executor used to launch workers
# @!attribute [rw] reloader
# @return [Proc] the code reloader proc for development environments
# @!attribute [rw] enable_reloading
# @return [Boolean] whether code reloading is enabled
# @!attribute [rw] start_callback
# @return [Proc, nil] callback to execute when server starts
# @!attribute [rw] stop_callback
# @return [Proc, nil] callback to execute when server stops
# @!attribute [rw] worker_executor
# @return [Class] the executor class for running workers
# @!attribute [rw] worker_registry
# @return [Shoryuken::WorkerRegistry] the registry for worker classes
# @!attribute [rw] exception_handlers
# @return [Array<#call>] handlers for processing exceptions
# @return [Boolean] whether to enable ActiveJob queue name prefixing
# @return [Boolean] whether to cache SQS visibility timeout
# @return [Hash{String => Hash}] the configured processing groups
# @return [Object] the executor used to launch workers
# @return [Proc] the code reloader proc for development environments
# @return [Boolean] whether code reloading is enabled
# @return [Proc, nil] callback to execute when server starts
# @return [Proc, nil] callback to execute when server stops
# @return [Class] the executor class for running workers
# @return [Shoryuken::WorkerRegistry] the registry for worker classes
# @return [Array<#call>] handlers for processing exceptions
attr_accessor :active_job_queue_name_prefixing, :cache_visibility_timeout,
:groups, :launcher_executor, :reloader, :enable_reloading,
:start_callback, :stop_callback, :worker_executor, :worker_registry,
:exception_handlers
Comment on lines +26 to 40
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n lib/shoryuken/options.rb | sed -n '20,50p'

Repository: ruby-shoryuken/shoryuken

Length of output: 1766


🏁 Script executed:

# Check if YARD is available and what version
gem list | grep -i yard || echo "YARD not found via gem list"
which yard || echo "YARD not in PATH"

Repository: ruby-shoryuken/shoryuken

Length of output: 173


🌐 Web query:

YARD documentation multiple @return tags attribute methods how to document attributes

💡 Result:

Short answer — use @!attribute for attributes (with an indented docstring and a single @return describing the type/value), put attribute docs directly above attr_* (or use @!attribute when attributes are created dynamically), and use multiple @return tags only for distinct return cases (each starting with "if ...").

Examples and rules

  • Document a normal attr_accessor/reader/writer by placing the doc above the declaration and a single @return for the getter type. Example:

    @return [String] the name

    attr_accessor :name
    [1][2]

  • For dynamically defined attributes (DSL/meta-programming) use the @!attribute directive. You can specify [r], [w], or [rw] and include an indented docstring with @return:

    @!attribute [rw] publisher

    @return [String] publisher name

    cattr_accessor :publisher
    [2][3]

  • If getter and setter need different docs, keep docs on the reader/declaration and use @overload to describe separate behavior/signatures (or use @!method/@!attribute to create explicit docs). By default YARD exposes the reader. [1][2]

  • Multiple @return tags: allowed only when the method has distinct return cases — each @return should document a specific case and begin with "if …" (e.g. "@return [TypeA] if condition; @return [TypeB] if other condition"). Otherwise list multiple types in one @return (e.g. @return [String, nil]). [4][1]

References
[1] YARD Getting Started — Documenting Attributes (rubydoc.info).
[2] YARD Tags / @!attribute directive (rubydoc.info).
[3] Example usage / community guidance (Stack Overflow).
[4] YARD @return tag documentation and multiple-return-case guidance (rubydoc.info / YARD source).


Refactor documentation to use one @return per attribute method.

This pattern places 11 separate @return tags before a single attr_accessor declaration with 11 comma-separated attributes. YARD documentation conventions specify that each attribute method should have its own documentation block with a single @return tag describing the getter's return type. Multiple @return tags are only appropriate when documenting distinct conditional return cases within the same method, each prefixed with "if ...".

The current structure does not follow YARD best practices and may result in incorrect or missing documentation in the generated YARD output. Each attribute should either:

  1. Be documented individually above its own declaration, or
  2. Use the @!attribute [rw] directive with indented docstrings (useful for DSL-based attributes)

Apply similar corrections to lines 42–45 (attr_writer with 3 @return tags) and verify line 47–48 (attr_reader with 1 @return tag, which is correct).


# @!attribute [w] default_worker_options
# @return [Hash] the default options for workers
# @!attribute [w] sqs_client
# @return [Aws::SQS::Client] the SQS client instance
# @!attribute [w] logger
# @return [Logger] the logger instance
# @return [Hash] the default options for workers
# @return [Aws::SQS::Client] the SQS client instance
# @return [Logger] the logger instance
attr_writer :default_worker_options, :sqs_client, :logger

# @!attribute [r] sqs_client_receive_message_opts
# @return [Hash] options passed to SQS receive_message calls
# @return [Hash] options passed to SQS receive_message calls
attr_reader :sqs_client_receive_message_opts

# Initializes a new Options instance with default values
Expand Down
2 changes: 1 addition & 1 deletion lib/shoryuken/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def write_pid(options)
#
# @return [void]
def execute_soft_shutdown
logger.info { 'Received USR1, will soft shutdown down' }
logger.info { 'Received USR1, will soft shutdown' }

@launcher.stop
exit 0
Expand Down