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/formatter/formatter_set_spec.rb
spec/rubocop/formatter/formatter_set_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Formatter::FormatterSet do subject(:formatter_set) { described_class.new } win_close = lambda do |fset| fset.close_output_files fset.each { |f| f.instance_variable_set :@output, nil } end it 'responds to all formatter API methods' do %i[starte...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/formatter/offense_count_formatter_spec.rb
spec/rubocop/formatter/offense_count_formatter_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Formatter::OffenseCountFormatter do subject(:formatter) { described_class.new(output, options) } let(:output) { StringIO.new } let(:options) { { display_style_guide: false } } let(:files) do %w[lib/rubocop.rb spec/spec_helper.rb exe/rubocop].map do |p...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/formatter/junit_formatter_spec.rb
spec/rubocop/formatter/junit_formatter_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Formatter::JUnitFormatter, :config do subject(:formatter) { described_class.new(output) } let(:output) { StringIO.new } let(:cop_class) { RuboCop::Cop::Layout::SpaceInsideBlockBraces } let(:source) { %w[foo bar baz].join("\n") } before { cop.send(:begin...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/formatter/clang_style_formatter_spec.rb
spec/rubocop/formatter/clang_style_formatter_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Formatter::ClangStyleFormatter, :config do subject(:formatter) { described_class.new(output) } let(:cop_class) { RuboCop::Cop::Base } let(:output) { StringIO.new } before { cop.send(:begin_investigation, processed_source) } describe '#report_file' do ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/formatter/markdown_formatter_spec.rb
spec/rubocop/formatter/markdown_formatter_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Formatter::MarkdownFormatter, :isolated_environment do spec_root = File.expand_path('../..', __dir__) around do |example| project_path = File.join(spec_root, 'fixtures/markdown_formatter/project') FileUtils.cp_r(project_path, '.') Dir.chdir(File.b...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/formatter/progress_formatter_spec.rb
spec/rubocop/formatter/progress_formatter_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Formatter::ProgressFormatter do subject(:formatter) { described_class.new(output) } let(:output) { StringIO.new } let(:files) do %w[lib/rubocop.rb spec/spec_helper.rb exe/rubocop].map do |path| File.expand_path(path) end end describe '#fi...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/formatter/github_actions_formatter_spec.rb
spec/rubocop/formatter/github_actions_formatter_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Formatter::GitHubActionsFormatter, :config do subject(:formatter) { described_class.new(output, formatter_options) } let(:formatter_options) { {} } let(:cop_class) { RuboCop::Cop::Base } let(:output) { StringIO.new } describe '#finished' do let(:fil...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/config_obsoletion/renamed_cop_spec.rb
spec/rubocop/config_obsoletion/renamed_cop_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::ConfigObsoletion::RenamedCop do subject(:rule) { described_class.new(config, old_name, new_name) } let(:config) { instance_double(RuboCop::Config, loaded_path: '.rubocop.yml').as_null_object } let(:old_name) { 'Style/MyCop' } describe '#message' do su...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/ext/regexp_node_spec.rb
spec/rubocop/ext/regexp_node_spec.rb
# frozen_string_literal: true require 'timeout' RSpec.describe RuboCop::Ext::RegexpNode do let(:source) { '/(hello)(?<foo>world)(?:not captured)/' } let(:processed_source) { parse_source(source) } let(:ast) { processed_source.ast } let(:node) { ast } describe '#each_capture' do subject(:captures) { nod...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/variable_force_spec.rb
spec/rubocop/cop/variable_force_spec.rb
# frozen_string_literal: true require 'rubocop/ast/sexp' RSpec.describe RuboCop::Cop::VariableForce do include RuboCop::AST::Sexp subject(:force) { described_class.new([]) } describe '#process_node' do before { force.variable_table.push_scope(s(:def)) } context 'when processing lvar node' do le...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/badge_spec.rb
spec/rubocop/cop/badge_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Badge do subject(:badge) { described_class.new(%w[Test ModuleMustBeAClassCop]) } it 'exposes department name' do expect(badge.department).to be(:Test) end it 'exposes cop name' do expect(badge.cop_name).to eql('ModuleMustBeAClassCop') end ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/commissioner_spec.rb
spec/rubocop/cop/commissioner_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Commissioner do describe '#investigate' do subject(:offenses) { report.offenses } let(:report) { commissioner.investigate(processed_source) } let(:cop_class) do stub_const('Fake::FakeCop', Class.new(RuboCop::Cop::Base) do ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/team_spec.rb
spec/rubocop/cop/team_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Team do subject(:team) { described_class.mobilize(cop_classes, config, options) } let(:cop_classes) { RuboCop::Cop::Registry.global } let(:config) { RuboCop::ConfigLoader.default_configuration } let(:options) { {} } let(:ruby_version) { RuboCop::Tar...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/visibility_help_spec.rb
spec/rubocop/cop/visibility_help_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::VisibilityHelp do describe '#node_visibility' do subject do instance.__send__(:node_visibility, node) end let(:instance) do klass.new end let(:klass) do mod = described_class Class.new do include mod ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/message_annotator_spec.rb
spec/rubocop/cop/message_annotator_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::MessageAnnotator do let(:options) { {} } let(:config) { RuboCop::Config.new({}) } let(:cop_name) { 'Cop/Cop' } let(:annotator) { described_class.new(config, cop_name, config[cop_name], options) } describe '#annotate' do subject(:annotate) { anno...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/range_help_spec.rb
spec/rubocop/cop/range_help_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::RangeHelp do before { stub_const('TestRangeHelp', klass) } let(:instance) do klass.new(processed_source: processed_source) end let(:klass) do Class.new do include RuboCop::Cop::RangeHelp def initialize(processed_source:) ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/util_spec.rb
spec/rubocop/cop/util_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Util do before { stub_const('TestUtil', Class.new { include RuboCop::Cop::Util }) } describe '#line_range' do let(:source) do <<~RUBY foo = 1 bar = 2 class Test def some_method do_something ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/cop_spec.rb
spec/rubocop/cop/cop_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Cop, :config do include FileHelper let(:source) { 'code = {some: :ruby}' } let(:location) { source_range(0...1) } before { cop.send(:begin_investigation, processed_source) } it 'initially has 0 offenses' do expect(cop.offenses).to be_empty e...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/force_spec.rb
spec/rubocop/cop/force_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Force do subject(:force) { described_class.new(cops) } let(:cops) { [instance_double(RuboCop::Cop::Base), instance_double(RuboCop::Cop::Base)] } describe '.force_name' do it 'returns the class name without namespace' do expect(RuboCop::Cop::V...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/corrector_spec.rb
spec/rubocop/cop/corrector_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Corrector do describe '#rewrite' do let(:source) do <<~RUBY.strip true and false RUBY end let(:processed_source) { parse_source(source) } let(:node) { processed_source.ast } let(:operator) { node.loc.operator } de...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/alignment_corrector_spec.rb
spec/rubocop/cop/alignment_corrector_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::AlignmentCorrector, :config do let(:cop_class) { RuboCop::Cop::Test::AlignmentDirective } describe '#correct' do context 'simple indentation' do context 'with a positive column delta' do it 'indents' 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/offense_spec.rb
spec/rubocop/cop/offense_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Offense do subject(:offense) do described_class.new(:convention, location, 'message', 'CopName', :corrected) end let(:location) do source_buffer = Parser::Source::Buffer.new('test', 1) source_buffer.source = "a\n" Parser::Source::Range.n...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/registry_spec.rb
spec/rubocop/cop/registry_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Registry do subject(:registry) { described_class.new(cops, options) } let(:cops) do [ RuboCop::Cop::Lint::BooleanSymbol, RuboCop::Cop::Lint::DuplicateMethods, RuboCop::Cop::Layout::FirstArrayElementIndentation, RuboCop::Cop::Me...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/generator_spec.rb
spec/rubocop/cop/generator_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Generator do subject(:generator) { described_class.new(cop_identifier, output: stdout) } let(:stdout) { StringIO.new } let(:cop_identifier) { 'Style/FakeCop' } before do allow(File).to receive(:write) stub_const('HOME_DIR', Dir.pwd) end ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/severity_spec.rb
spec/rubocop/cop/severity_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Severity do let(:info) { described_class.new(:info) } let(:refactor) { described_class.new(:refactor) } let(:convention) { described_class.new(:convention) } let(:warning) { described_class.new(:warning) } let(:error) { described_class.new(:error) } ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/annotation_comment_spec.rb
spec/rubocop/cop/annotation_comment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::AnnotationComment do subject(:annotation) { described_class.new(comment, keywords) } let(:keywords) { ['TODO', 'FOR LATER', 'FIXME'] } let(:comment) { instance_double(Parser::Source::Comment, text: "# #{text}") } describe '#annotation?' do subjec...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/constant_definition_in_block_spec.rb
spec/rubocop/cop/lint/constant_definition_in_block_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ConstantDefinitionInBlock, :config do it 'does not register an offense for a top-level constant' do expect_no_offenses(<<~RUBY) FOO = 1 RUBY end it 'does not register an offense for a top-level constant followed by another statement'...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/lambda_without_literal_block_spec.rb
spec/rubocop/cop/lint/lambda_without_literal_block_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::LambdaWithoutLiteralBlock, :config do it 'registers and corrects an offense when using lambda with `&proc {}` block argument' do expect_offense(<<~RUBY) lambda(&proc { do_something }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lambda without a lite...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/else_layout_spec.rb
spec/rubocop/cop/lint/else_layout_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ElseLayout, :config do it 'registers an offense and corrects for expr on same line as else' do expect_offense(<<~RUBY) if something test else ala ^^^ Odd `else` layout detected. Did you mean to use `elsif`? so...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/empty_interpolation_spec.rb
spec/rubocop/cop/lint/empty_interpolation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyInterpolation, :config do it 'registers an offense and corrects #{} in interpolation' do expect_offense(<<~'RUBY') "this is the #{}" ^^^ Empty interpolation detected. RUBY expect_correction(<<~RUBY) "thi...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_numeric_operation_spec.rb
spec/rubocop/cop/lint/useless_numeric_operation_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessNumericOperation, :config do it 'registers an offense when 0 is added to a variable' do expect_offense(<<~RUBY) x + 0 ^^^^^ Do not apply inconsequential numeric operations to variables. 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/lint/useless_defined_spec.rb
spec/rubocop/cop/lint/useless_defined_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessDefined, :config do it 'registers an offense when using `defined?` with a string argument' do expect_offense(<<~RUBY) defined?("FooBar") ^^^^^^^^^^^^^^^^^^ Calling `defined?` with a string argument will always return a truthy val...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_regexp_quantifiers_spec.rb
spec/rubocop/cop/lint/redundant_regexp_quantifiers_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantRegexpQuantifiers, :config do # silence Ruby's own warnings for the tested redundant quantifiers around { |example| RuboCop::Util.silence_warnings(&example) } context 'with non-redundant quantifiers' do it 'does not register an offens...
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_with_empty_spec.rb
spec/rubocop/cop/lint/safe_navigation_with_empty_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SafeNavigationWithEmpty, :config do context 'in a conditional' do it 'registers an offense and corrects on `&.empty?`' do expect_offense(<<~RUBY) return unless foo&.empty? ^^^^^^^^^^^ Avoid calling `empty?` with ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/unreachable_loop_spec.rb
spec/rubocop/cop/lint/unreachable_loop_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnreachableLoop, :config do context 'without preceding continue statements' do it 'registers an offense when using `break`' do expect_offense(<<~RUBY) while x > 0 ^^^^^^^^^^^ This loop will have at most one iteration. ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/script_permission_spec.rb
spec/rubocop/cop/lint/script_permission_spec.rb
# frozen_string_literal: true # rubocop:disable Style/NumericLiteralPrefix RSpec.describe RuboCop::Cop::Lint::ScriptPermission, :config do subject(:cop) { described_class.new(config, options) } let(:options) { nil } let(:file) { Tempfile.new('') } let(:filename) { file.path.split('/').last } let(:source) {...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/flip_flop_spec.rb
spec/rubocop/cop/lint/flip_flop_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::FlipFlop, :config do it 'registers an offense for inclusive flip-flops' do expect_offense(<<~RUBY) DATA.each_line do |line| print line if (line =~ /begin/)..(line =~ /end/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid th...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler_spec.rb
spec/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::IncompatibleIoSelectWithFiberScheduler, :config do it 'registers and corrects an offense when using `IO.select` with single read argument' do expect_offense(<<~RUBY) IO.select([io], [], []) ^^^^^^^^^^^^^^^^^^^^^^^ Use `io.wait_readable`...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/void_spec.rb
spec/rubocop/cop/lint/void_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::Void, :config do described_class::BINARY_OPERATORS.each do |op| it "registers an offense for void op #{op} if not on last line" do expect_offense(<<~RUBY, op: op) a %{op} b ^{op} Operator `#{op}` used in void context. ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/nested_method_definition_spec.rb
spec/rubocop/cop/lint/nested_method_definition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NestedMethodDefinition, :config do it 'registers an offense for a nested method definition' do expect_offense(<<~RUBY) def x; def y; end; end ^^^^^^^^^^ Method definitions must not be nested. Use `lambda` instead. RUBY end ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_case_condition_spec.rb
spec/rubocop/cop/lint/duplicate_case_condition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateCaseCondition, :config do it 'registers an offense for repeated case conditionals' do expect_offense(<<~RUBY) case x when false first_method when true second_method when false ^^^^^ Duplic...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/next_without_accumulator_spec.rb
spec/rubocop/cop/lint/next_without_accumulator_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NextWithoutAccumulator, :config do shared_examples 'reduce/inject' do |reduce_alias| context "given a #{reduce_alias} block" do it 'registers an offense for a bare next' do expect_offense(<<~RUBY) (1..4).#{reduce_alias}(0) d...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/empty_block_spec.rb
spec/rubocop/cop/lint/empty_block_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyBlock, :config do let(:cop_config) { { 'AllowComments' => true, 'AllowEmptyLambdas' => true } } it 'registers an offense for empty block within method call' do expect_offense(<<~RUBY) items.each { |item| } ^^^^^^^^^^^^^^^^^^^^^ ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/refinement_import_methods_spec.rb
spec/rubocop/cop/lint/refinement_import_methods_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RefinementImportMethods, :config do context 'Ruby >= 3.1', :ruby31 do it 'registers an offense when using `include` in `refine` block' do expect_offense(<<~RUBY) refine Foo do include Bar ^^^^^^^ Use `import_method...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/struct_new_override_spec.rb
spec/rubocop/cop/lint/struct_new_override_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::StructNewOverride, :config do it 'registers an offense using `Struct.new(symbol)`' do expect_offense(<<~RUBY) Bad = Struct.new(:members) ^^^^^^^^ `:members` member overrides `Struct#members` and it may be unexpected. ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/suppressed_exception_spec.rb
spec/rubocop/cop/lint/suppressed_exception_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SuppressedException, :config do context 'with AllowComments set to false' do let(:cop_config) { { 'AllowComments' => false } } it 'registers an offense for empty rescue block' do expect_offense(<<~RUBY) begin something ...
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_consistency_spec.rb
spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SafeNavigationConsistency, :config do let(:cop_config) { { 'AllowedMethods' => %w[present? blank? try presence] } } it 'allows && without receiver' do expect_no_offenses(<<~RUBY) foo && bar RUBY end it 'allows && without safe navi...
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_disable_directive_spec.rb
spec/rubocop/cop/lint/redundant_cop_disable_directive_spec.rb
# frozen_string_literal: true require 'rubocop/cop/legacy/corrector' RSpec.describe RuboCop::Cop::Lint::RedundantCopDisableDirective, :config do describe '.check' do let(:offenses) { [] } let(:cop) { cop_class.new(config, cop_options, offenses) } context 'when there are no disabled lines' do let(...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/numbered_parameter_assignment_spec.rb
spec/rubocop/cop/lint/numbered_parameter_assignment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NumberedParameterAssignment, :config do # NOTE: Assigning to numbered parameter (from `_1` to `_9`) cause an error in Ruby 3.0. context 'when Ruby 2.7 or lower', :ruby27, unsupported_on: :prism do (1..9).to_a.each do |number| it "registers ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/rescue_type_spec.rb
spec/rubocop/cop/lint/rescue_type_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RescueType, :config do it 'accepts rescue modifier' do expect_no_offenses('foo rescue nil') end it 'accepts rescuing nothing' do expect_no_offenses(<<~RUBY) begin foo rescue bar end RUBY end it 'a...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/top_level_return_with_argument_spec.rb
spec/rubocop/cop/lint/top_level_return_with_argument_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::TopLevelReturnWithArgument, :config do context 'Code segment with only top-level return statement' do it 'expects no offense from the return without arguments' do expect_no_offenses(<<~RUBY) return RUBY end it 'expects ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb
spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb
# frozen_string_literal: true # FIXME: https://github.com/ruby/prism/issues/2513 RSpec.describe RuboCop::Cop::Lint::AmbiguousRegexpLiteral, :config do shared_examples 'with a regexp literal in the first argument' do context 'without parentheses' do it 'registers an offense and corrects when single argument...
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_spec.rb
spec/rubocop/cop/lint/ambiguous_operator_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::AmbiguousOperator, :config do context 'with `+` unary operator in the first argument' do context 'without parentheses' do context 'without whitespaces on the right of the operator' do it 'registers an offense and corrects' do ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_magic_comment_spec.rb
spec/rubocop/cop/lint/duplicate_magic_comment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateMagicComment, :config do it 'registers an offense when frozen magic comments are duplicated' do expect_offense(<<~RUBY) # frozen_string_literal: true # frozen_string_literal: true ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Duplicate m...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_match_pattern_spec.rb
spec/rubocop/cop/lint/duplicate_match_pattern_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateMatchPattern, :config, :ruby27 do it 'registers an offense for repeated `in` patterns' do expect_offense(<<~RUBY) case x in foo first_method in bar second_method in foo ^^^ Duplicate `in` pa...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/raise_exception_spec.rb
spec/rubocop/cop/lint/raise_exception_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RaiseException, :config do let(:cop_config) { { 'AllowedImplicitNamespaces' => ['Gem'] } } it 'registers an offense and corrects for `raise` with `::Exception`' do expect_offense(<<~RUBY) raise ::Exception ^^^^^^^^^^^ Use `Stan...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/empty_ensure_spec.rb
spec/rubocop/cop/lint/empty_ensure_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyEnsure, :config do it 'registers an offense and corrects empty ensure' do expect_offense(<<~RUBY) begin something ensure # hello ^^^^^^ Empty `ensure` block detected. # world end RUBY expect_cor...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_with_index_spec.rb
spec/rubocop/cop/lint/redundant_with_index_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantWithIndex, :config do it 'registers an offense for `ary.each_with_index { |v| v }` and corrects to `ary.each`' do expect_offense(<<~RUBY) ary.each_with_index { |v| v } ^^^^^^^^^^^^^^^ Use `each` instead of `each_with_index`...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/non_local_exit_from_iterator_spec.rb
spec/rubocop/cop/lint/non_local_exit_from_iterator_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NonLocalExitFromIterator, :config do context 'when block is followed by method chain' do context 'and has single argument' do it 'registers an offense' do expect_offense(<<~RUBY) items.each do |item| return if it...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_string_coercion_spec.rb
spec/rubocop/cop/lint/redundant_string_coercion_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantStringCoercion, :config do it 'registers an offense and corrects `to_s` in interpolation' do expect_offense(<<~'RUBY') "this is the #{result.to_s}" ^^^^ Redundant use of `Object#to_s` in interpolation. ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/triple_quotes_spec.rb
spec/rubocop/cop/lint/triple_quotes_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::TripleQuotes, :config do context 'triple quotes' do context 'on one line' do it 'registers an offense and corrects' do expect_offense(<<~RUBY) """a string""" ^^^^^^^^^^^^^^ Delimiting a string with multiple quotes ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/multiple_comparison_spec.rb
spec/rubocop/cop/lint/multiple_comparison_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::MultipleComparison, :config do shared_examples 'Check to use two comparison operator' do |operator1, operator2| it "registers an offense for x #{operator1} y #{operator2} z" do expect_offense(<<~RUBY, operator1: operator1, operator2: operator...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/unmodified_reduce_accumulator_spec.rb
spec/rubocop/cop/lint/unmodified_reduce_accumulator_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnmodifiedReduceAccumulator, :config do shared_examples 'reduce/inject' do |method| it "does not affect #{method} called with no block args" do expect_no_offenses(<<~RUBY) values.#{method} do do_something end R...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/missing_super_spec.rb
spec/rubocop/cop/lint/missing_super_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::MissingSuper, :config do context 'constructor' do it 'registers an offense and does not autocorrect when no `super` call' do expect_offense(<<~RUBY) class Child < Parent def initialize ^^^^^^^^^^^^^^ Call `super` t...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/empty_conditional_body_spec.rb
spec/rubocop/cop/lint/empty_conditional_body_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyConditionalBody, :config do let(:cop_config) { { 'AllowComments' => true } } it 'registers an offense for missing `if` body' do expect_offense(<<~RUBY) if condition ^^^^^^^^^^^^ Avoid `if` branches without a body. end ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/binary_operator_with_identical_operands_spec.rb
spec/rubocop/cop/lint/binary_operator_with_identical_operands_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::BinaryOperatorWithIdenticalOperands, :config do %i[== != === <=> =~ && || > >= < <= | ^].each do |operator| it "registers an offense for `#{operator}` with duplicate operands" do expect_offense(<<~RUBY, operator: operator) y = a.x(arg...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/ambiguous_range_spec.rb
spec/rubocop/cop/lint/ambiguous_range_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::AmbiguousRange, :config do { 'irange' => '..', 'erange' => '...' }.each do |node_type, operator| context "for an #{node_type}" do it 'registers an offense and corrects when not parenthesized' do expect_offense(<<~RUBY) x || ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/shadowed_exception_spec.rb
spec/rubocop/cop/lint/shadowed_exception_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ShadowedException, :config do context 'modifier rescue' do it 'accepts rescue in its modifier form' do expect_no_offenses('foo rescue nil') end end context 'single rescue' do it 'accepts an empty rescue' do expect_no_offens...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/or_assignment_to_constant_spec.rb
spec/rubocop/cop/lint/or_assignment_to_constant_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::OrAssignmentToConstant, :config do it 'registers an offense with or-assignment to a constant' do expect_offense(<<~RUBY) CONST ||= 1 ^^^ Avoid using or-assignment with constants. RUBY expect_correction(<<~RUBY) CONS...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_dir_glob_sort_spec.rb
spec/rubocop/cop/lint/redundant_dir_glob_sort_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantDirGlobSort, :config do context 'when Ruby 3.0 or higher', :ruby30 do it 'registers an offense and correction when using `Dir.glob.sort`' do expect_offense(<<~RUBY) Dir.glob(Rails.root.join('test', '*.rb')).sort.each(&method(...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/redundant_with_object_spec.rb
spec/rubocop/cop/lint/redundant_with_object_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantWithObject, :config do it 'registers an offense and corrects when using `ary.each_with_object { |v| v }`' do expect_offense(<<~RUBY) ary.each_with_object([]) { |v| v } ^^^^^^^^^^^^^^^^^^^^ Use `each` instead of `each_with_o...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_or_spec.rb
spec/rubocop/cop/lint/useless_or_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessOr, :config do described_class::TRUTHY_RETURN_VALUE_METHODS.each do |method| it "registers an offense with `x.#{method} || fallback`" do expect_offense(<<~RUBY, method: method) x.#{method} || fallback _{method} ^^^^^^...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/nested_percent_literal_spec.rb
spec/rubocop/cop/lint/nested_percent_literal_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::NestedPercentLiteral, :config do it 'registers no offense for empty array' do expect_no_offenses('%i[]') end it 'registers no offense for array' do expect_no_offenses('%i[a b c d xyz]') end it 'registers no offense for percent modifie...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/ambiguous_assignment_spec.rb
spec/rubocop/cop/lint/ambiguous_assignment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::AmbiguousAssignment, :config do described_class::MISTAKES.each_key do |mistake| operator = mistake[1] %i[x @x @@x $x X].each do |lhs| it "registers an offense when using `#{operator}` with `#{lhs}`" do expect_offense(<<~RUBY, ope...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/self_assignment_spec.rb
spec/rubocop/cop/lint/self_assignment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SelfAssignment, :config do it 'registers an offense when using local var self-assignment' do expect_offense(<<~RUBY) foo = foo ^^^^^^^^^ Self-assignment detected. RUBY end it 'does not register an offense when using local var a...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/require_parentheses_spec.rb
spec/rubocop/cop/lint/require_parentheses_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RequireParentheses, :config do it 'registers an offense for missing parentheses around expression with && operator' do expect_offense(<<~RUBY) if day.is? 'monday' && month == :jan ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use parentheses in ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_elsif_condition_spec.rb
spec/rubocop/cop/lint/duplicate_elsif_condition_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateElsifCondition, :config do it 'registers an offense for repeated elsif conditions' do expect_offense(<<~RUBY) if x == 1 elsif x == 2 elsif x == 1 ^^^^^^ Duplicate `elsif` condition detected. end RUBY...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/send_with_mixin_argument_spec.rb
spec/rubocop/cop/lint/send_with_mixin_argument_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SendWithMixinArgument, :config do it 'registers an offense when using `send` with `include`' do expect_offense(<<~RUBY) Foo.send(:include, Bar) ^^^^^^^^^^^^^^^^^^^ Use `include Bar` instead of `send(:include, Bar)`. RUBY ex...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/unescaped_bracket_in_regexp_spec.rb
spec/rubocop/cop/lint/unescaped_bracket_in_regexp_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnescapedBracketInRegexp, :config do around { |example| RuboCop::Util.silence_warnings(&example) } context 'literal Regexp' do context 'when unescaped bracket is the first character' do it 'does not register an offense' do # this d...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/syntax_spec.rb
spec/rubocop/cop/lint/syntax_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::Syntax, :config do describe '.offenses_from_processed_source' do let(:commissioner) { RuboCop::Cop::Commissioner.new([cop]) } let(:offenses) { commissioner.investigate(processed_source).offenses } let(:ruby_version) { 3.3 } # The minimum ve...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_set_element_spec.rb
spec/rubocop/cop/lint/duplicate_set_element_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateSetElement, :config do %w[Set SortedSet].each do |class_name| it "registers an offense when using duplicate symbol element in `#{class_name}[...]`" do expect_offense(<<~RUBY, class_name: class_name) #{class_name}[:foo, :bar, ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/unused_block_argument_spec.rb
spec/rubocop/cop/lint/unused_block_argument_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnusedBlockArgument, :config do let(:cop_config) { { 'AllowUnusedKeywordArguments' => false } } context 'inspection' do context 'when a block takes multiple arguments' do context 'and an argument is unused' do 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/parentheses_as_grouped_expression_spec.rb
spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ParenthesesAsGroupedExpression, :config do it 'registers an offense and corrects for method call with space before the parenthesis' do expect_offense(<<~RUBY) a.func (x) ^ `(x)` interpreted as grouped expression. RUBY exp...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/return_in_void_context_spec.rb
spec/rubocop/cop/lint/return_in_void_context_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ReturnInVoidContext, :config do context 'with an initialize method containing a return with a value' do it 'registers an offense' do expect_offense(<<~RUBY) class A def initialize return :qux if bar? ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/suppressed_exception_in_number_conversion_spec.rb
spec/rubocop/cop/lint/suppressed_exception_in_number_conversion_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SuppressedExceptionInNumberConversion, :config, :ruby26 do it 'registers an offense when using `Integer(arg) rescue nil`' do expect_offense(<<~RUBY) Integer(arg) rescue nil ^^^^^^^^^^^^^^^^^^^^^^^ Use `Integer(arg, exception: false)` in...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/constant_reassignment_spec.rb
spec/rubocop/cop/lint/constant_reassignment_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ConstantReassignment, :config do it 'registers an offense when reassigning a constant on top-level namespace' do expect_offense(<<~RUBY) FOO = :bar FOO = :baz ^^^^^^^^^^ Constant `FOO` is already assigned in this namespace. RU...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/useless_rescue_spec.rb
spec/rubocop/cop/lint/useless_rescue_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UselessRescue, :config do it 'registers an offense when single `rescue` which only anonymously reraises' do expect_offense(<<~RUBY) def foo do_something rescue ^^^^^^ Useless `rescue` detected. raise end ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/array_literal_in_regexp_spec.rb
spec/rubocop/cop/lint/array_literal_in_regexp_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ArrayLiteralInRegexp, :config do shared_examples 'character class' do |source, correction| it "registers an offense and corrects for `#{source}`" do expect_offense(<<~'RUBY', source: source) /#{%{source}}/ ^^^{source}^ Use a ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/out_of_range_regexp_ref_spec.rb
spec/rubocop/cop/lint/out_of_range_regexp_ref_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::OutOfRangeRegexpRef, :config do it 'registers an offense when references are used before any regexp' do expect_offense(<<~RUBY) puts $3 ^^ $3 is out of range (no regexp capture groups detected). RUBY end it 'registers an o...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/constant_resolution_spec.rb
spec/rubocop/cop/lint/constant_resolution_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ConstantResolution, :config do it 'registers no offense when qualifying a const' do expect_no_offenses(<<~RUBY) ::MyConst RUBY end it 'registers no offense qualifying a namespace const' do expect_no_offenses(<<~RUBY) ::MyCo...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/duplicate_branch_spec.rb
spec/rubocop/cop/lint/duplicate_branch_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::DuplicateBranch, :config do shared_examples 'literal if allowed' do |type, value| context "when returning a #{type} in multiple branches" do it 'allows branches to be duplicated' do expect_no_offenses(<<~RUBY) if x ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/symbol_conversion_spec.rb
spec/rubocop/cop/lint/symbol_conversion_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SymbolConversion, :config do shared_examples 'offense' do |from, to| it "registers an offense for #{from}" do expect_offense(<<~RUBY, from: from) #{from} ^{from} Unnecessary symbol conversion; use `#{to}` instead. RUBY ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/debugger_spec.rb
spec/rubocop/cop/lint/debugger_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::Debugger, :config do context 'with the DebuggerMethods configuration' do let(:cop_config) { { 'DebuggerMethods' => %w[custom_debugger] } } it 'does not register an offense for a byebug call' do expect_no_offenses(<<~RUBY) byebug ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/ineffective_access_modifier_spec.rb
spec/rubocop/cop/lint/ineffective_access_modifier_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::IneffectiveAccessModifier, :config do context 'when `private` is applied to a class method' do it 'registers an offense' do expect_offense(<<~RUBY) class C private def self.method ^^^ `private` (on line ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/hash_compare_by_identity_spec.rb
spec/rubocop/cop/lint/hash_compare_by_identity_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::HashCompareByIdentity, :config do it 'registers an offense when using hash methods with `object_id` on receiver as a key' do expect_offense(<<~RUBY) hash.key?(foo.object_id) ^^^^^^^^^^^^^^^^^^^^^^^^ Use `Hash#compare_by_identity` instea...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/empty_file_spec.rb
spec/rubocop/cop/lint/empty_file_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyFile, :config do let(:commissioner) { RuboCop::Cop::Commissioner.new([cop]) } let(:offenses) { commissioner.investigate(processed_source).offenses } let(:cop_config) { { 'AllowComments' => true } } let(:source) { '' } 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/require_range_parentheses_spec.rb
spec/rubocop/cop/lint/require_range_parentheses_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RequireRangeParentheses, :config do it 'registers an offense when the end of the range (`..`) is line break' do expect_offense(<<~RUBY) 42.. ^^^^ Wrap the endless range literal `42..` to avoid precedence ambiguity. do_something ...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/big_decimal_new_spec.rb
spec/rubocop/cop/lint/big_decimal_new_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::BigDecimalNew, :config do it 'registers an offense and corrects using `BigDecimal.new()`' do expect_offense(<<~RUBY) BigDecimal.new(123.456, 3) ^^^ `BigDecimal.new()` is deprecated. Use `BigDecimal()` instead. RUBY e...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/uri_escape_unescape_spec.rb
spec/rubocop/cop/lint/uri_escape_unescape_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UriEscapeUnescape, :config do it "registers an offense when using `URI.escape('http://example.com')`" do expect_offense(<<~RUBY) URI.escape('http://example.com') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `URI.escape` method is obsolete and shoul...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false
rubocop/rubocop
https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/spec/rubocop/cop/lint/heredoc_method_call_position_spec.rb
spec/rubocop/cop/lint/heredoc_method_call_position_spec.rb
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::HeredocMethodCallPosition, :config do context 'correct cases' do it 'accepts simple correct case' do expect_no_offenses(<<~RUBY) <<~SQL foo SQL RUBY end it 'accepts chained correct case' do expec...
ruby
MIT
99fa0fdd0481910d7d052f4c2ed01ad36178f404
2026-01-04T15:37:41.211519Z
false