source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/string_literal_corrector.rb
Ruby
mit
12,856
master
500
# frozen_string_literal: true module RuboCop module Cop # This autocorrects string literals class StringLiteralCorrector extend Util class << self def correct(corrector, node, style) return if node.dstr_type? str = node.str_content if style == :single_quote...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/space_corrector.rb
Ruby
mit
12,856
master
1,578
# frozen_string_literal: true module RuboCop module Cop # This autocorrects whitespace class SpaceCorrector extend SurroundingSpace class << self attr_reader :processed_source def empty_corrections(processed_source, corrector, empty_config, left_tok...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/empty_line_corrector.rb
Ruby
mit
12,856
master
561
# frozen_string_literal: true module RuboCop module Cop # This class does empty line autocorrection class EmptyLineCorrector class << self def correct(corrector, node) offense_style, range = node case offense_style when :no_empty_lines corrector.remove...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb
Ruby
mit
12,856
master
3,622
# frozen_string_literal: true module RuboCop module Cop # This class autocorrects lambda literal to method notation. class LambdaLiteralToMethodCorrector def initialize(block_node) @block_node = block_node @method = block_node.send_node @arguments = block_node.arguments ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/punctuation_corrector.rb
Ruby
mit
12,856
master
627
# frozen_string_literal: true module RuboCop module Cop # This autocorrects punctuation class PunctuationCorrector class << self def remove_space(corrector, space_before) corrector.remove(space_before) end def add_space(corrector, token) corrector.replace(to...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/parentheses_corrector.rb
Ruby
mit
12,856
master
2,943
# frozen_string_literal: true module RuboCop module Cop # This autocorrects parentheses class ParenthesesCorrector class << self include RangeHelp COMMA_REGEXP = /(?<=\))\s*,/.freeze def correct(corrector, node) buffer = node.source_range.source_buffer corr...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/percent_literal_corrector.rb
Ruby
mit
12,856
master
3,918
# frozen_string_literal: true module RuboCop module Cop # This autocorrects percent literals class PercentLiteralCorrector include Util attr_reader :config, :preferred_delimiters def initialize(config, preferred_delimiters) @config = config @preferred_delimiters = preferre...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/if_then_corrector.rb
Ruby
mit
12,856
master
1,611
# frozen_string_literal: true module RuboCop module Cop # This class autocorrects `if...then` structures to a multiline `if` statement class IfThenCorrector DEFAULT_INDENTATION_WIDTH = 2 def initialize(if_node, indentation: nil) @if_node = if_node @indentation = indentation || DE...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/alignment_corrector.rb
Ruby
mit
12,856
master
4,544
# frozen_string_literal: true module RuboCop module Cop # This class does autocorrection of nodes that should just be moved to # the left or to the right, amount being determined by the instance # variable column_delta. class AlignmentCorrector extend RangeHelp extend Alignment cla...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/correctors/ordered_gem_corrector.rb
Ruby
mit
12,856
master
1,222
# frozen_string_literal: true module RuboCop module Cop # This autocorrects gem dependency order class OrderedGemCorrector class << self include OrderedGemNode include RangeHelp attr_reader :processed_source, :comments_as_separators def correct(processed_source, node, ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/bundler/gem_comment.rb
Ruby
mit
12,856
master
5,435
# frozen_string_literal: true module RuboCop module Cop module Bundler # Each gem in the Gemfile should have a comment explaining # its purpose in the project, or the reason for its version # or source. # # The optional "OnlyFor" configuration array # can be used to only regis...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/bundler/ordered_gems.rb
Ruby
mit
12,856
master
1,849
# frozen_string_literal: true module RuboCop module Cop module Bundler # Gems should be alphabetically sorted within groups. # # @example # # bad # gem 'rubocop' # gem 'rspec' # # # good # gem 'rspec' # gem 'rubocop' # # # good...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/bundler/gem_filename.rb
Ruby
mit
12,856
master
3,413
# frozen_string_literal: true module RuboCop module Cop module Bundler # Verifies that a project contains Gemfile or gems.rb file and correct # associated lock file based on the configuration. # # @example EnforcedStyle: Gemfile (default) # # bad # Project contains gems.rb...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/bundler/duplicated_group.rb
Ruby
mit
12,856
master
3,636
# frozen_string_literal: true module RuboCop module Cop module Bundler # A Gem group, or a set of groups, should be listed only once in a Gemfile. # # For example, if the values of `source`, `git`, `platforms`, or `path` # surrounding `group` are different, no offense will be registered: ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/bundler/gem_version.rb
Ruby
mit
12,856
master
3,449
# frozen_string_literal: true module RuboCop module Cop module Bundler # Enforce that Gem version specifications or a commit reference (branch, # ref, or tag) are either required or forbidden. # # @example EnforcedStyle: required (default) # # bad # gem 'rubocop' # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/bundler/duplicated_gem.rb
Ruby
mit
12,856
master
2,814
# frozen_string_literal: true module RuboCop module Cop module Bundler # A Gem's requirements should be listed only once in a Gemfile. # # @example # # bad # gem 'rubocop' # gem 'rubocop' # # # bad # group :development do # gem 'rubocop' ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/bundler/insecure_protocol_source.rb
Ruby
mit
12,856
master
2,903
# frozen_string_literal: true module RuboCop module Cop module Bundler # Passing symbol arguments to `source` (e.g. `source :rubygems`) is # deprecated because they default to using HTTP requests. Instead, specify # `'https://rubygems.org'` if possible, or `'http://rubygems.org'` if not. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/empty_file.rb
Ruby
mit
12,856
master
1,048
# 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 (...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/circular_argument_reference.rb
Ruby
mit
12,856
master
2,720
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for circular argument references in optional keyword # arguments and optional ordinal arguments. # # NOTE: This syntax was made invalid on Ruby 2.7 - Ruby 3.3 but is allowed # again since Ruby 3.4. # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/regexp_as_condition.rb
Ruby
mit
12,856
master
905
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/require_range_parentheses.rb
Ruby
mit
12,856
master
1,432
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/safe_navigation_with_empty.rb
Ruby
mit
12,856
master
1,352
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks to make sure safe navigation isn't used with `empty?` in # a conditional. # # While the safe navigation operator is generally a good idea, when # checking `foo&.empty?` in a conditional, `foo` being `nil` w...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/unified_integer.rb
Ruby
mit
12,856
master
922
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/non_deterministic_require_order.rb
Ruby
mit
12,856
master
6,240
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/multiple_comparison.rb
Ruby
mit
12,856
master
1,510
# frozen_string_literal: true module RuboCop module Cop module Lint # In math and Python, we can use `x < y < z` style comparison to compare # multiple value. However, we can't use the comparison in Ruby. However, # the comparison is not syntax error. This cop checks the bad usage of # co...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_cop_disable_directive.rb
Ruby
mit
12,856
master
12,972
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/rescue_exception.rb
Ruby
mit
12,856
master
880
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `rescue` blocks targeting the `Exception` class. # # @example # # # bad # begin # do_something # rescue Exception # handle_exception # end # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_methods.rb
Ruby
mit
12,856
master
13,252
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for duplicated instance (or singleton) method # definitions. # # NOTE: Aliasing a method to itself is allowed, as it indicates that # the developer intends to suppress Ruby's method redefinition warnings. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/uri_regexp.rb
Ruby
mit
12,856
master
1,858
# frozen_string_literal: true module RuboCop module Cop module Lint # Identifies places where `URI.regexp` is obsolete and should not be used. # # For Ruby 3.3 or lower, use `URI::DEFAULT_PARSER.make_regexp`. # For Ruby 3.4 or higher, use `URI::RFC2396_PARSER.make_regexp`. # #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/else_layout.rb
Ruby
mit
12,856
master
3,120
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/to_enum_arguments.rb
Ruby
mit
12,856
master
3,061
# frozen_string_literal: true module RuboCop module Cop module Lint # Ensures that `to_enum`/`enum_for`, called for the current method, # has correct arguments. # # @example # # bad # def foo(x, y = 1) # return to_enum(__callee__, x) # `y` is missing # en...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/percent_string_array.rb
Ruby
mit
12,856
master
2,149
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for quotes and commas in %w, e.g. `%w('foo', "bar")` # # It is more likely that the additional characters are unintended (for # example, mistranslating an array of literals to percent string notation) # rat...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/hash_compare_by_identity.rb
Ruby
mit
12,856
master
1,484
# frozen_string_literal: true module RuboCop module Cop module Lint # Prefer using `Hash#compare_by_identity` rather than using `object_id` # for hash keys. # # This cop looks for hashes being keyed by objects' `object_id`, using # one of these methods: `key?`, `has_key?`, `fetch`, ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/empty_when.rb
Ruby
mit
12,856
master
1,382
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for the presence of `when` branches without a body. # # @example # # # bad # case foo # when bar # do_something # when baz # end # # # good # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/empty_in_pattern.rb
Ruby
mit
12,856
master
1,461
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for the presence of `in` pattern branches without a body. # # @example # # # bad # case condition # in [a] # do_something # in [a, b] # end # # # go...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb
Ruby
mit
12,856
master
3,554
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_safe_navigation.rb
Ruby
mit
12,856
master
8,559
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for redundant safe navigation calls. # Use cases where a constant, named in camel case for classes and modules is `nil` are rare, # and an offense is not detected when the receiver is a constant. The detection also app...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/shared_mutable_default.rb
Ruby
mit
12,856
master
2,675
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `Hash` creation with a mutable default value. # Creating a `Hash` in such a way will share the default value # across all keys, causing unexpected behavior when modifying it. # # For example, when the `...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_cop_enable_directive.rb
Ruby
mit
12,856
master
3,915
# frozen_string_literal: true module RuboCop module Cop module Lint # Detects instances of rubocop:enable comments that can be # removed. # # When comment enables all cops at once `rubocop:enable all` # that cop checks whether any cop was actually enabled. # # @example ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/cop_directive_syntax.rb
Ruby
mit
12,856
master
3,112
# frozen_string_literal: true # rubocop:disable Lint/RedundantCopDisableDirective # rubocop:disable Style/DoubleCopDisableDirective module RuboCop module Cop module Lint # Checks that `# rubocop:enable ...` and `# rubocop:disable ...` statements # are strictly formatted. # # A comment can...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/return_in_void_context.rb
Ruby
mit
12,856
master
1,417
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for the use of a return with a value in a context # where the value will be ignored. (initialize and setter methods) # # @example # # # bad # def initialize # foo # retur...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/float_out_of_range.rb
Ruby
mit
12,856
master
692
# frozen_string_literal: true module RuboCop module Cop module Lint # Identifies `Float` literals which are, like, really really really # really really really really really big. Too big. No-one needs Floats # that big. If you need a float that big, something is wrong with you. # # @...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/ambiguous_operator.rb
Ruby
mit
12,856
master
3,278
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for ambiguous operators in the first argument of a # method invocation without parentheses. # # @example # # # bad # # # The `*` is interpreted as a splat operator but it could possibl...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/inherit_exception.rb
Ruby
mit
12,856
master
2,970
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/suppressed_exception.rb
Ruby
mit
12,856
master
2,721
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `rescue` blocks with no body. # # @example # # # bad # def some_method # do_something # rescue # end # # # bad # begin # do_something ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb
Ruby
mit
12,856
master
3,789
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for redundant quantifiers inside `Regexp` literals. # # It is always allowed when interpolation is used in a regexp literal, # because it's unknown what kind of string will be expanded as a result: # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb
Ruby
mit
12,856
master
2,283
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/ambiguous_block_association.rb
Ruby
mit
12,856
master
3,195
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for ambiguous block association with method # when param passed without parentheses. # # This cop can customize allowed methods with `AllowedMethods`. # By default, there are no methods to allowed. # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/symbol_conversion.rb
Ruby
mit
12,856
master
5,793
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/next_without_accumulator.rb
Ruby
mit
12,856
master
1,458
# 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 # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/empty_interpolation.rb
Ruby
mit
12,856
master
1,035
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for empty interpolation. # # @example # # # bad # "result is #{}" # # # good # "result is #{some_result}" class EmptyInterpolation < Base include Interpolation ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/constant_definition_in_block.rb
Ruby
mit
12,856
master
2,662
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/empty_conditional_body.rb
Ruby
mit
12,856
master
4,112
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for the presence of `if`, `elsif` and `unless` branches without a body. # # NOTE: empty `else` branches are handled by `Style/EmptyElse`. # # @example # # bad # if condition # end ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/require_parentheses.rb
Ruby
mit
12,856
master
1,766
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/safe_navigation_consistency.rb
Ruby
mit
12,856
master
5,519
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks 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. # # @safety ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/rescue_type.rb
Ruby
mit
12,856
master
2,091
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for arguments to `rescue` that will result in a `TypeError` # if an exception is raised. # # @example # # bad # begin # bar # rescue nil # baz # end # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/shadowing_outer_local_variable.rb
Ruby
mit
12,856
master
3,812
# 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". ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/shadowed_argument.rb
Ruby
mit
12,856
master
5,242
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for shadowed arguments. # # This cop has `IgnoreImplicitReferences` configuration option. # It means argument shadowing is used in order to pass parameters # to zero arity `super` when `IgnoreImplicitRefere...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/loop.rb
Ruby
mit
12,856
master
2,030
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for uses of `begin...end while/until something`. # # @safety # The cop is unsafe because behavior can change in some cases, including # if a local variable inside the loop body is accessed outside of it...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/interpolation_check.rb
Ruby
mit
12,856
master
2,416
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for interpolation in a single quoted string. # # @safety # This cop's autocorrection is unsafe because although it always replaces single quotes as # if it were miswritten double quotes, it is not alway...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/shadowed_exception.rb
Ruby
mit
12,856
master
5,509
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/nested_percent_literal.rb
Ruby
mit
12,856
master
2,010
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for nested percent literals. # # @example # # # bad # # # The percent literal for nested_attributes is parsed as four tokens, # # yielding the array [:name, :content, :"%i[incorrectl...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/missing_cop_enable_directive.rb
Ruby
mit
12,856
master
3,826
# frozen_string_literal: true # rubocop:disable Lint/RedundantCopDisableDirective module RuboCop module Cop module Lint # Checks that there is an `# rubocop:enable ...` statement # after a `# rubocop:disable ...` statement. This will prevent leaving # cop disables on wide ranges of code, that l...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb
Ruby
mit
12,856
master
2,039
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for places where binary operator has identical operands. # # It covers comparison operators: `==`, `===`, `=~`, `>`, `>=`, `<`, ``<=``; # bitwise operators: `|`, `^`, `&`; # boolean operators: `&&`, `||` ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb
Ruby
mit
12,856
master
2,156
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for underscore-prefixed variables that are actually # used. # # Since block keyword arguments cannot be arbitrarily named at call # sites, the `AllowKeywordBlockArguments` will allow use of underscore- ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/empty_block.rb
Ruby
mit
12,856
master
2,739
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for blocks without a body. # Such empty blocks are typically an oversight or we should provide a comment # to clarify what we're aiming for. # # Empty lambdas and procs are ignored by default. # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/or_assignment_to_constant.rb
Ruby
mit
12,856
master
1,097
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/big_decimal_new.rb
Ruby
mit
12,856
master
1,094
# frozen_string_literal: true module RuboCop module Cop module Lint # `BigDecimal.new()` is deprecated since BigDecimal 1.3.3. # This cop identifies places where `BigDecimal.new()` # can be replaced by `BigDecimal()`. # # @example # # bad # BigDecimal.new(123.456, 3)...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/percent_symbol_array.rb
Ruby
mit
12,856
master
1,721
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/each_with_object_argument.rb
Ruby
mit
12,856
master
1,171
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/non_local_exit_from_iterator.rb
Ruby
mit
12,856
master
2,851
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb
Ruby
mit
12,856
master
3,044
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb
Ruby
mit
12,856
master
1,461
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for overwriting an exception with an exception result by use ``rescue =>``. # # You intended to write as `rescue StandardError`. # However, you have written `rescue => StandardError`. # In that case, the re...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_rescue.rb
Ruby
mit
12,856
master
2,428
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for useless ``rescue``s, which only reraise rescued exceptions. # # @example # # bad # def foo # do_something # rescue # raise # end # # # bad # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/literal_in_interpolation.rb
Ruby
mit
12,856
master
7,190
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for interpolated literals. # # NOTE: Array literals interpolated in regexps are not handled by this cop, but # by `Lint/ArrayLiteralInRegexp` instead. # # @example # # # bad # "r...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_require_statement.rb
Ruby
mit
12,856
master
2,894
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for unnecessary `require` statement. # # The following features are unnecessary `require` statement because # they are already loaded. e.g. Ruby 2.2: # # ruby -ve 'p $LOADED_FEATURES.reject { |featu...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_default_value_argument.rb
Ruby
mit
12,856
master
2,952
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for usage of method `fetch` or `Array.new` with default value argument # and block. In such cases, block will always be used as default value. # # This cop emulates Ruby warning "block supersedes default value ar...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_require.rb
Ruby
mit
12,856
master
1,609
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for duplicate ``require``s and ``require_relative``s. # # @safety # This cop's autocorrection is unsafe because it may break the dependency order # of `require`. # # @example # # bad...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_assignment.rb
Ruby
mit
12,856
master
8,485
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for every useless assignment to local variable in every # scope. # The basic idea for this cop was from the warning of `ruby -cw`: # # [source,console] # ---- # assigned but unused variable - fo...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_with_index.rb
Ruby
mit
12,856
master
2,194
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for redundant `with_index`. # # @example # # bad # ary.each_with_index do |v| # v # end # # # good # ary.each do |v| # v # end # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_case_condition.rb
Ruby
mit
12,856
master
912
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/non_atomic_file_operation.rb
Ruby
mit
12,856
master
6,262
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for non-atomic file operation. # And then replace it with a nearly equivalent and atomic method. # # These can cause problems that are difficult to reproduce, # especially in cases of frequent file operatio...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/unused_method_argument.rb
Ruby
mit
12,856
master
4,279
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for unused method arguments. # # @example # # bad # def some_method(used, unused, _unused_but_allowed) # puts used # end # # # good # def some_method(used, _unuse...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_branch.rb
Ruby
mit
12,856
master
5,287
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/erb_new_arguments.rb
Ruby
mit
12,856
master
5,763
# frozen_string_literal: true module RuboCop module Cop module Lint # Emulates the following Ruby warnings in Ruby 2.6. # # [source,console] # ---- # $ cat example.rb # ERB.new('hi', nil, '-', '@output_buffer') # $ ruby -rerb example.rb # example.rb:1: warning: Pas...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_or.rb
Ruby
mit
12,856
master
3,897
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for useless OR (`||` and `or`) expressions. # # Some methods always return a truthy value, even when called # on `nil` (e.g. `nil.to_i` evaluates to `0`). Therefore, OR expressions # appended after these me...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb
Ruby
mit
12,856
master
1,576
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for the presence of a `return` inside a `begin..end` block # in assignment contexts. # In this situation, the `return` will result in an exit from the current # method, possibly leading to unexpected behavior. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/ambiguous_range.rb
Ruby
mit
12,856
master
3,546
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/format_parameter_mismatch.rb
Ruby
mit
12,856
master
5,752
# frozen_string_literal: true module RuboCop module Cop module Lint # This lint sees if there is a mismatch between the number of # expected fields for format/sprintf/#% and what is actually # passed as arguments. # # In addition, it checks whether different formats are used in the ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/void.rb
Ruby
mit
12,856
master
10,550
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb
Ruby
mit
12,856
master
2,379
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for Regexpes (both literals and via `Regexp.new` / `Regexp.compile`) # that contain unescaped `]` characters. # # It emulates the following Ruby warning: # # [source,ruby] # ---- # $ ruby ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/unreachable_code.rb
Ruby
mit
12,856
master
4,038
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for unreachable code. # The check are based on the presence of flow of control # statement in non-final position in `begin` (implicit) blocks. # # @example # # # bad # def some_method ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/lambda_without_literal_block.rb
Ruby
mit
12,856
master
1,577
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks uses of lambda without a literal block. # It emulates the following warning in Ruby 3.0: # # $ ruby -vwe 'lambda(&proc {})' # ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19] # -e...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/flip_flop.rb
Ruby
mit
12,856
master
917
# frozen_string_literal: true module RuboCop module Cop module Lint # Looks for uses of flip-flop operator # based on the Ruby Style Guide. # # Here is the history of flip-flops in Ruby. # flip-flop operator is deprecated in Ruby 2.6.0 and # the deprecation has been reverted b...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/it_without_arguments_in_block.rb
Ruby
mit
12,856
master
1,445
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/empty_class.rb
Ruby
mit
12,856
master
2,199
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for classes and metaclasses without a body. # Such empty classes and metaclasses are typically an oversight or we should provide a comment # to be clearer what we're aiming for. # # @example # # bad...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/numbered_parameter_assignment.rb
Ruby
mit
12,856
master
1,577
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for uses of numbered parameter assignment. # It emulates the following warning in Ruby 2.7: # # $ ruby -ve '_1 = :value' # ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19] # -e:...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_else_without_rescue.rb
Ruby
mit
12,856
master
1,014
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for useless `else` in `begin..end` without `rescue`. # # NOTE: This syntax is no longer valid on Ruby 2.6 or higher. # # @example # # # bad # begin # do_something # e...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/out_of_range_regexp_ref.rb
Ruby
mit
12,856
master
3,842
# frozen_string_literal: true module RuboCop module Cop module Lint # Looks for references of `Regexp` captures that are out of range # and thus always returns nil. # # @safety # This cop is unsafe because it is naive in how it determines what # references are available ba...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/constant_reassignment.rb
Ruby
mit
12,856
master
5,732
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for constant reassignments. # # Emulates Ruby's runtime warning "already initialized constant X" # when a constant is reassigned in the same file and namespace. # # The cop tracks constants defined vi...