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/lib/rubocop/cop/lint/safe_navigation_consistency.rb | lib/rubocop/cop/lint/safe_navigation_consistency.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Check to make sure that if safe navigation is used in an `&&` or `||` condition,
# consistent and appropriate safe navigation, without excess or deficiency,
# is used for all method calls on the same object.
#
# @... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/non_deterministic_require_order.rb | lib/rubocop/cop/lint/non_deterministic_require_order.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# `Dir[...]` and `Dir.glob(...)` do not make any guarantees about
# the order in which files are returned. The final order is
# determined by the operating system and file system.
# This means that using them in cases whe... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/symbol_conversion.rb | lib/rubocop/cop/lint/symbol_conversion.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for uses of literal strings converted to
# a symbol where a literal symbol could be used instead.
#
# There are two possible styles for this cop.
# `strict` (default) will register an offense for any incorr... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/ambiguous_range.rb | lib/rubocop/cop/lint/ambiguous_range.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for ambiguous ranges.
#
# Ranges have quite low precedence, which leads to unexpected behavior when
# using a range with other operators. This cop avoids that by making ranges
# explicit by requiring parent... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/void.rb | lib/rubocop/cop/lint/void.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for operators, variables, literals, lambda, proc and nonmutating
# methods used in void context.
#
# `each` blocks are allowed to prevent false positives.
# For example, the expression inside the `each` blo... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/empty_file.rb | lib/rubocop/cop/lint/empty_file.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Enforces that Ruby source files are not empty.
#
# @example
# # bad
# # Empty file
#
# # good
# # File containing non commented source lines
#
# @example AllowComments: true (... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/useless_access_modifier.rb | lib/rubocop/cop/lint/useless_access_modifier.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for redundant access modifiers, including those with no
# code, those which are repeated, those which are on top-level, and
# leading `public` modifiers in a class or module body.
# Conditionally-defined methods ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb | lib/rubocop/cop/lint/ambiguous_regexp_literal.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for ambiguous regexp literals in the first argument of
# a method invocation without parentheses.
#
# @example
#
# # bad
#
# # This is interpreted as a method invocation with a regexp ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/next_without_accumulator.rb | lib/rubocop/cop/lint/next_without_accumulator.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Don't omit the accumulator when calling `next` in a `reduce` block.
#
# @example
#
# # bad
# result = (1..4).reduce(0) do |acc, i|
# next if i.odd?
# acc + i
# end
#
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/implicit_string_concatenation.rb | lib/rubocop/cop/lint/implicit_string_concatenation.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for implicit string concatenation of string literals
# which are on the same line.
#
# @example
#
# # bad
# array = ['Item 1' 'Item 2']
#
# # good
# array = ['Item 1Ite... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/regexp_as_condition.rb | lib/rubocop/cop/lint/regexp_as_condition.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for regexp literals used as `match-current-line`.
# If a regexp literal is in condition, the regexp matches `$_` implicitly.
#
# @example
# # bad
# if /foo/
# do_something
# end
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/else_layout.rb | lib/rubocop/cop/lint/else_layout.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for odd `else` block layout - like
# having an expression on the same line as the `else` keyword,
# which is usually a mistake.
#
# Its autocorrection tweaks layout to keep the syntax. So, this autocorrecti... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb | lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks constructors for disjunctive assignments (`||=`) that should
# be plain assignments.
#
# So far, this cop is only concerned with disjunctive assignment of
# instance variables.
#
# In ruby, an i... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/redundant_string_coercion.rb | lib/rubocop/cop/lint/redundant_string_coercion.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for string conversion in string interpolation, `print`, `puts`, and `warn` arguments,
# which is redundant.
#
# @example
#
# # bad
# "result is #{something.to_s}"
# print something.t... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb | lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for trailing commas in attribute declarations, such as
# `#attr_reader`. Leaving a trailing comma will nullify the next method
# definition by overriding it with a getter method.
#
# @example
#
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/unreachable_loop.rb | lib/rubocop/cop/lint/unreachable_loop.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for loops that will have at most one iteration.
#
# A loop that can never reach the second iteration is a possible error in the code.
# In rare cases where only one iteration (or at most one iteration) is intende... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/inherit_exception.rb | lib/rubocop/cop/lint/inherit_exception.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Looks for error classes inheriting from `Exception`.
# It is configurable to suggest using either `StandardError` (default) or
# `RuntimeError` instead.
#
# @safety
# This cop's autocorrection is unsafe be... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb | lib/rubocop/cop/lint/non_local_exit_from_iterator.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for non-local exits from iterators without a return
# value. It registers an offense under these conditions:
#
# * No value is returned,
# * the block is preceded by a method chain,
# * the block has ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/uri_escape_unescape.rb | lib/rubocop/cop/lint/uri_escape_unescape.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Identifies places where `URI.escape` can be replaced by
# `CGI.escape`, `URI.encode_www_form`, or `URI.encode_www_form_component`
# depending on your specific use case.
# Also this cop identifies places where `URI.unesc... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/duplicate_case_condition.rb | lib/rubocop/cop/lint/duplicate_case_condition.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks that there are no repeated conditions
# used in case 'when' expressions.
#
# @example
#
# # bad
# case x
# when 'first'
# do_something
# when 'first'
# do... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/unified_integer.rb | lib/rubocop/cop/lint/unified_integer.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for using Fixnum or Bignum constant.
#
# @example
#
# # bad
# 1.is_a?(Fixnum)
# 1.is_a?(Bignum)
#
# # good
# 1.is_a?(Integer)
class UnifiedInteger < Base
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/duplicate_hash_key.rb | lib/rubocop/cop/lint/duplicate_hash_key.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for duplicated keys in hash literals.
# This cop considers both primitive types and constants for the hash keys.
#
# This cop mirrors a warning in Ruby 2.2.
#
# @example
#
# # bad
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb | lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Algorithmic constants for `OpenSSL::Cipher` and `OpenSSL::Digest`
# deprecated since OpenSSL version 2.2.0. Prefer passing a string
# instead.
#
# @example
#
# # bad
# OpenSSL::Cipher::AES.ne... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/shadowed_exception.rb | lib/rubocop/cop/lint/shadowed_exception.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for a rescued exception that get shadowed by a
# less specific exception being rescued before a more specific
# exception is rescued.
#
# An exception is considered shadowed if it is rescued after its
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/percent_symbol_array.rb | lib/rubocop/cop/lint/percent_symbol_array.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for colons and commas in %i, e.g. `%i(:foo, :bar)`
#
# It is more likely that the additional characters are unintended (for
# example, mistranslating an array of literals to percent string notation)
# rathe... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/each_with_object_argument.rb | lib/rubocop/cop/lint/each_with_object_argument.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks if each_with_object is called with an immutable
# argument. Since the argument is the object that the given block shall
# make calls on to build something based on the enumerable that
# each_with_object iterates ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb | lib/rubocop/cop/lint/redundant_cop_disable_directive.rb | # frozen_string_literal: true
# The Lint/RedundantCopDisableDirective cop needs to be disabled so as
# to be able to provide a (bad) example of a redundant disable.
# rubocop:disable Lint/RedundantCopDisableDirective
module RuboCop
module Cop
module Lint
# Detects instances of rubocop:disable comments that... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/unused_block_argument.rb | lib/rubocop/cop/lint/unused_block_argument.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for unused block arguments.
#
# @example
# # bad
# do_something do |used, unused|
# puts used
# end
#
# do_something do |bar|
# puts :foo
# end
#
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/duplicate_branch.rb | lib/rubocop/cop/lint/duplicate_branch.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks that there are no repeated bodies
# within `if/unless`, `case-when`, `case-in` and `rescue` constructs.
#
# With `IgnoreLiteralBranches: true`, branches are not registered
# as offenses if they return a bas... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/empty_ensure.rb | lib/rubocop/cop/lint/empty_ensure.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for empty `ensure` blocks.
#
# @example
#
# # bad
# def some_method
# do_something
# ensure
# end
#
# # bad
# begin
# do_something
#... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/identity_comparison.rb | lib/rubocop/cop/lint/identity_comparison.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Prefer `equal?` over `==` when comparing `object_id`.
#
# `Object#equal?` is provided to compare objects for identity, and in contrast
# `Object#==` is provided for the purpose of doing value comparison.
#
#... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/heredoc_method_call_position.rb | lib/rubocop/cop/lint/heredoc_method_call_position.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for the ordering of a method call where
# the receiver of the call is a HEREDOC.
#
# @example
# # bad
# <<-SQL
# bar
# SQL
# .strip_indent
#
# <<-SQL
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/nested_method_definition.rb | lib/rubocop/cop/lint/nested_method_definition.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for nested method definitions.
#
# @example
#
# # bad
#
# # `bar` definition actually produces methods in the same scope
# # as the outer `foo` method. Furthermore, the `bar` method
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/require_range_parentheses.rb | lib/rubocop/cop/lint/require_range_parentheses.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks that a range literal is enclosed in parentheses when the end of the range is
# at a line break.
#
# NOTE: The following is maybe intended for `(42..)`. But, compatible is `42..do_something`.
# So, this cop ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/triple_quotes.rb | lib/rubocop/cop/lint/triple_quotes.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for "triple quotes" (strings delimited by any odd number
# of quotes greater than 1).
#
# Ruby allows multiple strings to be implicitly concatenated by just
# being adjacent in a statement (ie. `"foo""bar" ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/require_parentheses.rb | lib/rubocop/cop/lint/require_parentheses.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for expressions where there is a call to a predicate
# method with at least one argument, where no parentheses are used around
# the parameter list, and a boolean operator, && or ||, is used in the
# last argumen... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb | lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for space between the name of a called method and a left
# parenthesis.
#
# @example
#
# # bad
# do_something (foo)
#
# # good
# do_something(foo)
# do_somethin... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb | lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Certain numeric operations have a constant result, usually 0 or 1.
# Multiplying a number by 0 will always return 0.
# Dividing a number by itself or raising it to the power of 0 will always return 1.
# As such, they ca... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/redundant_splat_expansion.rb | lib/rubocop/cop/lint/redundant_splat_expansion.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for unneeded usages of splat expansion.
#
# @example
#
# # bad
# a = *[1, 2, 3]
# a = *'a'
# a = *1
# ['a', 'b', *%w(c d e), 'f', 'g']
#
# # good
# c ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb | lib/rubocop/cop/lint/mixed_regexp_capture_types.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Do not mix named captures and numbered captures in a `Regexp` literal
# because numbered capture is ignored if they're mixed.
# Replace numbered captures with non-capturing groupings or
# named captures.
#
#... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb | lib/rubocop/cop/lint/shadowing_outer_local_variable.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for the use of local variable names from an outer scope
# in block arguments or block-local variables. This mirrors the warning
# given by `ruby -cw` prior to Ruby 2.6:
# "shadowing outer local variable - foo".
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/useless_setter_call.rb | lib/rubocop/cop/lint/useless_setter_call.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for setter call to local variable as the final
# expression of a function definition.
#
# @safety
# There are edge cases in which the local variable references a
# value that is also accessible ou... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/redundant_type_conversion.rb | lib/rubocop/cop/lint/redundant_type_conversion.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for redundant uses of `to_s`, `to_sym`, `to_i`, `to_f`, `to_d`, `to_r`, `to_c`,
# `to_a`, `to_h`, and `to_set`.
#
# When one of these methods is called on an object of the same type, that object
# is return... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/ordered_magic_comments.rb | lib/rubocop/cop/lint/ordered_magic_comments.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks the proper ordering of magic comments and whether
# a magic comment is not placed before a shebang.
#
# @safety
# This cop's autocorrection is unsafe because file encoding may change.
#
# @exa... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/or_assignment_to_constant.rb | lib/rubocop/cop/lint/or_assignment_to_constant.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for unintended or-assignment to a constant.
#
# Constants should always be assigned in the same location. And its value
# should always be the same. If constants are assigned in multiple
# locations, the re... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/literal_assignment_in_condition.rb | lib/rubocop/cop/lint/literal_assignment_in_condition.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for literal assignments in the conditions of `if`, `while`, and `until`.
# It emulates the following Ruby warning:
#
# [source,console]
# ----
# $ ruby -we 'if x = true; end'
# -e:1: warning: fo... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/refinement_import_methods.rb | lib/rubocop/cop/lint/refinement_import_methods.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks if `include` or `prepend` is called in `refine` block.
# These methods are deprecated and should be replaced with `Refinement#import_methods`.
#
# It emulates deprecation warnings in Ruby 3.1. Functionality has b... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/constant_definition_in_block.rb | lib/rubocop/cop/lint/constant_definition_in_block.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Do not define constants within a block, since the block's scope does not
# isolate or namespace the constant in any way.
#
# If you are trying to define that constant once, define it outside of
# the block instead... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb | lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for cases where exceptions unrelated to the numeric constructors `Integer()`,
# `Float()`, `BigDecimal()`, `Complex()`, and `Rational()` may be unintentionally swallowed.
#
# @safety
# The cop is unsafe f... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/assignment_in_condition.rb | lib/rubocop/cop/lint/assignment_in_condition.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Checks for assignments in the conditions of
# if/while/until.
#
# `AllowSafeAssignment` option for safe assignment.
# By safe assignment we mean putting parentheses around
# an assignment to indicate "I know... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/it_without_arguments_in_block.rb | lib/rubocop/cop/lint/it_without_arguments_in_block.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# Emulates the following Ruby warning in Ruby 3.3.
#
# [source,ruby]
# ----
# $ ruby -e '0.times { it }'
# -e:1: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4;
# u... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb | lib/rubocop/cop/lint/utils/nil_receiver_checker.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
module Utils
# Utility class that checks if the receiver can't be nil.
class NilReceiverChecker
NIL_METHODS = (nil.methods + %i[!]).to_set.freeze
def initialize(receiver, additional_nil_methods)
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/generator/configuration_injector.rb | lib/rubocop/cop/generator/configuration_injector.rb | # frozen_string_literal: true
module RuboCop
module Cop
class Generator
# A class that injects a require directive into the root RuboCop file.
# It looks for other directives that require files in the same (cop)
# namespace and injects the provided one in alpha
class ConfigurationInjector... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/generator/require_file_injector.rb | lib/rubocop/cop/generator/require_file_injector.rb | # frozen_string_literal: true
module RuboCop
module Cop
class Generator
# A class that injects a require directive into the root RuboCop file.
# It looks for other directives that require files in the same (cop)
# namespace and injects the provided one in alpha
class RequireFileInjector
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/method_called_on_do_end_block.rb | lib/rubocop/cop/style/method_called_on_do_end_block.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for methods called on a do...end block. The point of
# this check is that it's easy to miss the call tacked on to the block
# when reading code.
#
# @example
# # bad
# a do
# b
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/min_max_comparison.rb | lib/rubocop/cop/style/min_max_comparison.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Enforces the use of `max` or `min` instead of comparison for greater or less.
#
# NOTE: It can be used if you want to present limit or threshold in Ruby 2.7+.
# That it is slow though. So autocorrection will apply gene... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/proc.rb | lib/rubocop/cop/style/proc.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for uses of Proc.new where Kernel#proc
# would be more appropriate.
#
# @example
# # bad
# p = Proc.new { |n| puts n }
#
# # good
# p = proc { |n| puts n }
#
cla... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/even_odd.rb | lib/rubocop/cop/style/even_odd.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for places where `Integer#even?` or `Integer#odd?`
# can be used.
#
# @example
#
# # bad
# if x % 2 == 0
# end
#
# # good
# if x.even?
# end
clas... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/inverse_methods.rb | lib/rubocop/cop/style/inverse_methods.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for usages of not (`not` or `!`) called on a method
# when an inverse of that method can be used instead.
#
# Methods that can be inverted by a not (`not` or `!`) should be defined
# in `InverseMethods`.
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/comment_annotation.rb | lib/rubocop/cop/style/comment_annotation.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks that comment annotation keywords are written according
# to guidelines.
#
# Annotation keywords can be specified by overriding the cop's `Keywords`
# configuration. Keywords are allowed to be single words ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/class_equality_comparison.rb | lib/rubocop/cop/style/class_equality_comparison.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Enforces the use of `Object#instance_of?` instead of class comparison
# for equality.
# `==`, `equal?`, and `eql?` custom method definitions are allowed by default.
# These are customizable with `AllowedMethods` option... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/redundant_fetch_block.rb | lib/rubocop/cop/style/redundant_fetch_block.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Identifies places where `fetch(key) { value }` can be replaced by `fetch(key, value)`.
#
# In such cases `fetch(key, value)` method is faster than `fetch(key) { value }`.
#
# NOTE: The block string `'value'` in `... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/multiline_in_pattern_then.rb | lib/rubocop/cop/style/multiline_in_pattern_then.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks uses of the `then` keyword in multi-line `in` statement.
#
# @example
# # bad
# case expression
# in pattern then
# end
#
# # good
# case expression
# in p... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/exact_regexp_match.rb | lib/rubocop/cop/style/exact_regexp_match.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for exact regexp match inside `Regexp` literals.
#
# @example
#
# # bad
# string =~ /\Astring\z/
# string === /\Astring\z/
# string.match(/\Astring\z/)
# string.match?(/\A... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/numeric_literals.rb | lib/rubocop/cop/style/numeric_literals.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for big numeric literals without `_` between groups
# of digits in them.
#
# Additional allowed patterns can be added by adding regexps to
# the `AllowedPatterns` configuration. All regexps are treated
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/data_inheritance.rb | lib/rubocop/cop/style/data_inheritance.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for inheritance from `Data.define` to avoid creating the anonymous parent class.
# Inheriting from `Data.define` adds a superfluous level in inheritance tree.
#
# @safety
# Autocorrection is unsafe becau... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/mixin_usage.rb | lib/rubocop/cop/style/mixin_usage.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks that `include`, `extend` and `prepend` statements appear
# inside classes and modules, not at the top level, so as to not affect
# the behavior of `Object`.
#
# @example
# # bad
# include M... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/for.rb | lib/rubocop/cop/style/for.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Looks for uses of the `for` keyword or `each` method. The
# preferred alternative is set in the EnforcedStyle configuration
# parameter. An `each` call with a block on a single line is always
# allowed.
#
#... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/struct_inheritance.rb | lib/rubocop/cop/style/struct_inheritance.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for inheritance from `Struct.new`. Inheriting from `Struct.new`
# adds a superfluous level in inheritance tree.
#
# @safety
# Autocorrection is unsafe because it will change the inheritance
# tre... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/case_like_if.rb | lib/rubocop/cop/style/case_like_if.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Identifies places where `if-elsif` constructions
# can be replaced with `case-when`.
#
# @safety
# This cop is unsafe. `case` statements use `===` for equality,
# so if the original conditional used a d... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/map_to_set.rb | lib/rubocop/cop/style/map_to_set.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Looks for uses of `map.to_set` or `collect.to_set` that could be
# written with just `to_set`.
#
# @safety
# This cop is unsafe, as it can produce false positives if the receiver
# is not an `Enumerable... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/numeric_predicate.rb | lib/rubocop/cop/style/numeric_predicate.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for usage of comparison operators (`==`,
# `>`, `<`) to test numbers as zero, positive, or negative.
# These can be replaced by their respective predicate methods.
# This cop can also be configured to do the rev... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/expand_path_arguments.rb | lib/rubocop/cop/style/expand_path_arguments.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for use of the `File.expand_path` arguments.
# Likewise, it also checks for the `Pathname.new` argument.
#
# Contrastive bad case and good case are alternately shown in
# the following examples.
#
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/hash_each_methods.rb | lib/rubocop/cop/style/hash_each_methods.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for uses of `each_key` and `each_value` `Hash` methods.
#
# NOTE: If you have an array of two-element arrays, you can put
# parentheses around the block arguments to indicate that you're not
# working ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/trailing_underscore_variable.rb | lib/rubocop/cop/style/trailing_underscore_variable.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for extra underscores in variable assignment.
#
# @example
# # bad
# a, b, _ = foo
# a, b, _, = foo
# a, _, _ = foo
# a, _, _, = foo
#
# # good
# a, b, = f... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/select_by_regexp.rb | lib/rubocop/cop/style/select_by_regexp.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Looks for places where a subset of an Enumerable (array,
# range, set, etc.; see note below) is calculated based on a `Regexp`
# match, and suggests `grep` or `grep_v` instead.
#
# NOTE: Hashes do not behave as y... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/ip_addresses.rb | lib/rubocop/cop/style/ip_addresses.rb | # frozen_string_literal: true
require 'resolv'
module RuboCop
module Cop
module Style
# Checks for hardcoded IP addresses, which can make code
# brittle. IP addresses are likely to need to be changed when code
# is deployed to a different server or environment, which may break
# a deploy... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/end_block.rb | lib/rubocop/cop/style/end_block.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for END blocks.
#
# @example
# # bad
# END { puts 'Goodbye!' }
#
# # good
# at_exit { puts 'Goodbye!' }
#
class EndBlock < Base
extend AutoCorrector
M... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/file_read.rb | lib/rubocop/cop/style/file_read.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Favor `File.(bin)read` convenience methods.
#
# @example
# # bad - text mode
# File.open(filename).read
# File.open(filename, &:read)
# File.open(filename) { |f| f.read }
# File.open(f... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/unless_else.rb | lib/rubocop/cop/style/unless_else.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Looks for `unless` expressions with `else` clauses.
#
# @example
# # bad
# unless foo_bar.nil?
# # do something...
# else
# # do a different thing...
# end
#
# ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/require_order.rb | lib/rubocop/cop/style/require_order.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Sort `require` and `require_relative` in alphabetical order.
#
# @safety
# This cop's autocorrection is unsafe because it will obviously change the execution order.
#
# @example
# # bad
# ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/self_assignment.rb | lib/rubocop/cop/style/self_assignment.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Enforces the use the shorthand for self-assignment.
#
# @example
#
# # bad
# x = x + 1
#
# # good
# x += 1
class SelfAssignment < Base
extend AutoCorrector
M... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/bitwise_predicate.rb | lib/rubocop/cop/style/bitwise_predicate.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Prefer bitwise predicate methods over direct comparison operations.
#
# @safety
# This cop is unsafe, as it can produce false positives if the receiver
# is not an `Integer` object.
#
# @example
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/and_or.rb | lib/rubocop/cop/style/and_or.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for uses of `and` and `or`, and suggests using `&&` and
# `||` instead. It can be configured to check only in conditions or in
# all contexts.
#
# @safety
# Autocorrection is unsafe because there i... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/dir_empty.rb | lib/rubocop/cop/style/dir_empty.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Prefer to use `Dir.empty?('path/to/dir')` when checking if a directory is empty.
#
# @example
# # bad
# Dir.entries('path/to/dir').size == 2
# Dir.children('path/to/dir').empty?
# Dir.children... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/symbol_array.rb | lib/rubocop/cop/style/symbol_array.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for array literals made up of symbols that are not
# using the %i() syntax.
#
# Alternatively, it checks for symbol arrays using the %i() syntax on
# projects which do not want to use that syntax, perhaps ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/multiline_if_then.rb | lib/rubocop/cop/style/multiline_if_then.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for uses of the `then` keyword in multi-line if statements.
#
# @example
# # bad
# # This is considered bad practice.
# if cond then
# end
#
# # good
# # If statem... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/random_with_offset.rb | lib/rubocop/cop/style/random_with_offset.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for the use of randomly generated numbers,
# added/subtracted with integer literals, as well as those with
# Integer#succ and Integer#pred methods. Prefer using ranges instead,
# as it clearly states the intenti... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/hash_except.rb | lib/rubocop/cop/style/hash_except.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
# that can be replaced with `Hash#except` method.
#
# This cop should only be enabled on Ruby version 3.0 or higher.
# (`Hash#except` w... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/conditional_assignment.rb | lib/rubocop/cop/style/conditional_assignment.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Helper module to provide common methods to classes needed for the
# ConditionalAssignment Cop.
module ConditionalAssignmentHelper
extend NodePattern::Macros
EQUAL = '='
END_ALIGNMENT = 'Layout/EndAli... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/redundant_filter_chain.rb | lib/rubocop/cop/style/redundant_filter_chain.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Identifies usages of `any?`, `empty?` or `none?` predicate methods
# chained to `select`/`filter`/`find_all` and change them to use predicate method instead.
#
# @safety
# This cop's autocorrection is unsafe be... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/map_into_array.rb | lib/rubocop/cop/style/map_into_array.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for usages of `each` with `<<`, `push`, or `append` which
# can be replaced by `map`.
#
# If `PreferredMethods` is configured for `map` in `Style/CollectionMethods`,
# this cop uses the specified method fo... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb | lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for predicate method definitions that return `nil`.
# A predicate method should only return a boolean value.
#
# @safety
# Autocorrection is marked as unsafe because the change of the return value
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/array_intersect_with_single_element.rb | lib/rubocop/cop/style/array_intersect_with_single_element.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Use `include?(element)` instead of `intersect?([element])`.
#
# @safety
# The receiver might not be an array.
#
# @example
# # bad
# array.intersect?([element])
#
# # good
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/env_home.rb | lib/rubocop/cop/style/env_home.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for consistent usage of `ENV['HOME']`. If `nil` is used as
# the second argument of `ENV.fetch`, it is treated as a bad case like `ENV[]`.
#
# @safety
# The cop is unsafe because the result when `nil` is... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/comparable_clamp.rb | lib/rubocop/cop/style/comparable_clamp.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.
#
# This cop supports autocorrection for `if/elsif/else` bad style only.
# Because `ArgumentError` occurs if the minimum and maximum ... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/copyright.rb | lib/rubocop/cop/style/copyright.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Check that a copyright notice was given in each source file.
#
# The default regexp for an acceptable copyright notice can be found in
# config/default.yml. The default can be changed as follows:
#
# [sourc... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/non_nil_check.rb | lib/rubocop/cop/style/non_nil_check.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for non-nil checks, which are usually redundant.
#
# With `IncludeSemanticChanges` set to `false` by default, this cop
# does not report offenses for `!x.nil?` and does no changes that might
# change behav... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/redundant_condition.rb | lib/rubocop/cop/style/redundant_condition.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for unnecessary conditional expressions.
#
# NOTE: Since the intention of the comment cannot be automatically determined,
# autocorrection is not applied when a comment is used, as shown below:
#
# [... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
rubocop/rubocop | https://github.com/rubocop/rubocop/blob/99fa0fdd0481910d7d052f4c2ed01ad36178f404/lib/rubocop/cop/style/symbol_proc.rb | lib/rubocop/cop/style/symbol_proc.rb | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Use symbols as procs when possible.
#
# If you prefer a style that allows block for method with arguments,
# please set `true` to `AllowMethodsWithArguments`.
# `define_method?` methods are allowed by default.
... | ruby | MIT | 99fa0fdd0481910d7d052f4c2ed01ad36178f404 | 2026-01-04T15:37:41.211519Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.