repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/yoda_expression_spec.rb | spec/rubocop/cop/style/yoda_expression_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::YodaExpression, :config do
let(:cop_config) { { 'SupportedOperators' => ['*', '+'] } }
it 'registers an offense when numeric literal on left' do
expect_offense(<<~RUBY)
1 + x
^^^^^ Non-literal operand (`x`) should be first.
RUBY... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/quoted_symbols_spec.rb | spec/rubocop/cop/style/quoted_symbols_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::QuotedSymbols, :config do
shared_examples 'enforce single quotes' do
it 'accepts unquoted symbols' do
expect_no_offenses(<<~RUBY)
:a
RUBY
end
it 'accepts single quotes' do
expect_no_offenses(<<~RUBY)
:'a'... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/symbol_literal_spec.rb | spec/rubocop/cop/style/symbol_literal_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::SymbolLiteral, :config do
it 'registers an offense for word-line symbols using string syntax' do
expect_offense(<<~RUBY)
x = { :"test" => 0, :"other" => 1 }
^^^^^^^^ Do not use strings for word-like symbol literals.... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/def_with_parentheses_spec.rb | spec/rubocop/cop/style/def_with_parentheses_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::DefWithParentheses, :config do
it 'reports an offense for def with empty parens' do
expect_offense(<<~RUBY)
def func()
^^ Omit the parentheses in defs when the method doesn't accept any arguments.
end
RUBY
expect... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_regexp_argument_spec.rb | spec/rubocop/cop/style/redundant_regexp_argument_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantRegexpArgument, :config do
described_class::RESTRICT_ON_SEND.each do |method|
it "registers an offense and corrects when the method is `#{method}`" do
expect_offense(<<~RUBY, method: method)
'foo'.#{method}(/f/)
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/block_comments_spec.rb | spec/rubocop/cop/style/block_comments_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::BlockComments, :config do
it 'registers an offense for block comments' do
expect_offense(<<~RUBY)
=begin
^^^^^^ Do not use block comments.
comment
=end
RUBY
expect_correction(<<~RUBY)
# comment
RUBY
end... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/bisected_attr_accessor_spec.rb | spec/rubocop/cop/style/bisected_attr_accessor_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::BisectedAttrAccessor, :config do
it 'registers an offense and corrects when both accessors of the name exists' do
expect_offense(<<~RUBY)
class Foo
attr_reader :bar
^^^^ Combine both accessors into `attr_accessor ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/comment_annotation_spec.rb | spec/rubocop/cop/style/comment_annotation_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::CommentAnnotation, :config do
context 'with default RequireColon configuration (colon + space)' do
let(:cop_config) { { 'Keywords' => %w[TODO FIXME OPTIMIZE HACK REVIEW] } }
context 'missing colon' do
it 'registers an offense and adds c... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/nested_file_dirname_spec.rb | spec/rubocop/cop/style/nested_file_dirname_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::NestedFileDirname, :config do
context 'Ruby >= 3.1', :ruby31 do
it 'registers and corrects an offense when using `File.dirname(path)` nested two times' do
expect_offense(<<~RUBY)
File.dirname(File.dirname(path))
^^^^^^^^... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/zero_length_predicate_spec.rb | spec/rubocop/cop/style/zero_length_predicate_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ZeroLengthPredicate, :config do
context 'with arrays' do
it 'registers an offense for `array.length == 0`' do
expect_offense(<<~RUBY)
[1, 2, 3].length == 0
^^^^^^^^^^^^^^^^^^^^^ Use `empty?` instead of `length == 0`.
RU... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/option_hash_spec.rb | spec/rubocop/cop/style/option_hash_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::OptionHash, :config do
let(:cop_config) { { 'SuspiciousParamNames' => suspicious_names } }
let(:suspicious_names) { ['options'] }
it 'registers an offense' do
expect_offense(<<~RUBY)
def some_method(options = {})
^... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/expand_path_arguments_spec.rb | spec/rubocop/cop/style/expand_path_arguments_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ExpandPathArguments, :config do
it "registers an offense when using `File.expand_path('..', __FILE__)`" do
expect_offense(<<~RUBY)
File.expand_path('..', __FILE__)
^^^^^^^^^^^ Use `expand_path(__dir__)` instead of `expand_path('..... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/invertible_unless_condition_spec.rb | spec/rubocop/cop/style/invertible_unless_condition_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::InvertibleUnlessCondition, :config do
let(:cop_config) do
{
'InverseMethods' => {
:!= => :==,
:even? => :odd?,
:odd? => :even?,
:>= => :<,
:< => :>=,
:zero? => :nonzero?,
# non-standard... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/multiline_method_signature_spec.rb | spec/rubocop/cop/style/multiline_method_signature_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::MultilineMethodSignature, :config do
context 'when arguments span a single line' do
context 'when defining an instance method' do
it 'registers an offense and corrects when closing paren is on the following line' do
expect_offense(<<... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/global_std_stream_spec.rb | spec/rubocop/cop/style/global_std_stream_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::GlobalStdStream, :config do
it 'registers an offense and corrects when using std stream as const' do
expect_offense(<<~RUBY)
STDOUT.puts('hello')
^^^^^^ Use `$stdout` instead of `STDOUT`.
hash = { out: STDOUT, key: value }
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/slicing_with_range_spec.rb | spec/rubocop/cop/style/slicing_with_range_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::SlicingWithRange, :config do
context '<= Ruby 2.5', :ruby25, unsupported_on: :prism do
it 'reports no offense for array slicing end with `-1`' do
expect_no_offenses(<<~RUBY)
ary[1..-1]
RUBY
end
end
context '>= Ruby 2.6... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/data_inheritance_spec.rb | spec/rubocop/cop/style/data_inheritance_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::DataInheritance, :config do
context 'Ruby >= 3.2', :ruby32 do
it 'registers an offense when extending instance of `Data.define`' do
expect_offense(<<~RUBY)
class Person < Data.define(:first_name, :last_name)
^^... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb | spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::MethodCalledOnDoEndBlock, :config do
context 'with a multi-line do..end block' do
it 'registers an offense for a chained call' do
expect_offense(<<~RUBY)
a do
b
end.c
^^^^^ Avoid chaining a method call on a ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/class_methods_spec.rb | spec/rubocop/cop/style/class_methods_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ClassMethods, :config do
it 'registers an offense for methods using a class name' do
expect_offense(<<~RUBY)
class Test
def Test.some_method
^^^^ Use `self.some_method` instead of `Test.some_method`.
do_somethin... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/each_for_simple_loop_spec.rb | spec/rubocop/cop/style/each_for_simple_loop_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::EachForSimpleLoop, :config do
it 'does not register offense if range starting point is not constant' do
expect_no_offenses('(a..10).each {}')
end
it 'does not register offense if range endpoint is not constant' do
expect_no_offenses('(0..... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/special_global_vars_spec.rb | spec/rubocop/cop/style/special_global_vars_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::SpecialGlobalVars, :config do
context 'when style is use_english_names' do
context 'when add require English is disabled' do
let(:cop_config) do
{
'EnforcedStyle' => 'use_english_names',
'RequireEnglish' => false
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_current_directory_in_path_spec.rb | spec/rubocop/cop/style/redundant_current_directory_in_path_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantCurrentDirectoryInPath, :config do
it "registers an offense when using a current directory path in `require_relative '...'`" do
expect_offense(<<~RUBY)
require_relative './path/to/feature'
^^ Remove the redun... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/nil_comparison_spec.rb | spec/rubocop/cop/style/nil_comparison_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::NilComparison, :config do
context 'configured with predicate preferred' do
let(:cop_config) { { 'EnforcedStyle' => 'predicate' } }
it 'registers an offense for == nil' do
expect_offense(<<~RUBY)
x == nil
^^ Prefer the ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/keyword_parameters_order_spec.rb | spec/rubocop/cop/style/keyword_parameters_order_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::KeywordParametersOrder, :config do
it 'registers an offense and corrects when `kwoptarg` is before `kwarg`' do
expect_offense(<<~RUBY)
def m(arg, optional: 1, required:)
^^^^^^^^^^^ Place optional keyword parameters at the e... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_line_continuation_spec.rb | spec/rubocop/cop/style/redundant_line_continuation_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantLineContinuation, :config do
context 'when a line continuation precedes the arguments to an unparenthesized method call' do
shared_examples 'no offense' do |argument|
it "does not register an offense when the first argument is `#{ar... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_begin_spec.rb | spec/rubocop/cop/style/redundant_begin_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantBegin, :config do
it 'reports an offense for single line def with redundant begin block' do
expect_offense(<<~RUBY)
def func; begin; x; y; rescue; z end; end
^^^^^ Redundant `begin` block detected.
RUBY
expe... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_conditional_spec.rb | spec/rubocop/cop/style/redundant_conditional_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantConditional, :config do
it 'registers an offense for ternary with boolean results' do
expect_offense(<<~RUBY)
x == y ? true : false
^^^^^^^^^^^^^^^^^^^^^ This conditional expression can just be replaced by `x == y`.
RUBY
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/sole_nested_conditional_spec.rb | spec/rubocop/cop/style/sole_nested_conditional_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::SoleNestedConditional, :config do
let(:cop_config) { { 'AllowModifier' => false } }
it 'registers an offense and corrects when using nested `if` within `if`' do
expect_offense(<<~RUBY)
if foo
if bar
^^ Consider merging nes... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_freeze_spec.rb | spec/rubocop/cop/style/redundant_freeze_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantFreeze, :config do
let(:prefix) { nil }
shared_examples 'immutable objects' do |o|
it "registers an offense for frozen #{o}" do
expect_offense([prefix, <<~RUBY].compact.join("\n"), o: o)
CONST = %{o}.freeze
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/map_to_set_spec.rb | spec/rubocop/cop/style/map_to_set_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::MapToSet, :config do
%i[map collect].each do |method|
context "for `#{method}.to_set` with block arity 1" do
it 'registers an offense and corrects' do
expect_offense(<<~RUBY, method: method)
foo.#{method} { |x| [x, x * 2] }... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/alias_spec.rb | spec/rubocop/cop/style/alias_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::Alias, :config do
context 'when EnforcedStyle is prefer_alias_method' do
let(:cop_config) { { 'EnforcedStyle' => 'prefer_alias_method' } }
it 'registers an offense for alias with symbol args' do
expect_offense(<<~RUBY)
alias :al... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/file_read_spec.rb | spec/rubocop/cop/style/file_read_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::FileRead, :config do
it 'does not register an offense when not reading from the block variable' do
expect_no_offenses(<<~RUBY)
File.open(filename) do |f|
something_else.read
end
RUBY
end
it 'registers an offense for an... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/method_call_without_args_parentheses_spec.rb | spec/rubocop/cop/style/method_call_without_args_parentheses_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::MethodCallWithoutArgsParentheses, :config do
it 'registers an offense for parens in method call without args' do
expect_offense(<<~RUBY)
top.test()
^^ Do not use parentheses for method calls with no arguments.
RUBY
exp... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/numeric_literal_prefix_spec.rb | spec/rubocop/cop/style/numeric_literal_prefix_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::NumericLiteralPrefix, :config do
context 'octal literals' do
context 'when config is zero_with_o' do
let(:cop_config) { { 'EnforcedOctalStyle' => 'zero_with_o' } }
it 'registers an offense for prefixes `0` and `0O`' do
expect_... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/word_array_spec.rb | spec/rubocop/cop/style/word_array_spec.rb | # frozen_string_literal: true
require 'timeout'
RSpec.describe RuboCop::Cop::Style::WordArray, :config do
include EncodingHelper
before do
# Reset data which is shared by all instances of WordArray
described_class.largest_brackets = -Float::INFINITY
end
let(:other_cops) do
{
'Style/Percent... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/array_first_last_spec.rb | spec/rubocop/cop/style/array_first_last_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ArrayFirstLast, :config do
it 'registers an offense when using `[0]`' do
expect_offense(<<~RUBY)
arr[0]
^^^ Use `first`.
RUBY
expect_correction(<<~RUBY)
arr.first
RUBY
end
it 'registers an offense when using ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/return_nil_spec.rb | spec/rubocop/cop/style/return_nil_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ReturnNil, :config do
context 'when enforced style is `return`' do
let(:config) do
RuboCop::Config.new(
'Style/ReturnNil' => {
'EnforcedStyle' => 'return',
'SupportedStyles' => %w[return return_nil]
}
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/empty_else_spec.rb | spec/rubocop/cop/style/empty_else_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::EmptyElse, :config do
let(:missing_else_config) { {} }
shared_examples 'autocorrect' do |keyword|
context 'MissingElse is disabled' do
it 'does autocorrection' do
expect_offense(source)
expect_correction(corrected_source)... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_exception_spec.rb | spec/rubocop/cop/style/redundant_exception_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantException, :config do
shared_examples 'common behavior' do |keyword, runtime_error|
it "reports an offense for a #{keyword} with #{runtime_error}" do
expect_offense(<<~RUBY, keyword: keyword, runtime_error: runtime_error)
%{... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/next_spec.rb | spec/rubocop/cop/style/next_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::Next, :config do
let(:cop_config) { { 'MinBodyLength' => 1 } }
shared_examples 'iterators' do |condition|
let(:opposite) { condition == 'if' ? 'unless' : 'if' }
it "registers an offense for #{condition} inside of downto" do
expect_of... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/array_join_spec.rb | spec/rubocop/cop/style/array_join_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ArrayJoin, :config do
it 'registers an offense for an array followed by string' do
expect_offense(<<~RUBY)
%w(one two three) * ", "
^ Favor `Array#join` over `Array#*`.
RUBY
expect_correction(<<~RUBY)
%... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/when_then_spec.rb | spec/rubocop/cop/style/when_then_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::WhenThen, :config do
it 'registers an offense for when b;' do
expect_offense(<<~RUBY)
case a
when b; c
^ Do not use `when b;`. Use `when b then` instead.
end
RUBY
expect_correction(<<~RUBY)
case a
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/return_nil_in_predicate_method_definition_spec.rb | spec/rubocop/cop/style/return_nil_in_predicate_method_definition_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ReturnNilInPredicateMethodDefinition, :config do
context 'when defining predicate method' do
it 'registers an offense when using `return`' do
expect_offense(<<~RUBY)
def foo?
return if condition
^^^^^^ Return `fal... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_return_spec.rb | spec/rubocop/cop/style/redundant_return_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantReturn, :config do
let(:cop_config) { { 'AllowMultipleReturnValues' => false } }
it 'reports an offense for def with only a return' do
expect_offense(<<~RUBY)
def func
return something
^^^^^^ Redundant `return` de... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/conditional_assignment_assign_in_condition_spec.rb | spec/rubocop/cop/style/conditional_assignment_assign_in_condition_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ConditionalAssignment, :config do
shared_examples 'all variable types' do |variable|
it 'registers an offense assigning any variable type to ternary' do
expect_offense(<<~RUBY, variable: variable)
%{variable} = foo? ? 1 : 2
^... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | true |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/collection_methods_spec.rb | spec/rubocop/cop/style/collection_methods_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::CollectionMethods, :config do
cop_config = {
'PreferredMethods' => {
'collect' => 'map',
'inject' => 'reduce',
'detect' => 'find',
'find_all' => 'select',
'member?' => 'include?'
}
}
let(:cop_config) { cop_co... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/mixin_grouping_spec.rb | spec/rubocop/cop/style/mixin_grouping_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::MixinGrouping, :config do
context 'when configured with separated style' do
let(:cop_config) { { 'EnforcedStyle' => 'separated' } }
context 'when using `include`' do
it 'registers an offense for several mixins in one call' do
ex... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/lambda_call_spec.rb | spec/rubocop/cop/style/lambda_call_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::LambdaCall, :config do
context 'when style is set to call' do
let(:cop_config) { { 'EnforcedStyle' => 'call' } }
it 'registers an offense for x.()' do
expect_offense(<<~RUBY)
x.(a, b)
^^^^^^^^ Prefer the use of `x.call(a... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/bitwise_predicate_spec.rb | spec/rubocop/cop/style/bitwise_predicate_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::BitwisePredicate, :config do
context 'when checking any set bits' do
context 'when Ruby >= 2.5', :ruby25 do
it 'registers an offense when using `&` in conjunction with `predicate` for comparisons' do
expect_offense(<<~RUBY)
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/trailing_body_on_method_definition_spec.rb | spec/rubocop/cop/style/trailing_body_on_method_definition_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::TrailingBodyOnMethodDefinition, :config do
let(:config) { RuboCop::Config.new('Layout/IndentationWidth' => { 'Width' => 2 }) }
it 'registers an offense when body trails after method definition' do
expect_offense(<<~RUBY)
def some_method; ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/semicolon_spec.rb | spec/rubocop/cop/style/semicolon_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::Semicolon, :config do
let(:cop_config) { { 'AllowAsExpressionSeparator' => false } }
it 'registers an offense for a single expression' do
expect_offense(<<~RUBY)
puts "this is a test";
^ Do not use semicolons to... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/numeric_literals_spec.rb | spec/rubocop/cop/style/numeric_literals_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::NumericLiterals, :config do
let(:cop_config) { { 'MinDigits' => 5 } }
it 'registers an offense for a long undelimited integer' do
expect_offense(<<~RUBY)
a = 12345
^^^^^ Use underscores(_) as thousands separator and separate eve... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/global_vars_spec.rb | spec/rubocop/cop/style/global_vars_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::GlobalVars, :config do
cop_config = { 'AllowedVariables' => ['$allowed'] }
let(:cop_config) { cop_config }
it 'registers an offense for $custom' do
expect_offense(<<~RUBY)
puts $custom
^^^^^^^ Do not introduce global variabl... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/regexp_literal_spec.rb | spec/rubocop/cop/style/regexp_literal_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RegexpLiteral, :config do
let(:config) do
supported_styles = { 'SupportedStyles' => %w[slashes percent_r mixed] }
RuboCop::Config.new('Style/PercentLiteralDelimiters' =>
percent_literal_delimiters_config,
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/empty_literal_spec.rb | spec/rubocop/cop/style/empty_literal_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::EmptyLiteral, :config do
describe 'Empty Array' do
shared_examples 'registers_and_corrects' do |initializer:|
it "registers an offense for #{initializer}" do
expect_offense(<<~RUBY)
test = #{initializer}
#{... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/inverse_methods_spec.rb | spec/rubocop/cop/style/inverse_methods_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::InverseMethods, :config do
let(:config) do
RuboCop::Config.new(
'Style/InverseMethods' => {
'InverseMethods' => {
any?: :none?,
even?: :odd?,
present?: :blank?,
include?: :exclude?,
:... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/class_vars_spec.rb | spec/rubocop/cop/style/class_vars_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ClassVars, :config do
it 'registers an offense for class variable declaration' do
expect_offense(<<~RUBY)
class TestClass; @@test = 10; end
^^^^^^ Replace class var @@test with a class instance var.
RUBY
end
i... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/array_intersect_with_single_element_spec.rb | spec/rubocop/cop/style/array_intersect_with_single_element_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ArrayIntersectWithSingleElement, :config do
context 'with `include?(element)`' do
it 'does not register an offense' do
expect_no_offenses(<<~RUBY)
array.include?(element)
RUBY
end
end
context 'with `intersect?([element... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/trailing_body_on_module_spec.rb | spec/rubocop/cop/style/trailing_body_on_module_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::TrailingBodyOnModule, :config do
let(:config) { RuboCop::Config.new('Layout/IndentationWidth' => { 'Width' => 2 }) }
it 'registers an offense when body trails after module definition' do
expect_offense(<<~RUBY)
module Foo body
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/struct_inheritance_spec.rb | spec/rubocop/cop/style/struct_inheritance_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::StructInheritance, :config do
it 'registers an offense when extending instance of Struct' do
expect_offense(<<~RUBY)
class Person < Struct.new(:first_name, :last_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't extend an ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/rescue_standard_error_spec.rb | spec/rubocop/cop/style/rescue_standard_error_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RescueStandardError, :config do
context 'implicit' do
let(:cop_config) do
{ 'EnforcedStyle' => 'implicit',
'SupportedStyles' => %w[implicit explicit] }
end
context 'when rescuing in a begin block' do
it 'accepts rescui... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/empty_block_parameter_spec.rb | spec/rubocop/cop/style/empty_block_parameter_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::EmptyBlockParameter, :config do
it 'registers an offense for an empty block parameter with do-end style' do
expect_offense(<<~RUBY)
a do ||
^^ Omit pipes for the empty block parameters.
end
RUBY
expect_correction(<<... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/object_then_spec.rb | spec/rubocop/cop/style/object_then_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ObjectThen, :config do
context 'EnforcedStyle: then' do
let(:cop_config) { { 'EnforcedStyle' => 'then' } }
it 'does not register an offense for method names other than `then`' do
expect_no_offenses(<<~RUBY)
obj.map { |x| x.foo }... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/collection_literal_length_spec.rb | spec/rubocop/cop/metrics/collection_literal_length_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::CollectionLiteralLength, :config do
let(:cop_config) do
{
'LengthThreshold' => length_threshold
}
end
let(:length_threshold) { 10 }
let(:message) do
'Avoid hard coding large quantities of data in code. ' \
'Prefer readi... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/block_nesting_spec.rb | spec/rubocop/cop/metrics/block_nesting_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::BlockNesting, :config do
let(:cop_config) { { 'Max' => 2 } }
it 'accepts `Max` levels of nesting' do
expect_no_offenses(<<~RUBY)
if a
if b
puts b
end
end
RUBY
end
context '`Max + 1` levels of `if... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/parameter_lists_spec.rb | spec/rubocop/cop/metrics/parameter_lists_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::ParameterLists, :config do
let(:cop_config) { { 'Max' => 4, 'CountKeywordArgs' => true, 'MaxOptionalParameters' => 3 } }
it 'registers an offense for a method def with 5 parameters' do
expect_offense(<<~RUBY)
def meth(a, b, c, d, e)
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/class_length_spec.rb | spec/rubocop/cop/metrics/class_length_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::ClassLength, :config do
let(:cop_config) { { 'Max' => 5, 'CountComments' => false } }
it 'rejects a class with more than 5 lines' do
expect_offense(<<~RUBY)
class Test
^^^^^^^^^^ Class has too many lines. [6/5]
a = 1
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/module_length_spec.rb | spec/rubocop/cop/metrics/module_length_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::ModuleLength, :config do
let(:cop_config) { { 'Max' => 5, 'CountComments' => false } }
it 'rejects a module with more than 5 lines' do
expect_offense(<<~RUBY)
module Test
^^^^^^^^^^^ Module has too many lines. [6/5]
a = 1
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/block_length_spec.rb | spec/rubocop/cop/metrics/block_length_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::BlockLength, :config do
let(:cop_config) { { 'Max' => 2, 'CountComments' => false } }
shared_examples 'allow an offense on an allowed method' do |allowed, config_key|
before { cop_config[config_key] = [allowed] }
it 'still rejects other ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/method_length_spec.rb | spec/rubocop/cop/metrics/method_length_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::MethodLength, :config do
let(:cop_config) { { 'Max' => 5, 'CountComments' => false } }
context 'when method is an instance method' do
it 'does not register an offense when there are exactly `Max` lines' do
expect_no_offenses(<<~RUBY)
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb | spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::CyclomaticComplexity, :config do
context 'when Max is 1' do
let(:cop_config) { { 'Max' => 1 } }
it 'accepts a method with no decision points' do
expect_no_offenses(<<~RUBY)
def method_name
call_foo
end
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/abc_size_spec.rb | spec/rubocop/cop/metrics/abc_size_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::AbcSize, :config do
context 'when Max is 0' do
let(:cop_config) { { 'Max' => 0 } }
it 'accepts an empty method' do
expect_no_offenses(<<~RUBY)
def method_name
end
RUBY
end
it 'accepts an empty `define_me... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/perceived_complexity_spec.rb | spec/rubocop/cop/metrics/perceived_complexity_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::PerceivedComplexity, :config do
context 'when Max is 1' do
let(:cop_config) { { 'Max' => 1 } }
it 'accepts a method with no decision points' do
expect_no_offenses(<<~RUBY)
def method_name
call_foo
end
R... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/utils/code_length_calculator_spec.rb | spec/rubocop/cop/metrics/utils/code_length_calculator_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::Utils::CodeLengthCalculator do
describe '#calculate' do
context 'when method' do
it 'calculates method length' do
source = parse_source(<<~RUBY)
def test
a = 1
# a = 2
a = [
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/metrics/utils/abc_size_calculator_spec.rb | spec/rubocop/cop/metrics/utils/abc_size_calculator_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Metrics::Utils::AbcSizeCalculator do
describe '#calculate' do
subject(:vector) do
described_class.calculate(node,
discount_repeated_attributes: discount_repeated_attributes).last
end
let(:discount_repeated_a... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/redundant_described_class_as_subject_spec.rb | spec/rubocop/cop/internal_affairs/redundant_described_class_as_subject_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::RedundantDescribedClassAsSubject, :config do
it 'registers an offense when using `subject(:cop)` and `:config` is not specified in `describe`' do
expect_offense(<<~RUBY)
RSpec.describe RuboCop::Cop::Lint::RegexpAsCondition do
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new_spec.rb | spec/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::RedundantLetRuboCopConfigNew, :config do
it 'registers an offense when using `let(:config)` and `:config` is not specified in `describe`' do
expect_offense(<<~RUBY)
RSpec.describe RuboCop::Cop::Layout::SpaceAfterComma do
su... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/style_detected_api_use_spec.rb | spec/rubocop/cop/internal_affairs/style_detected_api_use_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::StyleDetectedApiUse, :config do
it 'registers an offense when correct_style_detected is used without a negative *_style_detected follow up' do
expect_offense(<<~RUBY)
def on_send(node)
^{} `correct_style_detected` method call... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/numblock_handler_spec.rb | spec/rubocop/cop/internal_affairs/numblock_handler_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::NumblockHandler, :config do
it 'registers an offense for cops with forgotten numblock handlers' do
expect_offense <<~RUBY
class Cop < Base
def on_block(node)
^^^^^^^^^^^^^^^^^^ Define on_numblock to handle blocks wi... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/offense_location_keyword_spec.rb | spec/rubocop/cop/internal_affairs/offense_location_keyword_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::OffenseLocationKeyword, :config do
context 'when `node.loc.selector` is passed' do
it 'registers an offense' do
expect_offense(<<~RUBY)
add_offense(node, location: node.loc.selector)
^^^^... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/empty_line_between_expect_offense_and_correction_spec.rb | spec/rubocop/cop/internal_affairs/empty_line_between_expect_offense_and_correction_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::EmptyLineBetweenExpectOffenseAndCorrection, :config do
it 'registers and corrects an offense when using no empty line between `expect_offense` and `expect_correction` ' \
'with heredoc argument' do
expect_offense(<<~RUBY)
expe... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/useless_message_assertion_spec.rb | spec/rubocop/cop/internal_affairs/useless_message_assertion_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::UselessMessageAssertion, :config do
it 'registers an offense for specs that assert using the MSG' do
expect_offense(<<~RUBY, 'example_spec.rb')
it 'uses described_class::MSG to specify the expected message' do
inspect_sourc... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/node_destructuring_spec.rb | spec/rubocop/cop/internal_affairs/node_destructuring_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::NodeDestructuring, :config do
context 'when destructuring using `node.children`' do
it 'registers an offense when receiver is named `node`' do
expect_offense(<<~RUBY, 'example_cop.rb')
lhs, rhs = node.children
^^^^^... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/redundant_location_argument_spec.rb | spec/rubocop/cop/internal_affairs/redundant_location_argument_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::RedundantLocationArgument, :config do
context 'when location argument is passed' do
context 'when location argument is :expression' do
it 'registers an offense' do
expect_offense(<<~RUBY, 'example_cop.rb')
add_off... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/cop_description_spec.rb | spec/rubocop/cop/internal_affairs/cop_description_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::CopDescription, :config do
context 'The description starts with `This cop ...`' do
it 'registers an offense and corrects if using just a verb' do
expect_offense(<<~RUBY)
module RuboCop
module Cop
modul... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/cop_enabled_spec.rb | spec/rubocop/cop/internal_affairs/cop_enabled_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::CopEnabled, :config do
context 'with .for_cop' do
it "registers an offense when using `config.for_cop(...)['Enabled']" do
expect_offense(<<~RUBY)
config.for_cop('Foo/Bar')['Enabled']
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/inherit_deprecated_cop_class_spec.rb | spec/rubocop/cop/internal_affairs/inherit_deprecated_cop_class_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::InheritDeprecatedCopClass, :config do
it 'registers an offense when using `Cop`' do
expect_offense(<<~RUBY)
class Foo < Cop
^^^ Use `Base` instead of `Cop`.
end
RUBY
end
it 'registers an offense whe... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/useless_restrict_on_send_spec.rb | spec/rubocop/cop/internal_affairs/useless_restrict_on_send_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::UselessRestrictOnSend, :config do
it 'registers an offense when using `RESTRICT_ON_SEND` and not defines send callback method' do
expect_offense(<<~RUBY)
class FooCop
RESTRICT_ON_SEND = %i[bad_method].freeze
^^^^^^^... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/method_name_end_with_spec.rb | spec/rubocop/cop/internal_affairs/method_name_end_with_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::MethodNameEndWith, :config do
it 'registers an offense if there is potentially usage of `assignment_method?`' do
expect_offense(<<~RUBY)
node.method_name.to_s.end_with?('=')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `assignmen... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/undefined_config_spec.rb | spec/rubocop/cop/internal_affairs/undefined_config_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::UndefinedConfig, :config, :isolated_environment do
include FileHelper
before do
create_file('config/default.yml', <<~YAML)
Test/Foo:
Defined: true
X/Y/Z:
Defined: true
YAML
stub_const('RuboCop::Co... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/location_exists_spec.rb | spec/rubocop/cop/internal_affairs/location_exists_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::LocationExists, :config do
context 'within an `and` node' do
context 'code that can be replaced with `loc?`' do
it 'registers an offense when the receiver does not match' do
expect_offense(<<~RUBY)
node.loc.respon... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/lambda_or_proc_spec.rb | spec/rubocop/cop/internal_affairs/lambda_or_proc_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::LambdaOrProc, :config do
it 'registers an offense when using `node.lambda? || node.proc?`' do
expect_offense(<<~RUBY)
node.lambda? || node.proc?
^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `node.lambda_or_proc?`.
RUBY
expect_corr... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/operator_keyword_spec.rb | spec/rubocop/cop/internal_affairs/operator_keyword_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::OperatorKeyword, :config do
it 'registers an offense when using `node.and_type? || node.or_type?`' do
expect_offense(<<~RUBY)
node.and_type? || node.or_type?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `node.operator_keyword?`.
R... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/node_type_predicate_spec.rb | spec/rubocop/cop/internal_affairs/node_type_predicate_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::NodeTypePredicate, :config do
context 'comparison node type check' do
it 'registers an offense and autocorrects' do
expect_offense(<<~RUBY)
node.type == :send
^^^^^^^^^^^^^^^^^^ Use `#send_type?` to check node type.... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/location_line_equality_comparison_spec.rb | spec/rubocop/cop/internal_affairs/location_line_equality_comparison_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::LocationLineEqualityComparison, :config do
it 'registers and corrects an offense when comparing `#loc.line` with LHS and RHS' do
expect_offense(<<~RUBY)
node.loc.line == node.parent.loc.line
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/on_send_without_on_csend_spec.rb | spec/rubocop/cop/internal_affairs/on_send_without_on_csend_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::OnSendWithoutOnCSend, :config do
it 'registers an offense when `on_send` is defined without `on_csend`' do
expect_offense(<<~RUBY)
class MyCop < RuboCop::Cop:Base
def on_send(node)
^^^^^^^^^^^^^^^^^ Cop defines `on_... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/processed_source_buffer_name_spec.rb | spec/rubocop/cop/internal_affairs/processed_source_buffer_name_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::ProcessedSourceBufferName, :config do
it 'registers an offense and corrects when using `processed_source.buffer.name` and `processed_source` is a method call' do
expect_offense(<<~RUBY)
processed_source.buffer.name
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/node_matcher_directive_spec.rb | spec/rubocop/cop/internal_affairs/node_matcher_directive_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::NodeMatcherDirective, :config do
%i[def_node_matcher def_node_search].each do |method|
it 'does not register an offense if the node matcher already has a directive' do
expect_no_offenses(<<~RUBY)
# @!method foo?(node)
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/create_empty_file_spec.rb | spec/rubocop/cop/internal_affairs/create_empty_file_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::CreateEmptyFile, :config do
it "registers an offense when using `create_file(path, '')" do
expect_offense(<<~RUBY)
create_file(path, '')
^^^^^^^^^^^^^^^^^^^^^ Use `create_empty_file(path)`.
RUBY
expect_correction(<<~... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/internal_affairs/node_type_multiple_predicates_spec.rb | spec/rubocop/cop/internal_affairs/node_type_multiple_predicates_spec.rb | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::NodeTypeMultiplePredicates, :config do
context 'in an `or` node with multiple node type predicate branches' do
it 'does not register an offense for type predicates called without a receiver' do
expect_no_offenses(<<~RUBY)
s... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.