Class: Shirobai::Cop::Rails::HttpPositionalArguments

Inherits:
RuboCop::Cop::Base
  • Object
show all
Extended by:
RuboCop::Cop::AutoCorrector, RuboCop::Cop::TargetRailsVersion
Includes:
RuboCop::Cop::RangeHelp, CandidateSupport
Defined in:
lib/shirobai/cop/rails/http_positional_arguments.rb

Overview

Drop-in Rust-backed reimplementation of Rails/HttpPositionalArguments (rubocop-rails 2.35.5), Architecture B.

Rust supplies candidate SEND ranges (bare-receiver HTTP verb calls with an action plus a data argument); this wrapper relocates each parser send node and runs stock's on_send (renamed investigate_send) plus autocorrect VERBATIM. The routing-block / rack-test guards, the http_request? / needs_conversion? matchers (kwsplat / forwarded / already-keyword hashes) and the full-node source rebuild all run on the parser AST, so offenses and -A bytes match stock exactly.

TargetRailsVersion: like stock, gated on requires_gem('railties', '>= 5.0') — silent on Rails < 5.0 or without railties in the target bundle. The Include: **/spec/**, **/test/** from the merged default.yml resolves through this wrapper's badge, exactly as for the stock cop.

Constant Summary collapse

MSG =
'Use keyword arguments instead of positional arguments for http call: `%<verb>s`.'
KEYWORD_ARGS =
%i[method params session body flash xhr as headers env to].freeze
ROUTING_METHODS =
%i[draw routes].freeze
RESTRICT_ON_SEND =
%i[get post put patch delete head].freeze

Class Method Summary collapse

Methods included from CandidateSupport

#on_new_investigation

Class Method Details

.badgeObject



36
# File 'lib/shirobai/cop/rails/http_positional_arguments.rb', line 36

def self.badge = RuboCop::Cop::Badge.parse(cop_name)

.bundle_args(_config) ⇒ Object

No behavioral config: the candidate list is a wake-up flag only.



39
40
41
# File 'lib/shirobai/cop/rails/http_positional_arguments.rb', line 39

def self.bundle_args(_config)
  []
end

.cop_nameObject



35
# File 'lib/shirobai/cop/rails/http_positional_arguments.rb', line 35

def self.cop_name = "Rails/HttpPositionalArguments"