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/lint/number_conversion_spec.rb
spec/rubocop/cop/lint/number_conversion_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NumberConversion, :config do context 'registers an offense' do it 'when using `#to_i`' do expect_offense(<<~RUBY) "10".to_i ^^^^^^^^^ Replace unsafe number conversion with number class parsing, instead of using `"10".to_i`, us...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_method_definition_spec.rb
spec/rubocop/cop/lint/useless_method_definition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessMethodDefinition, :config do it 'does not register an offense for empty constructor' do expect_no_offenses(<<~RUBY) class Foo def initialize(arg1, arg2) end end RUBY end it 'does not register an offense f...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_cop_enable_directive_spec.rb
spec/rubocop/cop/lint/redundant_cop_enable_directive_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantCopEnableDirective, :config do describe 'when cop is disabled in the configuration' do let(:other_cops) { { 'Layout/LineLength' => { 'Enabled' => false } } } it 'registers no offense when enabling the cop' 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/lint/shared_mutable_default_spec.rb
spec/rubocop/cop/lint/shared_mutable_default_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SharedMutableDefault, :config do context 'when line is unrelated' do it 'does not register an offense' do expect_no_offenses(<<~RUBY) [] {} Array.new Hash.new Hash.new { |h, k| h[k] = [] } Hash....
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/numeric_operation_with_constant_result_spec.rb
spec/rubocop/cop/lint/numeric_operation_with_constant_result_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NumericOperationWithConstantResult, :config do it 'registers an offense when a variable is multiplied by 0' do expect_offense(<<~RUBY) x * 0 ^^^^^ Numeric operation with a constant result detected. RUBY expect_correction(<<~RUB...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/shadowed_argument_spec.rb
spec/rubocop/cop/lint/shadowed_argument_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ShadowedArgument, :config do let(:cop_config) { { 'IgnoreImplicitReferences' => false } } describe 'method argument shadowing' do context 'when a single argument is shadowed' do it 'registers an offense' 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/lint/identity_comparison_spec.rb
spec/rubocop/cop/lint/identity_comparison_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::IdentityComparison, :config do it 'registers an offense and corrects when using `==` for comparison between `object_id`s' do expect_offense(<<~RUBY) foo.object_id == bar.object_id ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `equal?` instead of `...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_hash_key_spec.rb
spec/rubocop/cop/lint/duplicate_hash_key_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateHashKey, :config do context 'when there is a duplicated key in the hash literal' do it 'registers an offense' do expect_offense(<<~RUBY) hash = { 'otherkey' => 'value', 'key' => 'value', 'key' => 'hi' } ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/each_with_object_argument_spec.rb
spec/rubocop/cop/lint/each_with_object_argument_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EachWithObjectArgument, :config do it 'registers an offense for fixnum argument' do expect_offense(<<~RUBY) collection.each_with_object(0) { |e, a| a + e } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The argument to each_with_object cannot be immuta...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/non_deterministic_require_order_spec.rb
spec/rubocop/cop/lint/non_deterministic_require_order_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NonDeterministicRequireOrder, :config do context 'when requiring files' do context 'when Ruby 3.0 or higher', :ruby30 do context 'with `Dir[]`' do it 'does not register an offense' 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/lint/constant_overwritten_in_rescue_spec.rb
spec/rubocop/cop/lint/constant_overwritten_in_rescue_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ConstantOverwrittenInRescue, :config do it 'registers an offense when overriding an exception with an exception result' do expect_offense(<<~RUBY) begin something rescue => StandardError ^^ `StandardError` is overwr...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_require_statement_spec.rb
spec/rubocop/cop/lint/redundant_require_statement_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantRequireStatement, :config do it 'registers an offense when using requiring `enumerator`' do expect_offense(<<~RUBY) require 'enumerator' ^^^^^^^^^^^^^^^^^^^^ Remove unnecessary `require` statement. require 'uri' RUBY ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/percent_string_array_spec.rb
spec/rubocop/cop/lint/percent_string_array_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::PercentStringArray, :config do context 'detecting quotes or commas in a %w/%W string' do %w[w W].each do |char| it 'accepts tokens without quotes or commas' do expect_no_offenses("%#{char}(foo bar baz)") end [ %(%...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/circular_argument_reference_spec.rb
spec/rubocop/cop/lint/circular_argument_reference_spec.rb
# frozen_string_literal: true # Run test with Ruby 3.4 because this cop cannot handle invalid syntax between Ruby 2.7 and 3.3. RSpec.describe RuboCop::Cop::Lint::CircularArgumentReference, :config, :ruby34 do describe 'circular argument references in ordinal arguments' do context 'when the method contains a circ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/unexpected_block_arity_spec.rb
spec/rubocop/cop/lint/unexpected_block_arity_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnexpectedBlockArity, :config do let(:cop_config) { { 'Methods' => { 'reduce' => 2, 'inject' => 2 } } } context 'with a block' do context 'when given two parameters' do it 'does not register an offense' do expect_no_offenses(<<~RUB...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_rescue_exception_spec.rb
spec/rubocop/cop/lint/duplicate_rescue_exception_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateRescueException, :config do it 'registers an offense when duplicate exception exists' do expect_offense(<<~RUBY) begin something rescue FirstError rescue SecondError, FirstError ^^^^^^^^^...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/percent_symbol_array_spec.rb
spec/rubocop/cop/lint/percent_symbol_array_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::PercentSymbolArray, :config do context 'detecting colons or commas in a %i/%I string' do %w[i I].each do |char| it 'accepts tokens without colons or commas' do expect_no_offenses("%#{char}(foo bar baz)") end it 'accepts l...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/mixed_regexp_capture_types_spec.rb
spec/rubocop/cop/lint/mixed_regexp_capture_types_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::MixedRegexpCaptureTypes, :config do it 'registers an offense when both of named and numbered captures are used' do expect_offense(<<~RUBY) /(?<foo>bar)(baz)/ ^^^^^^^^^^^^^^^^^^ Do not mix named captures and numbered captures in a Regexp...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/format_parameter_mismatch_spec.rb
spec/rubocop/cop/lint/format_parameter_mismatch_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::FormatParameterMismatch, :config do shared_examples 'variables' do |variable| it 'does not register an offense for % called on a variable' do expect_no_offenses(<<~RUBY) #{variable} = '%s' #{variable} % [foo] RUBY en...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/trailing_comma_in_attribute_declaration_spec.rb
spec/rubocop/cop/lint/trailing_comma_in_attribute_declaration_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::TrailingCommaInAttributeDeclaration, :config do it 'registers an offense when using trailing comma' do expect_offense(<<~RUBY) class Foo attr_reader :bar, ^ Avoid leaving a trailing comma in attribute declarati...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/unreachable_code_spec.rb
spec/rubocop/cop/lint/unreachable_code_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnreachableCode, :config do def wrap(str) head = <<~RUBY def something array.each do |item| RUBY tail = <<~RUBY end end RUBY body = str.each_line.map { |line| " #{line}" }.join head + body + tail ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_default_value_argument_spec.rb
spec/rubocop/cop/lint/useless_default_value_argument_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessDefaultValueArgument, :config do context 'with `fetch`' do it 'registers an offense for `x.fetch(key, default_value) { block_value }`' do expect_offense(<<~RUBY) x.fetch(key, default_value) { block_value } ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/deprecated_open_ssl_constant_spec.rb
spec/rubocop/cop/lint/deprecated_open_ssl_constant_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DeprecatedOpenSSLConstant, :config do it 'registers an offense with cipher constant and two arguments and corrects' do expect_offense(<<~RUBY) OpenSSL::Cipher::AES.new(128, :GCM) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `OpenSSL::Cipher....
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/rescue_exception_spec.rb
spec/rubocop/cop/lint/rescue_exception_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RescueException, :config do it 'registers an offense for rescue from Exception' do expect_offense(<<~RUBY) begin something rescue Exception ^^^^^^^^^^^^^^^^ Avoid rescuing the `Exception` class. Perhaps you meant to rescue...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/deprecated_constants_spec.rb
spec/rubocop/cop/lint/deprecated_constants_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DeprecatedConstants, :config do let(:cop_config) do { 'DeprecatedConstants' => { 'NIL' => { 'Alternative' => 'nil', 'DeprecatedVersion' => '2.4' }, 'TRUE' => { 'Alternative' => 'true', 'DeprecatedVersion' => '2.4' }, '...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/literal_assignment_in_condition_spec.rb
spec/rubocop/cop/lint/literal_assignment_in_condition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::LiteralAssignmentInCondition, :config do it 'registers an offense when assigning integer literal to local variable in `if` condition' do expect_offense(<<~RUBY) if test = 42 ^^^^ Don't use literal assignment `= 42` in conditiona...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/empty_when_spec.rb
spec/rubocop/cop/lint/empty_when_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyWhen, :config do let(:cop_config) { { 'AllowComments' => false } } context 'when a `when` body is missing' do it 'registers an offense for a missing when body' do expect_offense(<<~RUBY) case foo when :bar then 1 ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/cop_directive_syntax_spec.rb
spec/rubocop/cop/lint/cop_directive_syntax_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::CopDirectiveSyntax, :config do it 'does not register an offense for a single cop name' do expect_no_offenses(<<~RUBY) # rubocop:disable Layout/LineLength RUBY end it 'does not register an offense for a single cop department' do e...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/assignment_in_condition_spec.rb
spec/rubocop/cop/lint/assignment_in_condition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::AssignmentInCondition, :config do let(:cop_config) { { 'AllowSafeAssignment' => true } } it 'registers an offense for lvar assignment in condition' do expect_offense(<<~RUBY) if test = 10 ^ Use `==` if you meant to do a compa...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/rand_one_spec.rb
spec/rubocop/cop/lint/rand_one_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RandOne, :config do shared_examples 'offenses' do |source| describe source do it 'registers an offense' do expect_offense(<<~RUBY, source: source) %{source} ^{source} `#{source}` always returns `0`. [...] R...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb
spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ShadowingOuterLocalVariable, :config do context 'when a block argument has same name as an outer scope variable' do it 'registers an offense' do expect_offense(<<~RUBY) def some_method foo = 1 puts foo 1....
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/ambiguous_operator_precedence_spec.rb
spec/rubocop/cop/lint/ambiguous_operator_precedence_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::AmbiguousOperatorPrecedence, :config do it 'does not register an offense when there is only one operator in the expression' do expect_no_offenses(<<~RUBY) a + b RUBY end it 'does not register an offense when all operators in the expr...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb
spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnderscorePrefixedVariableName, :config do let(:cop_config) { { 'AllowKeywordBlockArguments' => false } } context 'when an underscore-prefixed variable is used' do it 'registers an offense' do expect_offense(<<~RUBY) def some_metho...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/unified_integer_spec.rb
spec/rubocop/cop/lint/unified_integer_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnifiedInteger, :config do shared_examples 'registers an offense' do |klass| context 'target ruby version < 2.4', :ruby23, unsupported_on: :prism do context "when #{klass}" do context 'without any decorations' do it 'registe...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/require_relative_self_path_spec.rb
spec/rubocop/cop/lint/require_relative_self_path_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RequireRelativeSelfPath, :config do it 'registers an offense when using `require_relative` with self file path argument' do expect_offense(<<~RUBY, 'foo.rb') require_relative 'foo' ^^^^^^^^^^^^^^^^^^^^^^ Remove the `require_relative` th...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/ordered_magic_comments_spec.rb
spec/rubocop/cop/lint/ordered_magic_comments_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::OrderedMagicComments, :config do it 'registers an offense and corrects when an `encoding` magic comment ' \ 'does not precede all other magic comments' do expect_offense(<<~RUBY) # frozen_string_literal: true # encoding: ascii ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/disjunctive_assignment_in_constructor_spec.rb
spec/rubocop/cop/lint/disjunctive_assignment_in_constructor_spec.rb
# frozen_string_literal: true RSpec.describe( RuboCop::Cop::Lint::DisjunctiveAssignmentInConstructor, :config ) do context 'empty constructor' do it 'accepts' do expect_no_offenses(<<~RUBY) class Banana def initialize end end RUBY end end context 'cons...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/mixed_case_range_spec.rb
spec/rubocop/cop/lint/mixed_case_range_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::MixedCaseRange, :config do let(:message) do 'Ranges from upper to lower case ASCII letters may include unintended ' \ 'characters. Instead of `A-z` (which also includes several symbols) ' \ 'specify each range individually: `A-Za-z` and...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/boolean_symbol_spec.rb
spec/rubocop/cop/lint/boolean_symbol_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::BooleanSymbol, :config do it 'registers an offense when using `:true`' do expect_offense(<<~RUBY) :true ^^^^^ Symbol with a boolean name - you probably meant to use `true`. RUBY expect_correction(<<~RUBY) true RUBY ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/safe_navigation_chain_spec.rb
spec/rubocop/cop/lint/safe_navigation_chain_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SafeNavigationChain, :config do shared_examples 'accepts' do |name, code| it "accepts usages of #{name}" do expect_no_offenses(code) end end context 'TargetRubyVersion >= 2.3', :ruby23 do [ ['ordinary method chain', 'x.foo....
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/float_out_of_range_spec.rb
spec/rubocop/cop/lint/float_out_of_range_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::FloatOutOfRange, :config do it 'does not register an offense for 0.0' do expect_no_offenses('0.0') end it 'does not register an offense for tiny little itty bitty floats' do expect_no_offenses('1.1e-100') end it 'does not register an ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/empty_expression_spec.rb
spec/rubocop/cop/lint/empty_expression_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyExpression, :config do context 'when used as a standalone expression' do it 'registers an offense' do expect_offense(<<~RUBY) () ^^ Avoid empty expressions. RUBY end context 'with nested empty expressions' ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/float_comparison_spec.rb
spec/rubocop/cop/lint/float_comparison_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::FloatComparison, :config do it 'registers an offense when comparing with float' do expect_offense(<<~RUBY) x == 0.1 ^^^^^^^^ Avoid equality comparisons of floats as they are unreliable. 0.1 == x ^^^^^^^^ Avoid equality compa...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/no_return_in_begin_end_blocks_spec.rb
spec/rubocop/cop/lint/no_return_in_begin_end_blocks_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NoReturnInBeginEndBlocks, :config do shared_examples 'rejects return inside a block' do |operator| it "rejects a return statement inside a block when using #{operator} for local variable" do expect_offense(<<~RUBY) some_value = 10 ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/literal_as_condition_spec.rb
spec/rubocop/cop/lint/literal_as_condition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::LiteralAsCondition, :config do %w(1 2.0 [1] {} :sym :"#{a}").each do |lit| it "registers an offense for truthy literal #{lit} in if" do expect_offense(<<~RUBY, lit: lit) if %{lit} ^{lit} Literal `#{lit}` appeared as a condi...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/ambiguous_block_association_spec.rb
spec/rubocop/cop/lint/ambiguous_block_association_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::AmbiguousBlockAssociation, :config do shared_examples 'accepts' do |code| it 'does not register an offense' do expect_no_offenses(code) end end it_behaves_like 'accepts', 'foo == bar { baz a }' it_behaves_like 'accepts', 'foo ->(a)...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/ensure_return_spec.rb
spec/rubocop/cop/lint/ensure_return_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EnsureReturn, :config do it 'registers an offense but does not correct for return in ensure' do expect_offense(<<~RUBY) begin something ensure file.close return ^^^^^^ Do not return from an `ensure` block...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb
spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessElseWithoutRescue, :config do context 'with `else` without `rescue`', :ruby25, unsupported_on: :prism do it 'registers an offense' do expect_offense(<<~RUBY) begin do_something else ^^^^ `else` without...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_methods_spec.rb
spec/rubocop/cop/lint/duplicate_methods_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateMethods, :config do shared_examples 'in scope' do |type, opening_line| it "registers an offense for duplicate method in #{type}" do expect_offense(<<~RUBY) #{opening_line} def some_method implement 1 ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/to_json_spec.rb
spec/rubocop/cop/lint/to_json_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ToJSON, :config do it 'registers an offense and corrects using `#to_json` without arguments' do expect_offense(<<~RUBY) def to_json ^^^^^^^^^^^ `#to_json` requires an optional argument to be parsable via JSON.generate(obj). end ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_safe_navigation_spec.rb
spec/rubocop/cop/lint/redundant_safe_navigation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantSafeNavigation, :config do let(:cop_config) do { 'AllowedMethods' => %w[respond_to?], 'AdditionalNilMethods' => %w[present?] } end it 'registers an offense and corrects when `&.` is used for camel case const receiver' 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/lint/empty_in_pattern_spec.rb
spec/rubocop/cop/lint/empty_in_pattern_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyInPattern, :config do let(:cop_config) { { 'AllowComments' => false } } context 'when a `in` body is missing', :ruby27 do it 'registers an offense for a missing `in` body' do expect_offense(<<~RUBY) case foo in [a] the...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_regexp_character_class_element_spec.rb
spec/rubocop/cop/lint/duplicate_regexp_character_class_element_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateRegexpCharacterClassElement, :config do context 'with a repeated character class element' do it 'registers an offense and corrects' do expect_offense(<<~RUBY) foo = /[xyx]/ ^ Duplicate element inside regexp ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_access_modifier_spec.rb
spec/rubocop/cop/lint/useless_access_modifier_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessAccessModifier, :config do context 'when an access modifier has no effect' do it 'registers an offense and corrects' do expect_offense(<<~RUBY) class SomeClass def some_method puts 10 end ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/non_atomic_file_operation_spec.rb
spec/rubocop/cop/lint/non_atomic_file_operation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NonAtomicFileOperation, :config do it 'registers an offense when use `FileTest.exist?` before creating file' do expect_offense(<<~RUBY) unless FileTest.exist?(path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Remove unnecessary existence check `FileTe...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/erb_new_arguments_spec.rb
spec/rubocop/cop/lint/erb_new_arguments_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ErbNewArguments, :config do context '<= Ruby 2.5', :ruby25, unsupported_on: :prism do it 'does not register an offense when using `ERB.new` with non-keyword arguments' do expect_no_offenses(<<~RUBY) ERB.new(str, nil, '-', '@output_buf...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_assignment_spec.rb
spec/rubocop/cop/lint/useless_assignment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessAssignment, :config do context 'when a variable is assigned and assigned again in a modifier condition' do it 'accepts with parentheses' do expect_no_offenses(<<~RUBY) a = nil puts a if (a = 123) RUBY end ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
true
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_times_spec.rb
spec/rubocop/cop/lint/useless_times_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessTimes, :config do it 'registers an offense and corrects with 0.times' do expect_offense(<<~RUBY) 0.times { something } ^^^^^^^^^^^^^^^^^^^^^ Useless call to `0.times` detected. RUBY expect_correction('') end it 'reg...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_setter_call_spec.rb
spec/rubocop/cop/lint/useless_setter_call_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessSetterCall, :config do context 'with method ending with setter call on local object' do it 'registers an offense and corrects' do expect_offense(<<~RUBY) def test top = Top.new top.attr = 5 ^^^ Use...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_type_conversion_spec.rb
spec/rubocop/cop/lint/redundant_type_conversion_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantTypeConversion, :config do shared_examples 'accepted' do |source| it "does not register an offense on `#{source}`" do expect_no_offenses(source) end end shared_examples 'offense' do |conversion, receiver, suffix = ''| it...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/literal_in_interpolation_spec.rb
spec/rubocop/cop/lint/literal_in_interpolation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::LiteralInInterpolation, :config do it 'accepts empty interpolation' do expect_no_offenses('"this is #{a} silly"') end it 'accepts interpolation of xstr' do expect_no_offenses('"this is #{`a`} silly"') end it 'accepts interpolation of ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_ruby2_keywords_spec.rb
spec/rubocop/cop/lint/useless_ruby2_keywords_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessRuby2Keywords, :config do context 'when `ruby2_keywords` is given a `def` node' do it 'registers an offense for a method without arguments' do expect_offense(<<~RUBY) ruby2_keywords def foo ^^^^^^^^^^^^^^ `ruby2_keyword...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/deprecated_class_methods_spec.rb
spec/rubocop/cop/lint/deprecated_class_methods_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DeprecatedClassMethods, :config do context 'prefer `File.exist?` over `File.exists?`' do it 'registers an offense and corrects File.exists?' do expect_offense(<<~RUBY) File.exists?(o) ^^^^^^^^^^^^ `File.exists?` is deprecated ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/unused_method_argument_spec.rb
spec/rubocop/cop/lint/unused_method_argument_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnusedMethodArgument, :config do let(:cop_config) do { 'AllowUnusedKeywordArguments' => false, 'IgnoreEmptyMethods' => false, 'IgnoreNotImplementedMethods' => false } end describe 'inspection' do context 'when a metho...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_constant_scoping_spec.rb
spec/rubocop/cop/lint/useless_constant_scoping_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessConstantScoping, :config do it 'registers an offense when using constant after `private` access modifier' do expect_offense(<<~RUBY) class Foo private CONST = 42 ^^^^^^^^^^ Useless `private` access modifier for ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/missing_cop_enable_directive_spec.rb
spec/rubocop/cop/lint/missing_cop_enable_directive_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::MissingCopEnableDirective, :config do context 'when the maximum range size is infinite' do let(:cop_config) { { 'MaximumRangeSize' => Float::INFINITY } } let(:other_cops) { { 'Layout/SpaceAroundOperators' => { 'Enabled' => true } } } it 'r...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/interpolation_check_spec.rb
spec/rubocop/cop/lint/interpolation_check_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::InterpolationCheck, :config do it 'registers an offense and corrects for interpolation in single quoted string' do expect_offense(<<~'RUBY') 'foo #{bar}' ^^^^^^^^^^^^ Interpolation in single quoted string detected. Use double quoted str...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/implicit_string_concatenation_spec.rb
spec/rubocop/cop/lint/implicit_string_concatenation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ImplicitStringConcatenation, :config do context 'on a single string literal' do it 'does not register an offense' do expect_no_offenses('abc') end end context 'on adjacent string literals on the same line' do it 'registers an off...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/uri_regexp_spec.rb
spec/rubocop/cop/lint/uri_regexp_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UriRegexp, :config do it 'does not register an offense when using `regexp` without receiver' do expect_no_offenses(<<~RUBY) regexp('http://example.com') RUBY end it 'does not register an offense when using `regexp` with variable rece...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/to_enum_arguments_spec.rb
spec/rubocop/cop/lint/to_enum_arguments_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ToEnumArguments, :config do it 'registers an offense when required arg is missing' do expect_offense(<<~RUBY) def m(x) return to_enum(:m) unless block_given? ^^^^^^^^^^^ Ensure you correctly provided all the arguments. ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/empty_class_spec.rb
spec/rubocop/cop/lint/empty_class_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyClass, :config do let(:cop_config) { { 'AllowComments' => false } } it 'registers an offense for empty class' do expect_offense(<<~RUBY) class Foo ^^^^^^^^^ Empty class detected. end RUBY end it 'registers an offe...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/loop_spec.rb
spec/rubocop/cop/lint/loop_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::Loop, :config do it 'registers an offense and corrects for begin/end/while' do expect_offense(<<~RUBY) begin something end while test ^^^^^ Use `Kernel#loop` with `break` rather than `begin/end/until`(or `while`). ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_splat_expansion_spec.rb
spec/rubocop/cop/lint/redundant_splat_expansion_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantSplatExpansion, :config do it 'allows assigning to a splat' do expect_no_offenses('*, rhs = *node') end it 'allows assigning to a splat variable' do expect_no_offenses('lhs, *args = *node') end it 'allows assigning a variable...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/regexp_as_condition_spec.rb
spec/rubocop/cop/lint/regexp_as_condition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RegexpAsCondition, :config do it 'registers an offense and corrects for a regexp literal in `if` condition' do expect_offense(<<~RUBY) if /foo/ ^^^^^ Do not use regexp literal as a condition. The regexp literal matches `$_` implicitl...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_require_spec.rb
spec/rubocop/cop/lint/duplicate_require_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateRequire, :config do it 'registers and corrects an offense when duplicate `require` is detected' do expect_offense(<<~RUBY) require 'foo' require 'foo' ^^^^^^^^^^^^^ Duplicate `require` detected. RUBY expect_corre...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/it_without_arguments_in_block_spec.rb
spec/rubocop/cop/lint/it_without_arguments_in_block_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ItWithoutArgumentsInBlock, :config do context '>= Ruby 3.4', :ruby34 do it 'does not register an offense when using `it` without arguments in a single line block' do expect_no_offenses(<<~RUBY) 0.times { it } 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/lint/inherit_exception_spec.rb
spec/rubocop/cop/lint/inherit_exception_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::InheritException, :config do context 'when class inherits from `Exception`' do context 'with enforced style set to `runtime_error`' do let(:cop_config) { { 'EnforcedStyle' => 'runtime_error' } } it 'registers an offense and corrects' d...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default_spec.rb
spec/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::HashNewWithKeywordArgumentsAsDefault, :config do it 'registers an offense when using `Hash.new` with keyword arguments for default' do expect_offense(<<~RUBY) Hash.new(key: :value) ^^^^^^^^^^^ Use a hash literal instead of keyw...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/generator/require_file_injector_spec.rb
spec/rubocop/cop/generator/require_file_injector_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Generator::RequireFileInjector do let(:stdout) { StringIO.new } let(:root_file_path) { 'lib/root.rb' } let(:injector) do described_class.new(source_path: source_path, root_file_path: root_file_path, output: stdout) end around do |example| Di...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/hash_slice_spec.rb
spec/rubocop/cop/style/hash_slice_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::HashSlice, :config do shared_examples 'include?' do context 'using `include?`' do it 'does not register an offense when using `select` and calling `!include?` method with symbol array' do expect_no_offenses(<<~RUBY) {foo: 1...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/trailing_comma_in_array_literal_spec.rb
spec/rubocop/cop/style/trailing_comma_in_array_literal_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::TrailingCommaInArrayLiteral, :config do shared_examples 'single line lists' do |extra_info| it 'registers an offense for trailing comma' do expect_offense(<<~RUBY) VALUES = [1001, 2020, 3333, ] ^ Avo...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/numeric_predicate_spec.rb
spec/rubocop/cop/style/numeric_predicate_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NumericPredicate, :config do context 'when configured to enforce numeric predicate methods' do let(:cop_config) { { 'EnforcedStyle' => 'predicate', 'AutoCorrect' => true } } context 'when checking if a number is zero' do it 'registers a...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/file_null_spec.rb
spec/rubocop/cop/style/file_null_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::FileNull, :config do it 'does not register an offense for an empty string' do expect_no_offenses(<<~RUBY) "" RUBY end it 'does not register an offense when there is an invalid byte sequence error' 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/if_unless_modifier_of_if_unless_spec.rb
spec/rubocop/cop/style/if_unless_modifier_of_if_unless_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::IfUnlessModifierOfIfUnless, :config do it 'provides a good error message' do expect_offense(<<~RUBY) condition ? then_part : else_part unless external_condition ^^^^^^ Avoid modifier `unless` after ano...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/send_with_literal_method_name_spec.rb
spec/rubocop/cop/style/send_with_literal_method_name_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SendWithLiteralMethodName, :config do context 'when calling `public_send` with a symbol literal argument' do it 'registers an offense' do expect_offense(<<~RUBY) obj.public_send(:foo) ^^^^^^^^^^^^^^^^^ Use `foo` method ca...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/string_methods_spec.rb
spec/rubocop/cop/style/string_methods_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StringMethods, :config do let(:cop_config) { { 'intern' => 'to_sym' } } it 'registers an offense' do expect_offense(<<~RUBY) 'something'.intern ^^^^^^ Prefer `to_sym` over `intern`. RUBY expect_correction(<<~RUB...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/comparable_clamp_spec.rb
spec/rubocop/cop/style/comparable_clamp_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ComparableClamp, :config do context 'target ruby version >= 2.4', :ruby24 do it 'registers and corrects an offense when using `if x < low` / `elsif high < x` / `else`' do expect_offense(<<~RUBY) if x < low ^^^^^^^^^^ Use `x.c...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_assignment_spec.rb
spec/rubocop/cop/style/redundant_assignment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantAssignment, :config do it 'reports an offense for def ending with assignment and returning' do expect_offense(<<~RUBY) def func some_preceding_statements x = something ^^^^^^^^^^^^^ Redundant assignment befor...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/it_block_parameter_spec.rb
spec/rubocop/cop/style/it_block_parameter_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ItBlockParameter, :config do context '>= Ruby 3.4', :ruby34 do context 'EnforcedStyle: allow_single_line' do let(:cop_config) { { 'EnforcedStyle' => 'allow_single_line' } } it 'registers an offense when using multiline `it` parameters...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/require_order_spec.rb
spec/rubocop/cop/style/require_order_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RequireOrder, :config do context 'when `require` is sorted' do it 'registers no offense' do expect_no_offenses(<<~RUBY) require 'a' require 'b' RUBY end it 'registers no offense when single-quoted string and do...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/dir_empty_spec.rb
spec/rubocop/cop/style/dir_empty_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::DirEmpty, :config do context 'target ruby version >= 2.4', :ruby24 do it 'registers an offense for `Dir.entries.size == 2`' do expect_offense(<<~RUBY) Dir.entries('path/to/dir').size == 2 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/redundant_file_extension_in_require_spec.rb
spec/rubocop/cop/style/redundant_file_extension_in_require_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantFileExtensionInRequire, :config do it 'registers an offense and corrects when requiring filename ending with `.rb`' do expect_offense(<<~RUBY) require 'foo.rb' ^^^ Redundant `.rb` file extension detected. req...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/nested_modifier_spec.rb
spec/rubocop/cop/style/nested_modifier_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NestedModifier, :config do shared_examples 'not correctable' do |keyword| it "does not autocorrect when #{keyword} is the outer modifier" do expect_offense(<<~RUBY, keyword: keyword) something if a %{keyword} b ^^ A...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/bare_percent_literals_spec.rb
spec/rubocop/cop/style/bare_percent_literals_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::BarePercentLiterals, :config do shared_examples 'accepts other delimiters' do it 'accepts __FILE__' do expect_no_offenses('__FILE__') end it 'accepts regular expressions' do expect_no_offenses('/%Q?/') end it 'accepts...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/string_hash_keys_spec.rb
spec/rubocop/cop/style/string_hash_keys_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StringHashKeys, :config do it 'registers an offense when using strings as keys' do expect_offense(<<~RUBY) { 'one' => 1 } ^^^^^ Prefer symbols instead of strings as hash keys. RUBY expect_correction(<<~RUBY) { :one => ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/each_with_object_spec.rb
spec/rubocop/cop/style/each_with_object_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::EachWithObject, :config do it 'finds inject and reduce with passed in and returned hash' do expect_offense(<<~RUBY) [].inject({}) { |a, e| a } ^^^^^^ Use `each_with_object` instead of `inject`. [].reduce({}) do |a, e| ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/if_inside_else_spec.rb
spec/rubocop/cop/style/if_inside_else_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::IfInsideElse, :config do let(:cop_config) { { 'AllowIfModifier' => false } } it 'catches an if node nested inside an else' do expect_offense(<<~RUBY) if a blah else if b ^^ Convert `if` nested inside `else` t...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/or_assignment_spec.rb
spec/rubocop/cop/style/or_assignment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::OrAssignment, :config do context 'when using var = var ? var : something' do it 'registers an offense with normal variables' do expect_offense(<<~RUBY) foo = foo ? foo : 'default' ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use the double pi...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/trailing_underscore_variable_spec.rb
spec/rubocop/cop/style/trailing_underscore_variable_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::TrailingUnderscoreVariable, :config do shared_examples 'common functionality' do it 'registers an offense when the last variable of parallel assignment is an underscore' do expect_offense(<<~RUBY) a, b, _ = foo() ^^ Do ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/style/rescue_modifier_spec.rb
spec/rubocop/cop/style/rescue_modifier_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RescueModifier, :config do let(:config) { RuboCop::Config.new('Layout/IndentationWidth' => { 'Width' => 2 }) } it 'registers an offense for modifier rescue' do expect_offense(<<~RUBY) method rescue handle ^^^^^^^^^^^^^^^^^^^^ Avoid ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false