Class: RuboCop::MCP::AutocorrectionRequest Private
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/rubocop/mcp/autocorrection_request.rb |
Overview
What an autocorrection request asks for, shared by every file it corrects. The keywords are the tool’s arguments, so an unknown one is refused.
Constant Summary
-
DEFAULT_MAX_OFFENSES_PER_COP =
# File 'lib/rubocop/mcp/autocorrection_request.rb', line 19
The offenses left over come back after the files are written, so they’re capped unless the agent asks otherwise: a result too big for the client would hide what was done.
5 -
PROPERTIES =
# File 'lib/rubocop/mcp/autocorrection_request.rb', line 9{ safety: { type: 'boolean' }, contextual: { type: 'boolean' }, dry_run: { type: 'boolean' }, max_offenses_per_cop: { type: 'integer', minimum: 1 } }.freeze
Class Method Summary
Instance Attribute Summary
- #dry_run? ⇒ Boolean readonly Internal use only
- #limit readonly Internal use only
- #scope readonly Internal use only
Instance Method Summary
-
#format_options
Internal use only
The options LSP::Runtime#format takes to apply the corrections
safetyandcontextualallow, from the cops the scope selects. -
#runtime_options
Internal use only
The options the LSP runtime takes for each call the request makes.
Constructor Details
.new(scope, safety: true, contextual: false, dry_run: false, max_offenses_per_cop: DEFAULT_MAX_OFFENSES_PER_COP) ⇒ AutocorrectionRequest
# File 'lib/rubocop/mcp/autocorrection_request.rb', line 23
def initialize(scope, safety: true, contextual: false, dry_run: false, max_offenses_per_cop: DEFAULT_MAX_OFFENSES_PER_COP) @scope = scope @safety = safety @contextual = contextual @dry_run = dry_run @limit = OffenseLimit.new(max_offenses_per_cop) end
Instance Attribute Details
#dry_run? ⇒ Boolean (readonly)
# File 'lib/rubocop/mcp/autocorrection_request.rb', line 32
def dry_run? @dry_run end
#limit (readonly)
[ GitHub ]# File 'lib/rubocop/mcp/autocorrection_request.rb', line 21
attr_reader :scope, :limit
#scope (readonly)
[ GitHub ]# File 'lib/rubocop/mcp/autocorrection_request.rb', line 21
attr_reader :scope, :limit
Instance Method Details
#format_options
The options LSP::Runtime#format takes to apply the corrections
safety and contextual allow, from the cops the scope selects.
# File 'lib/rubocop/mcp/autocorrection_request.rb', line 38
def command = @safety ? 'rubocop.formatAutocorrects' : 'rubocop.formatAutocorrectsAll' { command: command, options: } end
#runtime_options
The options the LSP runtime takes for each call the request makes.
Cops with AutoCorrect: contextual hold back corrections that get in
the way of code still being written, such as removing a variable that
is about to be used, so an agent that is done editing has to ask for them.
# File 'lib/rubocop/mcp/autocorrection_request.rb', line 47
def { **@scope., editing: !@contextual } end