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/redundant_array_flatten_spec.rb
spec/rubocop/cop/style/redundant_array_flatten_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantArrayFlatten, :config do it 'registers an offense for `x.flatten.join`' do expect_offense(<<~RUBY) x.flatten.join ^^^^^^^^ Remove the redundant `flatten`. RUBY expect_correction(<<~RUBY) x.join 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/nil_lambda_spec.rb
spec/rubocop/cop/style/nil_lambda_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NilLambda, :config do context 'block lambda' do it 'registers an offense when returning nil implicitly' do expect_offense(<<~RUBY) lambda do ^^^^^^^^^ Use an empty lambda instead of always returning nil. nil ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/explicit_block_argument_spec.rb
spec/rubocop/cop/style/explicit_block_argument_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ExplicitBlockArgument, :config do it 'registers an offense and corrects when block just yields its arguments' do expect_offense(<<~RUBY) def m items.something(first_arg) { |i| yield i } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/command_literal_spec.rb
spec/rubocop/cop/style/command_literal_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::CommandLiteral, :config do let(:config) do supported_styles = { 'SupportedStyles' => %w[backticks percent_x 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/exponential_notation_spec.rb
spec/rubocop/cop/style/exponential_notation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ExponentialNotation, :config do context 'EnforcedStyle is scientific' do let(:cop_config) { { 'EnforcedStyle' => 'scientific' } } it 'registers an offense for mantissa equal to 10' do expect_offense(<<~RUBY) 10e6 ^^^^ Us...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/comparable_between_spec.rb
spec/rubocop/cop/style/comparable_between_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ComparableBetween, :config do [ 'x >= min && x <= max', 'x >= min && max >= x', 'min <= x && x <= max', 'min <= x && max >= x', 'x <= max && x >= min', 'x <= max && min <= x', 'max >= x && x >= min', 'max >= x && min <=...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/hash_transform_keys_spec.rb
spec/rubocop/cop/style/hash_transform_keys_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::HashTransformKeys, :config do context 'when using Ruby 2.5 or newer', :ruby25 do context 'with inline block' do it 'flags each_with_object when transform_keys could be used' do expect_offense(<<~RUBY) x.each_with_object({})...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/multiline_memoization_spec.rb
spec/rubocop/cop/style/multiline_memoization_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MultilineMemoization, :config do shared_examples 'with all enforced styles' do context 'with a single line memoization' do it 'allows expression on first line' do expect_no_offenses('foo ||= bar') end it 'allows expressi...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/file_write_spec.rb
spec/rubocop/cop/style/file_write_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::FileWrite, :config do it 'does not register an offense for the `File.open` with multiline write block when not writing to the block variable' do expect_no_offenses(<<~RUBY) File.open(filename, 'w') do |f| something.write(content) ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_capital_w_spec.rb
spec/rubocop/cop/style/redundant_capital_w_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantCapitalW, :config do it 'registers no offense for normal arrays of strings' do expect_no_offenses('["one", "two", "three"]') end it 'registers no offense for normal arrays of strings with interpolation' do expect_no_offenses('["o...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/trailing_method_end_statement_spec.rb
spec/rubocop/cop/style/trailing_method_end_statement_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::TrailingMethodEndStatement, :config do let(:config) { RuboCop::Config.new('Layout/IndentationWidth' => { 'Width' => 2 }) } it 'registers an offense with trailing end on 2 line method' do expect_offense(<<~RUBY) def some_method foo; ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/super_arguments_spec.rb
spec/rubocop/cop/style/super_arguments_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SuperArguments, :config do shared_examples 'offense' do |description, args, forwarded_args = args| it "registers and corrects an offense when using def`#{description} (#{args}) => (#{forwarded_args})`" do expect_offense(<<~RUBY, forwarded_ar...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/unless_else_spec.rb
spec/rubocop/cop/style/unless_else_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::UnlessElse, :config do context 'unless with else' do it 'registers an offense' do expect_offense(<<~RUBY) unless x # negative 1 ^^^^^^^^^^^^^^^^^^^^^ Do not use `unless` with `else`. Rewrite these with the positive case first...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/encoding_spec.rb
spec/rubocop/cop/style/encoding_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Encoding, :config do it 'does not register an offense when no encoding present' do expect_no_offenses(<<~RUBY) def foo() end RUBY end it 'does not register an offense when encoding present but not UTF-8' do expect_no_offenses(<<...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/perl_backrefs_spec.rb
spec/rubocop/cop/style/perl_backrefs_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::PerlBackrefs, :config do it 'autocorrects puts $1 to puts Regexp.last_match(1)' do expect_offense(<<~RUBY) puts $1 ^^ Prefer `Regexp.last_match(1)` over `$1`. RUBY expect_correction(<<~RUBY) puts Regexp.last_match(1...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/unpack_first_spec.rb
spec/rubocop/cop/style/unpack_first_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::UnpackFirst, :config do context 'ruby version >= 2.4', :ruby24 do context 'registers an offense' do it 'when using `#unpack` with `#first`' do expect_offense(<<~RUBY) x.unpack('h*').first ^^^^^^^^^^^^^^^^^^ Use ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_double_splat_hash_braces_spec.rb
spec/rubocop/cop/style/redundant_double_splat_hash_braces_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantDoubleSplatHashBraces, :config do it 'registers an offense when using double splat hash braces' do expect_offense(<<~RUBY) do_something(**{foo: bar, baz: qux}) ^^^^^^^^^^^^^^^^^^^^^^ Remove the redundant double sp...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_heredoc_delimiter_quotes_spec.rb
spec/rubocop/cop/style/redundant_heredoc_delimiter_quotes_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantHeredocDelimiterQuotes, :config do it 'registers an offense when using the redundant heredoc delimiter single quotes with `<<~`' do expect_offense(<<~RUBY) do_something(<<~'EOS') ^^^^^^^^ Remove the redundant here...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/collection_compact_spec.rb
spec/rubocop/cop/style/collection_compact_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::CollectionCompact, :config, :ruby24 do it 'registers an offense and corrects when using `reject` on array to reject nils' do expect_offense(<<~RUBY) array.reject { |e| e.nil? } ^^^^^^^^^^^^^^^^^^^^^ Use `compact` instead of `reje...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_percent_q_spec.rb
spec/rubocop/cop/style/redundant_percent_q_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantPercentQ, :config do context 'with %q strings' do it 'registers an offense for only single quotes' do expect_offense(<<~RUBY) %q('hi') ^^^^^^^^ Use `%q` only for strings that contain both single quotes and double quo...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_self_spec.rb
spec/rubocop/cop/style/redundant_self_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantSelf, :config do it 'reports an offense a self receiver on an rvalue' do expect_offense(<<~RUBY) a = self.b ^^^^ Redundant `self` detected. RUBY expect_correction(<<~RUBY) a = b RUBY end it 'does no...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/hash_transform_values_spec.rb
spec/rubocop/cop/style/hash_transform_values_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::HashTransformValues, :config do context 'when using Ruby 2.4 or newer', :ruby24 do context 'with inline block' do it 'flags each_with_object when transform_values could be used' do expect_offense(<<~RUBY) x.each_with_object...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/module_function_spec.rb
spec/rubocop/cop/style/module_function_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ModuleFunction, :config do context 'when enforced style is `module_function`' do let(:cop_config) { { 'EnforcedStyle' => 'module_function' } } it 'registers an offense for `extend self` in a module' do expect_offense(<<~RUBY) mo...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/if_with_semicolon_spec.rb
spec/rubocop/cop/style/if_with_semicolon_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::IfWithSemicolon, :config do it 'registers an offense and corrects for one line if/;/end' do expect_offense(<<~RUBY) if cond; run else dont end ^^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use `if cond;` - use a ternary operator instead. RUBY ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb
spec/rubocop/cop/style/percent_literal_delimiters_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::PercentLiteralDelimiters, :config do let(:cop_config) { { 'PreferredDelimiters' => { 'default' => '[]' } } } context '`default` override' do let(:cop_config) { { 'PreferredDelimiters' => { 'default' => '[]', '%' => '()' } } } it 'allows al...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_parentheses_spec.rb
spec/rubocop/cop/style/redundant_parentheses_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantParentheses, :config do shared_examples 'redundant' do |expr, correct, type, options| it "registers an offense for parentheses around #{type}", *options do expect_offense(<<~RUBY, expr: expr) %{expr} ^{expr} Don't us...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
true
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/format_string_token_spec.rb
spec/rubocop/cop/style/format_string_token_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::FormatStringToken, :config do let(:enforced_style) { :annotated } let(:allowed_methods) { [] } let(:allowed_patterns) { [] } let(:mode) { :aggressive } let(:cop_config) do { 'EnforcedStyle' => enforced_style, 'SupportedStyles'...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/block_delimiters_spec.rb
spec/rubocop/cop/style/block_delimiters_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::BlockDelimiters, :config do shared_examples 'always accepted' do context 'with blocks that need braces to be valid ruby' do it 'accepts a multi-line block' do expect_no_offenses(<<~RUBY) puts [1, 2, 3].map { |n| ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
true
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/static_class_spec.rb
spec/rubocop/cop/style/static_class_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StaticClass, :config do it 'registers an offense when class has only class method' do expect_offense(<<~RUBY) class C ^^^^^^^ Prefer modules to classes with only class methods. def self.class_method; end end RUBY ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_self_assignment_branch_spec.rb
spec/rubocop/cop/style/redundant_self_assignment_branch_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantSelfAssignmentBranch, :config do it 'registers and corrects an offense when self-assigning redundant else ternary branch' do expect_offense(<<~RUBY) foo = condition ? bar : foo ^^^ Remove the self-assig...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/numbered_parameters_spec.rb
spec/rubocop/cop/style/numbered_parameters_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NumberedParameters, :config do context '>= Ruby 2.7', :ruby27 do context 'EnforcedStyle: allow_single_line' do let(:cop_config) { { 'EnforcedStyle' => 'allow_single_line' } } it 'registers an offense when using numbered parameters wit...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb
spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StringLiteralsInInterpolation, :config do context 'configured with single quotes preferred' do let(:cop_config) { { 'EnforcedStyle' => 'single_quotes' } } it 'registers an offense for double quotes within embedded expression in a string' do ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/copyright_spec.rb
spec/rubocop/cop/style/copyright_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Copyright, :config do let(:cop_config) { { 'Notice' => 'Copyright (\(c\) )?2015 Acme Inc' } } it 'does not register an offense when the notice is present' do expect_no_offenses(<<~RUBY) # Copyright 2015 Acme Inc. # test2 names...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_interpolation_spec.rb
spec/rubocop/cop/style/redundant_interpolation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantInterpolation, :config do it 'registers an offense for "#{1 + 1}"' do expect_offense(<<~'RUBY') "#{1 + 1}" ^^^^^^^^^^ Prefer `to_s` over string interpolation. RUBY expect_correction(<<~RUBY) (1 + 1).to_s RUB...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_format_spec.rb
spec/rubocop/cop/style/redundant_format_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantFormat, :config do %i[format sprintf].each do |method| context "with #{method}" do it 'does not register an offense when called with no arguments' do expect_no_offenses(<<~RUBY) #{method} #{method}() ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/double_cop_disable_directive_spec.rb
spec/rubocop/cop/style/double_cop_disable_directive_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::DoubleCopDisableDirective, :config do it 'registers an offense for duplicate disable directives' do expect_offense(<<~RUBY) def choose_move(who_to_move) # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/AbcSize # ruboc...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/character_literal_spec.rb
spec/rubocop/cop/style/character_literal_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::CharacterLiteral, :config do it 'registers an offense for character literals' do expect_offense(<<~RUBY) x = ?x ^^ Do not use the character literal - use string literal instead. RUBY expect_correction(<<~RUBY) x = 'x...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/mutable_constant_spec.rb
spec/rubocop/cop/style/mutable_constant_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MutableConstant, :config do let(:prefix) { nil } shared_examples 'mutable objects' do |o| context 'when assigning with =' do it "registers an offense for #{o} assigned to a constant " \ 'and corrects by adding .freeze' do ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/negated_while_spec.rb
spec/rubocop/cop/style/negated_while_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NegatedWhile, :config do it 'registers an offense for while with exclamation point condition' do expect_offense(<<~RUBY) while !a_condition ^^^^^^^^^^^^^^^^^^ Favor `until` over `while` for negative conditions. 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/empty_string_inside_interpolation_spec.rb
spec/rubocop/cop/style/empty_string_inside_interpolation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::EmptyStringInsideInterpolation, :config do context 'when EnforcedStyle is trailing_conditional' do let(:cop_config) { { 'EnforcedStyle' => 'trailing_conditional' } } it 'does not register an offense when if branch is not a literal' do e...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/frozen_string_literal_comment_spec.rb
spec/rubocop/cop/style/frozen_string_literal_comment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::FrozenStringLiteralComment, :config do context 'always' do let(:cop_config) { { 'Enabled' => true, 'EnforcedStyle' => 'always' } } it 'accepts an empty source' do expect_no_offenses('') end it 'accepts a source with no tokens' ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/preferred_hash_methods_spec.rb
spec/rubocop/cop/style/preferred_hash_methods_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::PreferredHashMethods, :config do context 'with enforced `short` style' do let(:cop_config) { { 'EnforcedStyle' => 'short' } } it 'registers an offense for has_key? with one arg' do expect_offense(<<~RUBY) o.has_key?(o) ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/string_chars_spec.rb
spec/rubocop/cop/style/string_chars_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StringChars, :config do it 'registers and corrects an offense when using `split(//)`' do expect_offense(<<~RUBY) string.split(//) ^^^^^^^^^ Use `chars` instead of `split(//)`. RUBY expect_correction(<<~RUBY) strin...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/dig_chain_spec.rb
spec/rubocop/cop/style/dig_chain_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::DigChain, :config do it 'does not register an offense for unchained `dig` without a receiver' do expect_no_offenses(<<~RUBY) dig RUBY end it 'does not register an offense for `X::dig`' do expect_no_offenses(<<~RUBY) X::dig...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/hash_like_case_spec.rb
spec/rubocop/cop/style/hash_like_case_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::HashLikeCase, :config do context 'MinBranchesCount: 2' do let(:cop_config) { { 'MinBranchesCount' => 2 } } it 'registers an offense when using `case-when` with string conditions and literal bodies of the same type' 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/env_home_spec.rb
spec/rubocop/cop/style/env_home_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::EnvHome, :config do it "registers and corrects an offense when using `ENV['HOME']`" do expect_offense(<<~RUBY) ENV['HOME'] ^^^^^^^^^^^ Use `Dir.home` instead. RUBY expect_correction(<<~RUBY) Dir.home RUBY end it...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/multiple_comparison_spec.rb
spec/rubocop/cop/style/multiple_comparison_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MultipleComparison, :config do it 'does not register an offense for comparing an lvar' do expect_no_offenses(<<~RUBY) a = "a" if a == "a" print a end RUBY end it 'registers an offense and corrects when `a` is com...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/select_by_regexp_spec.rb
spec/rubocop/cop/style/select_by_regexp_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SelectByRegexp, :config do shared_examples 'regexp match' do |method, correction| message = "Prefer `#{correction}` to `#{method}` with a regexp match." context "with #{method}" do it 'registers an offense and corrects for `match?`' do ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/negated_if_else_condition_spec.rb
spec/rubocop/cop/style/negated_if_else_condition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NegatedIfElseCondition, :config do it 'registers an offense and corrects when negating condition with `!` for `if-else`' do expect_offense(<<~RUBY) if !x ^^^^^ Invert the negated condition and swap the if-else branches. do_some...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/single_line_do_end_block_spec.rb
spec/rubocop/cop/style/single_line_do_end_block_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SingleLineDoEndBlock, :config do it 'registers an offense when using single line `do`...`end`' do expect_offense(<<~RUBY) foo do bar end ^^^^^^^^^^^^^^ Prefer multiline `do`...`end` block. 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/colon_method_call_spec.rb
spec/rubocop/cop/style/colon_method_call_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ColonMethodCall, :config do it 'registers an offense for instance method call' do expect_offense(<<~RUBY) test::method_name ^^ Do not use `::` for method calls. RUBY expect_correction(<<~RUBY) test.method_name RU...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/class_and_module_children_spec.rb
spec/rubocop/cop/style/class_and_module_children_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ClassAndModuleChildren, :config do context 'nested style' do let(:cop_config) { { 'EnforcedStyle' => 'nested' } } it 'registers an offense for not nested classes' do expect_offense(<<~RUBY) class FooClass::BarClass ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/yoda_condition_spec.rb
spec/rubocop/cop/style/yoda_condition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::YodaCondition, :config do context 'enforce not yoda' do let(:cop_config) { { 'EnforcedStyle' => 'forbid_for_all_comparison_operators' } } it 'accepts method call on receiver on left' do expect_no_offenses('b.value == 2') end it...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/inline_comment_spec.rb
spec/rubocop/cop/style/inline_comment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::InlineComment, :config do it 'registers an offense for a trailing inline comment' do expect_offense(<<~RUBY) two = 1 + 1 # A trailing inline comment ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid trailing inline comments. 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/it_assignment_spec.rb
spec/rubocop/cop/style/it_assignment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ItAssignment, :config do it 'registers an offense when assigning a local `it` variable' do expect_offense(<<~RUBY) it = 5 ^^ `it` is the default block parameter; consider another name. RUBY end it 'registers an offense when na...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/yaml_file_read_spec.rb
spec/rubocop/cop/style/yaml_file_read_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::YAMLFileRead, :config do context 'when Ruby >= 3.0', :ruby30 do it 'registers an offense when using `YAML.load` with `File.read` argument' do expect_offense(<<~RUBY) YAML.load(File.read(path)) ^^^^^^^^^^^^^^^^^^^^^ Use `...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/min_max_comparison_spec.rb
spec/rubocop/cop/style/min_max_comparison_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MinMaxComparison, :config do it 'registers and corrects an offense when using `a > b ? a : b`' do expect_offense(<<~RUBY) a > b ? a : b ^^^^^^^^^^^^^ Use `[a, b].max` instead. RUBY expect_correction(<<~RUBY) [a, b].max ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/safe_navigation_spec.rb
spec/rubocop/cop/style/safe_navigation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SafeNavigation, :config do let(:cop_config) { { 'ConvertCodeThatCanStartToReturnNil' => false } } let(:target_ruby_version) { 2.3 } it 'allows calls to methods not safeguarded by respond_to' do expect_no_offenses('foo.bar') end it 'allow...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
true
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/method_def_parentheses_spec.rb
spec/rubocop/cop/style/method_def_parentheses_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MethodDefParentheses, :config do shared_examples 'no parentheses' do # common to require_no_parentheses and # require_no_parentheses_except_multiline it 'reports an offense for def with parameters with parens' do expect_offense(<<~RU...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/accessor_grouping_spec.rb
spec/rubocop/cop/style/accessor_grouping_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::AccessorGrouping, :config do context 'when EnforcedStyle is grouped' do let(:cop_config) { { 'EnforcedStyle' => 'grouped' } } it 'registers an offense and corrects when using separated accessors' do expect_offense(<<~RUBY) class...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/single_line_methods_spec.rb
spec/rubocop/cop/style/single_line_methods_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SingleLineMethods, :config do let(:config) do RuboCop::Config.new('AllCops' => all_cops_config, 'Style/SingleLineMethods' => cop_config, 'Layout/IndentationWidth' => { 'Width' => 2 }, ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/combinable_defined_spec.rb
spec/rubocop/cop/style/combinable_defined_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::CombinableDefined, :config do it 'does not register an offense for a single `defined?`' do expect_no_offenses(<<~RUBY) defined?(Foo) RUBY end %i[&& and].each do |operator| context "joined by `#{operator}`" do it 'does not ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/array_coercion_spec.rb
spec/rubocop/cop/style/array_coercion_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ArrayCoercion, :config do it 'registers an offense and corrects when splatting variable into array' do expect_offense(<<~RUBY) [*paths].each { |path| do_something(path) } ^^^^^^^^ Use `Array(paths)` instead of `[*paths]`. 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_class_spec.rb
spec/rubocop/cop/style/trailing_body_on_class_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::TrailingBodyOnClass, :config do let(:config) { RuboCop::Config.new('Layout/IndentationWidth' => { 'Width' => 2 }) } it 'registers an offense when body trails after class definition' do expect_offense(<<~RUBY) class 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/infinite_loop_spec.rb
spec/rubocop/cop/style/infinite_loop_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::InfiniteLoop, :config do let(:config) { RuboCop::Config.new('Layout/IndentationWidth' => { 'Width' => 2 }) } %w(1 2.0 [1] {}).each do |lit| it "registers an offense for a while loop with #{lit} as condition" 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/random_with_offset_spec.rb
spec/rubocop/cop/style/random_with_offset_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RandomWithOffset, :config do it 'registers an offense when using rand(int) + offset' do expect_offense(<<~RUBY) rand(6) + 1 ^^^^^^^^^^^ Prefer ranges when generating random numbers instead of integers with offsets. 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/nested_ternary_operator_spec.rb
spec/rubocop/cop/style/nested_ternary_operator_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NestedTernaryOperator, :config do it 'registers an offense and corrects for a nested ternary operator expression' do expect_offense(<<~RUBY) a ? (b ? b1 : b2) : a2 ^^^^^^^^^^^ Ternary operators must not be nested. Prefer `if` or `...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/collection_querying_spec.rb
spec/rubocop/cop/style/collection_querying_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::CollectionQuerying, :config do it 'registers an offense for `.count.positive?`' do expect_offense(<<~RUBY) x.count.positive? ^^^^^^^^^^^^^^^ Use `any?` instead. RUBY expect_correction(<<~RUBY) x.any? 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/line_end_concatenation_spec.rb
spec/rubocop/cop/style/line_end_concatenation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::LineEndConcatenation, :config do it 'registers an offense for string concat at line end' do expect_offense(<<~RUBY) top = "test" + ^ Use `\\` instead of `+` to concatenate multiline strings. "top" RUBY expec...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/class_check_spec.rb
spec/rubocop/cop/style/class_check_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ClassCheck, :config do context 'when enforced style is `is_a?`' do let(:cop_config) { { 'EnforcedStyle' => 'is_a?' } } it 'registers an offense for `kind_of?` and corrects to `is_a?`' do expect_offense(<<~RUBY) x.kind_of? y ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/implicit_runtime_error_spec.rb
spec/rubocop/cop/style/implicit_runtime_error_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ImplicitRuntimeError, :config do it 'registers an offense for `raise` without error class' do expect_offense(<<~RUBY) raise 'message' ^^^^^^^^^^^^^^^ Use `raise` with an explicit exception class and message, rather than just a message....
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/mixin_usage_spec.rb
spec/rubocop/cop/style/mixin_usage_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MixinUsage, :config do context 'include' do it 'registers an offense when using outside class (used above)' do expect_offense(<<~RUBY) include M ^^^^^^^^^ `include` is used at the top level. Use inside `class` or `module`. ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/class_equality_comparison_spec.rb
spec/rubocop/cop/style/class_equality_comparison_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ClassEqualityComparison, :config do let(:cop_config) { { 'AllowedMethods' => [] } } it 'registers an offense and corrects when comparing class using `==` for equality' do expect_offense(<<~RUBY) var.class == Date ^^^^^^^^^^^^^ U...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/empty_case_condition_spec.rb
spec/rubocop/cop/style/empty_case_condition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::EmptyCaseCondition, :config do shared_examples 'detect/correct empty case, accept non-empty case' do it 'registers an offense and autocorrects' do expect_offense(source) expect_correction(corrected_source) end let(:source_wit...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/colon_method_definition_spec.rb
spec/rubocop/cop/style/colon_method_definition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ColonMethodDefinition, :config do it 'accepts a class method defined using .' do expect_no_offenses(<<~RUBY) class Foo def self.bar something end end RUBY end context 'using self' do it 'registers...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/self_assignment_spec.rb
spec/rubocop/cop/style/self_assignment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SelfAssignment, :config do %i[+ - * ** / % ^ << >> | & || &&].product(['x', '@x', '@@x']).each do |op, var| it "registers an offense for non-shorthand assignment #{op} and #{var}" do expect_offense(<<~RUBY, op: op, var: var) %{var} =...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/single_line_block_params_spec.rb
spec/rubocop/cop/style/single_line_block_params_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SingleLineBlockParams, :config do let(:cop_config) { { 'Methods' => [{ 'reduce' => %w[a e] }, { 'test' => %w[x y] }] } } it 'finds wrong argument names in calls with different syntax' do expect_offense(<<~RUBY) def m [0, 1].reduce...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/percent_q_literals_spec.rb
spec/rubocop/cop/style/percent_q_literals_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::PercentQLiterals, :config do shared_examples 'accepts quote characters' do it 'accepts single quotes' do expect_no_offenses("'hi'") end it 'accepts double quotes' do expect_no_offenses('"hi"') end end shared_examples ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/signal_exception_spec.rb
spec/rubocop/cop/style/signal_exception_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SignalException, :config do context 'when enforced style is `semantic`' do let(:cop_config) { { 'EnforcedStyle' => 'semantic' } } it 'registers an offense for raise in begin section' do expect_offense(<<~RUBY) begin ra...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_array_constructor_spec.rb
spec/rubocop/cop/style/redundant_array_constructor_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantArrayConstructor, :config do it 'registers an offense when using an empty array literal argument for `Array.new`' do expect_offense(<<~RUBY) Array.new([]) ^^^^^^^^^ Remove the redundant `Array` constructor. RUBY expec...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/guard_clause_spec.rb
spec/rubocop/cop/style/guard_clause_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::GuardClause, :config do let(:other_cops) do { 'Layout/LineLength' => { 'Enabled' => line_length_enabled, 'Max' => 80 } } end let(:line_length_enabled) { true } shared_examples 'reports offense' do |body| ...
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_character_class_spec.rb
spec/rubocop/cop/style/redundant_regexp_character_class_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantRegexpCharacterClass, :config do context 'with a character class containing a single character' do it 'registers an offense and corrects' do expect_offense(<<~RUBY) foo = /[a]/ ^^^ Redundant single-element cha...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/ambiguous_endless_method_definition_spec.rb
spec/rubocop/cop/style/ambiguous_endless_method_definition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::AmbiguousEndlessMethodDefinition, :config do context 'Ruby >= 3.0', :ruby30 do it 'does not register an offense for a non endless method' do expect_no_offenses(<<~RUBY) def foo end RUBY end %i[and or if unless ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_string_escape_spec.rb
spec/rubocop/cop/style/redundant_string_escape_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantStringEscape, :config do def wrap(contents) [l, contents, r].join end RSpec.shared_examples 'common no offenses' do |l, r| let(:l) { l } let(:r) { r } it 'does not register an offense without escapes' do expect_no_...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/endless_method_spec.rb
spec/rubocop/cop/style/endless_method_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::EndlessMethod, :config do context 'Ruby >= 3.0', :ruby30 do let(:other_cops) do { 'Layout/LineLength' => { 'Enabled' => line_length_enabled, 'Max' => 80 } } end let(:line_length_enabled) { tr...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/case_like_if_spec.rb
spec/rubocop/cop/style/case_like_if_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::CaseLikeIf, :config do let(:cop_config) { { 'MinBranchesCount' => 2 } } it 'registers an offense and corrects when using `===`' do expect_offense(<<~RUBY) if Integer === x ^^^^^^^^^^^^^^^^ Convert `if-elsif` to `case-when`. el...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/raise_args_spec.rb
spec/rubocop/cop/style/raise_args_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RaiseArgs, :config do context 'when enforced style is compact' do let(:cop_config) { { 'EnforcedStyle' => 'compact' } } context 'with a raise with 2 args' do it 'reports an offense' do expect_offense(<<~RUBY) raise Run...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/file_touch_spec.rb
spec/rubocop/cop/style/file_touch_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::FileTouch, :config do it 'registers an offense when using `File.open` in append mode with empty block' do expect_offense(<<~RUBY) File.open(filename, 'a') {} ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `FileUtils.touch(filename)` instead of `File....
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/auto_resource_cleanup_spec.rb
spec/rubocop/cop/style/auto_resource_cleanup_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::AutoResourceCleanup, :config do it 'registers an offense for File.open without block' do expect_offense(<<~RUBY) File.open("filename") ^^^^^^^^^^^^^^^^^^^^^ Use the block version of `File.open`. RUBY end it 'registers an offen...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/numbered_parameters_limit_spec.rb
spec/rubocop/cop/style/numbered_parameters_limit_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NumberedParametersLimit, :config do let(:cop_config) { { 'Max' => max } } let(:max) { 2 } context 'with Ruby >= 2.7', :ruby27 do it 'does not register an offense for a normal block with too many parameters' 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/style/multiline_if_then_spec.rb
spec/rubocop/cop/style/multiline_if_then_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MultilineIfThen, :config do it 'does not get confused by empty elsif branch' do expect_no_offenses(<<~RUBY) if cond elsif cond end RUBY end it 'registers an offense for then in multiline if' 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/case_equality_spec.rb
spec/rubocop/cop/style/case_equality_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::CaseEquality, :config do shared_examples 'offenses' do it 'does not fail when the receiver is implicit' do expect_no_offenses(<<~RUBY) puts "No offense" RUBY end it 'does not register an offense for === when the receiv...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/hash_each_methods_spec.rb
spec/rubocop/cop/style/hash_each_methods_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::HashEachMethods, :config do context 'when node matches a keys#each or values#each' do context 'when receiver is a send' do it 'registers an offense autocorrects foo#keys.each to foo#each_key' do expect_offense(<<~RUBY) foo....
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_with_args_parentheses_spec.rb
spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MethodCallWithArgsParentheses, :config do shared_examples 'endless methods' do |omit: false| context 'endless methods', :ruby30 do context 'with arguments' do it 'requires method calls to have parens' do expect_no_offenses(...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
true
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/constant_visibility_spec.rb
spec/rubocop/cop/style/constant_visibility_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ConstantVisibility, :config do context 'when defining a constant in a class' do context 'with a single-statement body' do it 'registers an offense when not using a visibility declaration' do expect_offense(<<~RUBY) class Fo...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/dir_spec.rb
spec/rubocop/cop/style/dir_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Dir, :config do context 'when using `#expand_path` and `#dirname`' do it 'registers an offense' do expect_offense(<<~RUBY) File.expand_path(File.dirname(__FILE__)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `__dir__` to get...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/stderr_puts_spec.rb
spec/rubocop/cop/style/stderr_puts_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StderrPuts, :config do it "registers an offense when using `$stderr.puts('hello')`" do expect_offense(<<~RUBY) $stderr.puts('hello') ^^^^^^^^^^^^ Use `warn` instead of `$stderr.puts` to allow such output to be disabled. RUBY e...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/string_literals_spec.rb
spec/rubocop/cop/style/string_literals_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StringLiterals, :config do context 'configured with single quotes preferred' do let(:cop_config) { { 'EnforcedStyle' => 'single_quotes' } } it 'registers an offense for double quotes when single quotes suffice' do expect_offense(<<~'RUB...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/hash_fetch_chain_spec.rb
spec/rubocop/cop/style/hash_fetch_chain_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::HashFetchChain, :config do context 'ruby >= 2.3' do context 'with chained `fetch` methods' do shared_examples 'fetch chain' do |argument| context "when the 2nd argument is `#{argument}`" do it 'does not register an offense ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/documentation_method_spec.rb
spec/rubocop/cop/style/documentation_method_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::DocumentationMethod, :config do let(:require_for_non_public_methods) { false } let(:config) do RuboCop::Config.new( 'Style/CommentAnnotation' => { 'Keywords' => %w[TODO FIXME OPTIMIZE HACK REVIEW] }, 'Style/Documentati...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false