Class: Shirobai::Cop::Lint::RequireParentheses
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Shirobai::Cop::Lint::RequireParentheses
- Defined in:
- lib/shirobai/cop/lint/require_parentheses.rb
Overview
Drop-in Rust reimplementation of ‘Lint/RequireParentheses`.
All detection (predicate-method send with an ‘&&`/`||` argument, or a ternary first-argument whose condition is `&&`/`||`) happens in Rust; Ruby only turns the byte offsets into offenses. No autocorrect, matching stock. Config-less, so this cop is always bundle-eligible.
Constant Summary collapse
- MSG =
"Use parentheses in the method call to avoid confusion about precedence."
Class Method Summary collapse
- .badge ⇒ Object
-
.bundle_args(_config) ⇒ Object
No packed args — the rule is config-less.
- .cop_name ⇒ Object
Instance Method Summary collapse
Class Method Details
.badge ⇒ Object
16 |
# File 'lib/shirobai/cop/lint/require_parentheses.rb', line 16 def self.badge = RuboCop::Cop::Badge.parse("Lint/RequireParentheses") |
.bundle_args(_config) ⇒ Object
No packed args — the rule is config-less. Present so the bundle ‘packed_config` builder treats this cop uniformly with its peers (currently a no-op; kept for parity with the other wrappers).
21 |
# File 'lib/shirobai/cop/lint/require_parentheses.rb', line 21 def self.bundle_args(_config) = [] |
.cop_name ⇒ Object
15 |
# File 'lib/shirobai/cop/lint/require_parentheses.rb', line 15 def self.cop_name = "Lint/RequireParentheses" |
Instance Method Details
#on_new_investigation ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/shirobai/cop/lint/require_parentheses.rb', line 23 def on_new_investigation offenses = Dispatch.offenses_for(processed_source, config, :require_parentheses) off = SourceOffsets.for(processed_source.raw_source) buffer = processed_source.buffer offenses.each do |start_offset, end_offset| range = Parser::Source::Range.new(buffer, off[start_offset], off[end_offset]) add_offense(range) end end |