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/lint/incompatible_io_select_with_fiber_scheduler.rb
Ruby
mit
12,856
master
2,668
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `IO.select` that is incompatible with Fiber Scheduler since Ruby 3.0. # # When an array of IO objects waiting for an exception (the third argument of `IO.select`) # is used as an argument, there is no alterna...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/empty_expression.rb
Ruby
mit
12,856
master
709
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for the presence of empty expressions. # # @example # # # bad # # foo = () # if () # bar # end # # # good # # foo = (some_expression) ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/ambiguous_regexp_literal.rb
Ruby
mit
12,856
master
2,511
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/debugger.rb
Ruby
mit
12,856
master
4,283
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for debug calls (such as `debugger` or `binding.pry`) that should # not be kept for production code. # # The cop can be configured using `DebuggerMethods`. By default, a number of gems # debug entrypoints a...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_splat_expansion.rb
Ruby
mit
12,856
master
6,200
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/unreachable_loop.rb
Ruby
mit
12,856
master
5,929
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb
Ruby
mit
12,856
master
2,863
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_type_conversion.rb
Ruby
mit
12,856
master
8,866
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/implicit_string_concatenation.rb
Ruby
mit
12,856
master
3,477
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/unreachable_pattern_branch.rb
Ruby
mit
12,856
master
3,040
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for unreachable `in` pattern branches in `case...in` statements. # # An `in` branch is unreachable when a previous branch uses an unguarded # catch-all pattern that matches any value unconditionally. Any `in` bra...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/nested_method_definition.rb
Ruby
mit
12,856
master
3,620
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/mixed_case_range.rb
Ruby
mit
12,856
master
3,618
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for mixed-case character ranges since they include likely unintended characters. # # Offenses are registered for regexp character classes like `/[A-z]/` # as well as range objects like `('A'..'z')`. # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/struct_new_override.rb
Ruby
mit
12,856
master
3,144
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks unexpected overrides of the `Struct` built-in methods # via `Struct.new`. # # @example # # bad # Bad = Struct.new(:members, :clone, :count) # b = Bad.new([], true, 1) # b.members #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/ineffective_access_modifier.rb
Ruby
mit
12,856
master
3,469
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `private` or `protected` access modifiers which are # applied to a singleton method. These access modifiers do not make # singleton methods private/protected. `private_class_method` can be # used for that. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_string_coercion.rb
Ruby
mit
12,856
master
1,865
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/script_permission.rb
Ruby
mit
12,856
master
2,074
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks if a file which has a shebang line as # its first line is granted execute permission. # # @example # # bad # # # A file which has a shebang line as its first line is not # # granted ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_numeric_operation.rb
Ruby
mit
12,856
master
2,064
# frozen_string_literal: true module RuboCop module Cop module Lint # Certain numeric operations have no impact, being: # Adding or subtracting 0, multiplying or dividing by 1 or raising to the power of 1. # These are probably leftover from debugging, or are mistakes. # # @example ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/safe_navigation_chain.rb
Ruby
mit
12,856
master
4,562
# frozen_string_literal: true module RuboCop module Cop module Lint # The safe navigation operator returns nil if the receiver is # nil. If you chain an ordinary method call after a safe # navigation operator, it raises NoMethodError. We should use a # safe navigation operator after a saf...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/to_json.rb
Ruby
mit
12,856
master
1,306
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks to make sure `#to_json` includes an optional argument. # When overriding `#to_json`, callers may invoke JSON # generation via `JSON.generate(your_obj)`. Since `JSON#generate` allows # for an optional argument, yo...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/ordered_magic_comments.rb
Ruby
mit
12,856
master
2,381
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_magic_comment.rb
Ruby
mit
12,856
master
1,848
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for duplicated magic comments. # # @example # # # bad # # # encoding: ascii # # encoding: ascii # # # good # # # encoding: ascii # # # bad ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/array_literal_in_regexp.rb
Ruby
mit
12,856
master
3,999
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for an array literal interpolated inside a regexp. # # When interpolating an array literal, it is converted to a string. This means # that when inside a regexp, it acts as a character class but with additional ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/uri_escape_unescape.rb
Ruby
mit
12,856
master
2,824
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/constant_resolution.rb
Ruby
mit
12,856
master
2,531
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks that certain constants are fully qualified. # # This is not enabled by default because it would mark a lot of offenses # unnecessarily. # # Generally, gems should fully qualify all constants to avoid ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/deprecated_constants.rb
Ruby
mit
12,856
master
3,134
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for deprecated constants. # # It has `DeprecatedConstants` config. If there is an alternative method, you can set # alternative value as `Alternative`. And you can set the deprecated version as # `Deprecate...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/syntax.rb
Ruby
mit
12,856
master
2,457
# frozen_string_literal: true module RuboCop module Cop module Lint # Repacks Parser's diagnostics/errors # into RuboCop's offenses. class Syntax < Base LEVELS = %i[error fatal].freeze def on_other_file add_offense_from_error(processed_source.parser_error) if processe...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_access_modifier.rb
Ruby
mit
12,856
master
10,313
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/raise_exception.rb
Ruby
mit
12,856
master
3,562
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `raise` or `fail` statements which raise `Exception` or # `Exception.new`. Use `StandardError` or a specific exception class instead. # # If you have defined your own namespaced `Exception` class, it is possi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/empty_ensure.rb
Ruby
mit
12,856
master
909
# 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 #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/identity_comparison.rb
Ruby
mit
12,856
master
1,657
# 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. # #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/rand_one.rb
Ruby
mit
12,856
master
925
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `rand(1)` calls. # Such calls always return `0`. # # @example # # # bad # rand 1 # Kernel.rand(-1) # rand 1.0 # rand(-1.0) # # # good # 0 # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/deprecated_class_methods.rb
Ruby
mit
12,856
master
3,730
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for uses of the deprecated class method usages. # # @example # # # bad # File.exists?(some_path) # Dir.exists?(some_path) # iterator? # attr :name, true # attr :nam...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_defined.rb
Ruby
mit
12,856
master
1,863
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for calls to `defined?` with strings or symbols as the argument. # Such calls will always return `'expression'`, you probably meant to # check for the existence of a constant, method, or variable instead. # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_ruby2_keywords.rb
Ruby
mit
12,856
master
3,792
# frozen_string_literal: true module RuboCop module Cop module Lint # Looks for `ruby2_keywords` calls for methods that do not need it. # # `ruby2_keywords` should only be called on methods that accept an argument splat # (`\*args`) but do not explicit keyword arguments (`k:` or `k: true`...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/heredoc_method_call_position.rb
Ruby
mit
12,856
master
4,129
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_dir_glob_sort.rb
Ruby
mit
12,856
master
1,754
# frozen_string_literal: true module RuboCop module Cop module Lint # Sort globbed results by default in Ruby 3.0. # This cop checks for redundant `sort` method to `Dir.glob` and `Dir[]`. # # @safety # This cop is unsafe, in case of having a file and a directory with # ide...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/missing_super.rb
Ruby
mit
12,856
master
4,954
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for the presence of constructors and lifecycle callbacks # without calls to `super`. # # This cop does not consider `method_missing` (and `respond_to_missing?`) # because in some cases it makes sense to ove...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb
Ruby
mit
12,856
master
2,342
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for duplicate elements in `Regexp` character classes. # # @example # # # bad # r = /[xyx]/ # # # bad # r = /[0-9x0-9]/ # # # good # r = /[xy]/ # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/boolean_symbol.rb
Ruby
mit
12,856
master
1,574
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `:true` and `:false` symbols. # In most cases it would be a typo. # # @safety # Autocorrection is unsafe for this cop because code relying # on `:true` or `:false` symbols will break when thos...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/ambiguous_operator_precedence.rb
Ruby
mit
12,856
master
3,152
# frozen_string_literal: true module RuboCop module Cop module Lint # Looks for expressions containing multiple binary operators # where precedence is ambiguous due to lack of parentheses. For example, # in `1 + 2 * 3`, the multiplication will happen before the addition, but # lexically i...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_match_pattern.rb
Ruby
mit
12,856
master
2,914
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks that there are no repeated patterns used in `in` keywords. # # @example # # # bad # case x # in 'first' # do_something # in 'first' # do_something_else # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/mixed_regexp_capture_types.rb
Ruby
mit
12,856
master
928
# 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. # #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb
Ruby
mit
12,856
master
1,407
# 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 # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/refinement_import_methods.rb
Ruby
mit
12,856
master
1,544
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/unused_block_argument.rb
Ruby
mit
12,856
master
4,681
# 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 # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/data_define_override.rb
Ruby
mit
12,856
master
2,352
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks unexpected overrides of the `Data` built-in methods # via `Data.define`. # # @example # # bad # Bad = Data.define(:members, :clone, :to_s) # b = Bad.new(members: [], clone: true, to_s: 'ba...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/send_with_mixin_argument.rb
Ruby
mit
12,856
master
2,561
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `send`, `public_send`, and `__send__` methods # when using mix-in. # # `include` and `prepend` methods were private methods until Ruby 2.0, # they were mixed-in via `send` method. This cop uses Ruby 2.1...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_constant_scoping.rb
Ruby
mit
12,856
master
2,148
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for useless constant scoping. Private constants must be defined using # `private_constant`. Even if `private` access modifier is used, it is public scope despite # its appearance. # # It does not support au...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_hash_key.rb
Ruby
mit
12,856
master
834
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_setter_call.rb
Ruby
mit
12,856
master
4,787
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_elsif_condition.rb
Ruby
mit
12,856
master
902
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks that there are no repeated conditions used in if 'elsif'. # # @example # # bad # if x == 1 # do_something # elsif x == 1 # do_something_else # end # # #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_rescue_exception.rb
Ruby
mit
12,856
master
1,125
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks that there are no repeated exceptions # used in 'rescue' expressions. # # @example # # bad # begin # something # rescue FirstException # handle_exception # resc...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default.rb
Ruby
mit
12,856
master
1,723
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for the deprecated use of keyword arguments as a default in `Hash.new`. # # This usage raises a warning in Ruby 3.3 and results in an error in Ruby 3.4. # In Ruby 3.4, keyword arguments will instead be used to ch...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_times.rb
Ruby
mit
12,856
master
3,404
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for uses of `Integer#times` that will never yield # (when the integer ``<= 0``) or that will only ever yield once # (`1.times`). # # @safety # This cop is unsafe as `times` returns its receiver, whi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/self_assignment.rb
Ruby
mit
12,856
master
4,588
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for self-assignments. # # @example # # bad # foo = foo # foo, bar = foo, bar # Foo = Foo # hash['foo'] = hash['foo'] # obj.attr = obj.attr # # # good ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/literal_as_condition.rb
Ruby
mit
12,856
master
8,579
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for literals used as the conditions or as # operands in and/or expressions serving as the conditions of # if/while/until/case-when/case-in. # # NOTE: Literals in `case-in` condition where the match variable...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/unexpected_block_arity.rb
Ruby
mit
12,856
master
2,858
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for a block that is known to need more positional # block arguments than are given (by default this is configured for # `Enumerable` methods needing 2 arguments). Optional arguments are allowed, # although they d...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/ensure_return.rb
Ruby
mit
12,856
master
1,218
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for `return` from an `ensure` block. # `return` from an ensure block is a dangerous code smell as it # will take precedence over any exception being raised, # and the exception will be silently thrown away as if ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/duplicate_set_element.rb
Ruby
mit
12,856
master
2,470
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for duplicate literal, constant, or variable elements in `Set` and `SortedSet`. # # @example # # # bad # Set[:foo, :bar, :foo] # # # good # Set[:foo, :bar] # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/number_conversion.rb
Ruby
mit
12,856
master
6,278
# frozen_string_literal: true module RuboCop module Cop module Lint # Warns the usage of unsafe number conversions. Unsafe # number conversion can cause unexpected error if auto type conversion # fails. Cop prefer parsing with number class instead. # # Conversion with `Integer`, `Fl...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/literal_assignment_in_condition.rb
Ruby
mit
12,856
master
2,297
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/top_level_return_with_argument.rb
Ruby
mit
12,856
master
1,351
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for top level return with arguments. If there is a # top-level return statement with an argument, then the argument is # always ignored. This is detected automatically since Ruby 2.7. # # @example # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb
Ruby
mit
12,856
master
4,367
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb
Ruby
mit
12,856
master
7,844
# frozen_string_literal: true module RuboCop module Cop module Lint # Looks for `reduce` or `inject` blocks where the value returned (implicitly or # explicitly) does not include the accumulator. A block is considered valid as # long as at least one return value includes the accumulator. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/assignment_in_condition.rb
Ruby
mit
12,856
master
3,116
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/useless_method_definition.rb
Ruby
mit
12,856
master
1,973
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for useless method definitions, specifically: empty constructors # and methods just delegating to `super`. # # @safety # This cop is unsafe as it can register false positives for cases when an empty ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/require_relative_self_path.rb
Ruby
mit
12,856
master
1,380
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for uses a file requiring itself with `require_relative`. # # @example # # # bad # # # foo.rb # require_relative 'foo' # require_relative 'bar' # # # good ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/triple_quotes.rb
Ruby
mit
12,856
master
2,079
# 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" ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/float_comparison.rb
Ruby
mit
12,856
master
4,069
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for the presence of precise comparison of floating point numbers. # # Floating point values are inherently inaccurate, and comparing them for exact equality # is almost never the desired semantics. Comparison via...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/ambiguous_assignment.rb
Ruby
mit
12,856
master
1,309
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for mistyped shorthand assignments. # # @example # # bad # x =- y # x =+ y # x =* y # x =! y # # # good # x -= y # or x = -y # x += y # or x = +y ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/redundant_with_object.rb
Ruby
mit
12,856
master
1,999
# frozen_string_literal: true module RuboCop module Cop module Lint # Checks for redundant `with_object`. # # @example # # bad # ary.each_with_object([]) do |v| # v # end # # # good # ary.each do |v| # v # end # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/lint/utils/nil_receiver_checker.rb
Ruby
mit
12,856
master
4,442
# 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) ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/variable_force/variable_table.rb
Ruby
mit
12,856
master
3,831
# frozen_string_literal: true module RuboCop module Cop class VariableForce # A VariableTable manages the lifetime of all scopes and local variables # in a program. # This holds scopes as stack structure, provides a way to add local # variables to current scope, and find local variables b...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/variable_force/branch.rb
Ruby
mit
12,856
master
9,271
# frozen_string_literal: true module RuboCop module Cop class VariableForce # Namespace for branch classes for each control structure. module Branch def self.of(target_node, scope: nil) ([target_node] + target_node.ancestors).each do |node| return nil unless node.parent ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/variable_force/variable.rb
Ruby
mit
12,856
master
4,153
# frozen_string_literal: true module RuboCop module Cop class VariableForce # A Variable represents existence of a local variable. # This holds a variable declaration node and some states of the variable. class Variable VARIABLE_DECLARATION_TYPES = (VARIABLE_ASSIGNMENT_TYPES + ARGUMENT_...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/variable_force/scope.rb
Ruby
mit
12,856
master
2,997
# frozen_string_literal: true module RuboCop module Cop class VariableForce # A Scope represents a context of local variable visibility. # This is a place where local variables belong to. # A scope instance holds a scope node and variable entries. class Scope OUTER_SCOPE_CHILD_IND...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/variable_force/branchable.rb
Ruby
mit
12,856
master
585
# frozen_string_literal: true module RuboCop module Cop class VariableForce # Mix-in module for classes which own a node and need branch information # of the node. The user classes must implement #node and #scope. module Branchable def branch return @branch if instance_variabl...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/variable_force/reference.rb
Ruby
mit
12,856
master
1,311
# frozen_string_literal: true module RuboCop module Cop class VariableForce # This class represents each reference of a variable. class Reference include Branchable VARIABLE_REFERENCE_TYPES = ( [VARIABLE_REFERENCE_TYPE] + OPERATOR_ASSIGNMENT_TYPES + [ZERO_ARITY_SUPER_TYPE, ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/variable_force/assignment.rb
Ruby
mit
12,856
master
4,336
# frozen_string_literal: true module RuboCop module Cop class VariableForce # This class represents each assignment of a variable. class Assignment include Branchable MULTIPLE_LEFT_HAND_SIDE_TYPE = :mlhs attr_reader :node, :variable, :referenced, :references, :reassigned ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/utils/format_string.rb
Ruby
mit
12,856
master
4,207
# frozen_string_literal: true module RuboCop module Cop module Utils # Parses {Kernel#sprintf} format strings. class FormatString # Escaping the `#` in `INTERPOLATION` and `TEMPLATE_NAME` is necessary to # avoid a bug in Ruby 3.2.0 # See: https://bugs.ruby-lang.org/issues/1937...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/trailing_whitespace.rb
Ruby
mit
12,856
master
3,602
# frozen_string_literal: true module RuboCop module Cop module Layout # Looks for trailing whitespace in the source code. # # @example # # The line in this example contains spaces after the 0. # # bad # x = 0 # # # The line in this example ends directly aft...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/space_around_operators.rb
Ruby
mit
12,856
master
9,313
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks that operators have space around them, except for ** which # should or shouldn't have surrounding space depending on configuration. # It allows vertical alignment consisting of one or more whitespace # around o...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb
Ruby
mit
12,856
master
4,173
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks the indentation of the next line after a line that ends with a string # literal and a backslash. # # If `EnforcedStyle: aligned` is set, the concatenated string parts shall be aligned with the # first par...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/condition_position.rb
Ruby
mit
12,856
master
1,368
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks for conditions that are not on the same line as # if/while/until. # # @example # # # bad # if # some_condition # do_something # end # # # good ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb
Ruby
mit
12,856
master
3,724
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks for a newline after an attribute accessor or a group of them. # `alias` syntax and `alias_method`, `public`, `protected`, and `private` methods are allowed # by default. These are customizable with `AllowAliasSyntax`...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/else_alignment.rb
Ruby
mit
12,856
master
4,387
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks the alignment of else keywords. Normally they should # be aligned with an if/unless/while/until/begin/def/rescue keyword, but there # are special cases when they should follow the same rules as the # alignment ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/trailing_empty_lines.rb
Ruby
mit
12,856
master
3,534
# frozen_string_literal: true module RuboCop module Cop module Layout # Looks for trailing blank lines and a final newline in the # source code. # # @example EnforcedStyle: final_newline (default) # # `final_newline` looks for one newline at the end of files. # # # b...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/indentation_width.rb
Ruby
mit
12,856
master
15,443
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks for indentation that doesn't use the specified number of spaces. # The indentation width can be configured using the `Width` setting. The default width is 2. # The block body indentation for method chain blocks can b...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/space_in_lambda_literal.rb
Ruby
mit
12,856
master
2,277
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks for spaces between `->` and opening parameter # parenthesis (`(`) in lambda literals. # # @example EnforcedStyle: require_no_space (default) # # bad # a = -> (x, y) { x + y } # # #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/end_of_line.rb
Ruby
mit
12,856
master
3,103
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks for Windows-style line endings in the source code. # # @example EnforcedStyle: native (default) # # The `native` style means that CR+LF (Carriage Return + Line Feed) is # # enforced on Windows, and LF...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/space_before_brackets.rb
Ruby
mit
12,856
master
966
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks for space between the name of a receiver and a left # brackets. # # @example # # # bad # collection [index_or_key] # # # good # collection[index_or_key] # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/multiline_assignment_layout.rb
Ruby
mit
12,856
master
3,445
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks whether the multiline assignments have a newline # after the assignment operator. # # @example EnforcedStyle: new_line (default) # # bad # foo = if expression # 'bar' # end ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/space_before_first_arg.rb
Ruby
mit
12,856
master
2,322
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks that exactly one space is used between a method name and the # first argument for method calls without parentheses. # # Alternatively, extra spaces can be added to align the argument with # something on a...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/space_inside_reference_brackets.rb
Ruby
mit
12,856
master
4,301
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks that reference brackets have or don't have # surrounding space depending on configuration. # # @example EnforcedStyle: no_space (default) # # The `no_space` style enforces that reference brackets have ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/single_line_block_chain.rb
Ruby
mit
12,856
master
2,118
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks if method calls are chained onto single line blocks. It considers that a # line break before the dot improves the readability of the code. # # @example # # bad # example.select { |item| item.con...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/empty_lines_around_arguments.rb
Ruby
mit
12,856
master
1,991
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks if empty lines exist around the arguments # of a method invocation. # # @example # # bad # do_something( # foo # # ) # # process(bar, # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/empty_lines.rb
Ruby
mit
12,856
master
1,903
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks for two or more consecutive blank lines. # # @example # # # bad - It has two empty lines. # some_method # # one empty line # # two empty lines # some_method # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/first_parameter_indentation.rb
Ruby
mit
12,856
master
2,910
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks the indentation of the first parameter in a method # definition. Parameters after the first one are checked by # `Layout/ParameterAlignment`, not by this cop. # # For indenting the first argument of metho...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/space_after_colon.rb
Ruby
mit
12,856
master
1,329
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks for colon (`:`) not followed by some kind of space. # N.B. this cop does not handle spaces after a ternary operator, which are # instead handled by `Layout/SpaceAroundOperators`. # # @example # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/layout/closing_heredoc_indentation.rb
Ruby
mit
12,856
master
3,031
# frozen_string_literal: true module RuboCop module Cop module Layout # Checks the indentation of here document closings. # # @example # # # bad # class Foo # def bar # <<~SQL # 'Hi' # SQL # end # end # ...