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/style/redundant_min_max_by.rb
Ruby
mit
12,856
master
3,003
# frozen_string_literal: true module RuboCop module Cop module Style # Identifies places where `max_by { ... }`, `min_by { ... }`, or # `minmax_by { ... }` can be replaced by `max`, `min`, or `minmax`. # # @example # # bad # array.max_by { |x| x } # array.min_by { ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/auto_resource_cleanup.rb
Ruby
mit
12,856
master
1,355
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for cases when you could use a block # accepting version of a method that does automatic # resource cleanup. # # @example # # # bad # f = File.open('file') # # # good ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/identical_conditional_branches.rb
Ruby
mit
12,856
master
8,498
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for identical expressions at the beginning or end of # each branch of a conditional expression. Such expressions should normally # be placed outside the conditional expression - before or after it. # # NOT...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/global_std_stream.rb
Ruby
mit
12,856
master
2,291
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`. # `STDOUT/STDERR/STDIN` are constants, and while you can actually # reassign (possibly to redirect some stream) constants in Ruby, you'll get ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/trailing_comma_in_block_args.rb
Ruby
mit
12,856
master
2,837
# frozen_string_literal: true module RuboCop module Cop module Style # Checks whether trailing commas in block arguments are # required. Blocks with only one argument and a trailing comma require # that comma to be present. Blocks with more than one argument never # require a trailing com...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/zero_length_predicate.rb
Ruby
mit
12,856
master
5,430
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for numeric comparisons that can be replaced # by a predicate method, such as `receiver.length == 0`, # `receiver.length > 0`, and `receiver.length != 0`, # `receiver.length < 1` and `receiver.size == 0` that ca...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_self_assignment_branch.rb
Ruby
mit
12,856
master
2,623
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for places where conditional branch makes redundant self-assignment. # # It only detects local variable because it may replace state of instance variable, # class variable, and global variable that have state ac...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/file_write.rb
Ruby
mit
12,856
master
3,864
# frozen_string_literal: true module RuboCop module Cop module Style # Favor `File.(bin)write` convenience methods. # # NOTE: There are different method signatures between `File.write` (class method) # and `File#write` (instance method). The following case will be allowed because # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/it_assignment.rb
Ruby
mit
12,856
master
1,911
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for local variables and method parameters named `it`, # where `it` can refer to the first anonymous parameter as of Ruby 3.4. # Use a meaningful variable name instead. # # NOTE: Although Ruby allows reassi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/multiline_if_modifier.rb
Ruby
mit
12,856
master
1,576
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of if/unless modifiers with multiple-lines bodies. # # @example # # # bad # { # result: 'this should not happen' # } unless cond # # # good # { re...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/single_line_do_end_block.rb
Ruby
mit
12,856
master
2,367
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for single-line `do`...`end` block. # # In practice a single line `do`...`end` is autocorrected when `EnforcedStyle: semantic` # is configured for `Style/BlockDelimiters`. The autocorrection maintains the ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/empty_block_parameter.rb
Ruby
mit
12,856
master
1,155
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for pipes for empty block parameters. Pipes for empty # block parameters do not cause syntax errors, but they are redundant. # # @example # # bad # a do || # do_something # end ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/nil_lambda.rb
Ruby
mit
12,856
master
1,716
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for lambdas and procs that always return nil, # which can be replaced with an empty lambda or proc instead. # # @example # # bad # -> { nil } # # lambda do # next nil ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb
Ruby
mit
12,856
master
2,634
# frozen_string_literal: true # rubocop:disable Lint/RedundantCopDisableDirective module RuboCop module Cop module Style # Detects comments to enable/disable RuboCop. # This is useful if want to make sure that every RuboCop error gets fixed # and not quickly disabled with a comment. # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/class_vars.rb
Ruby
mit
12,856
master
1,797
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of class variables. Offenses # are signaled only on assignment to class variables to # reduce the number of offenses that would be reported. # # You have to be careful when setting a value for a c...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/combinable_defined.rb
Ruby
mit
12,856
master
3,395
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for multiple `defined?` calls joined by `&&` that can be combined # into a single `defined?`. # # When checking that a nested constant or chained method is defined, it is # not necessary to check each ance...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/arguments_forwarding.rb
Ruby
mit
12,856
master
21,177
# frozen_string_literal: true module RuboCop module Cop module Style # In Ruby 2.7, arguments forwarding has been added. # # This cop identifies places where `do_something(*args, &block)` # can be replaced by `do_something(...)`. # # In Ruby 3.1, anonymous block forwarding has...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/signal_exception.rb
Ruby
mit
12,856
master
5,618
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of `fail` and `raise`. # # @example EnforcedStyle: only_raise (default) # # The `only_raise` style enforces the sole use of `raise`. # # bad # begin # fail # rescue E...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/trailing_comma_in_array_literal.rb
Ruby
mit
12,856
master
2,757
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for trailing comma in array literals. # The configuration options are: # # * `consistent_comma`: Requires a comma after the last item of all non-empty, multiline array # literals. # * `comma`: Requir...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/case_like_if.rb
Ruby
mit
12,856
master
8,575
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/file_touch.rb
Ruby
mit
12,856
master
2,151
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for usage of `File.open` in append mode with empty block. # # Such a usage only creates a new file, but it doesn't update # timestamps for an existing file, which might have been the intention. # # F...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
Ruby
mit
12,856
master
3,067
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for trailing comma in hash literals. # The configuration options are: # # * `consistent_comma`: Requires a comma after the last item of all non-empty, multiline hash # literals. # * `comma`: Requires...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/when_then.rb
Ruby
mit
12,856
master
875
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for `when;` uses in `case` expressions. # # @example # # bad # case foo # when 1; 'baz' # when 2; 'bar' # end # # # good # case foo # when 1 then '...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_regexp_escape.rb
Ruby
mit
12,856
master
4,139
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for redundant escapes inside `Regexp` literals. # # @example # # bad # %r{foo\/bar} # # # good # %r{foo/bar} # # # good # /foo\/bar/ # # # good...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/negated_unless.rb
Ruby
mit
12,856
master
2,008
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of unless with a negated condition. Only unless # without else are considered. There are three different styles: # # * both # * prefix # * postfix # # @example EnforcedStyle: bot...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/numeric_literals.rb
Ruby
mit
12,856
master
3,885
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for big numeric literals without `_` between groups # of digits in them. Underscores make large numbers easier to # read by visually separating groups of digits. # # Additional allowed patterns can be adde...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_each.rb
Ruby
mit
12,856
master
3,841
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for redundant `each`. # # @safety # This cop is unsafe, as it can produce false positives if the receiver # is not an `Enumerator`. # # @example # # # bad # array.each...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/comparable_between.rb
Ruby
mit
12,856
master
2,466
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for logical comparison which can be replaced with `Comparable#between?`. # # NOTE: `Comparable#between?` is on average slightly slower than logical comparison, # although the difference generally isn't observabl...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_file_extension_in_require.rb
Ruby
mit
12,856
master
1,879
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for the presence of superfluous `.rb` extension in # the filename provided to `require` and `require_relative`. # # NOTE: If the extension is omitted, Ruby tries adding '.rb', '.so', # and so on to t...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/data_inheritance.rb
Ruby
mit
12,856
master
2,576
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/mixin_grouping.rb
Ruby
mit
12,856
master
4,012
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for grouping of mixins in `class` and `module` bodies. # By default it enforces mixins to be placed in separate declarations, # but it can be configured to enforce grouping them in one declaration. # # @ex...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/swap_values.rb
Ruby
mit
12,856
master
2,827
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of shorthand-style swapping of 2 variables. # # @safety # Autocorrection is unsafe, because the temporary variable used to # swap variables will be removed, but may be referred to elsewhere. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/reverse_find.rb
Ruby
mit
12,856
master
1,429
# frozen_string_literal: true module RuboCop module Cop module Style # Identifies places where `array.reverse.find` can be replaced by `array.rfind`. # # @safety # This cop is unsafe because it cannot be guaranteed that the receiver # is an `Array` or responds to the replacement...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/send.rb
Ruby
mit
12,856
master
623
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for the use of the send method. # # @example # # bad # Foo.send(bar) # quuz.send(fred) # # # good # Foo.__send__(bar) # quuz.public_send(fred) class Send < B...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/preferred_hash_methods.rb
Ruby
mit
12,856
master
2,114
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of methods `Hash#has_key?` and # `Hash#has_value?`, and suggests using `Hash#key?` and `Hash#value?` instead. # # It is configurable to enforce the verbose method names, by using the # `EnforcedSt...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/send_with_literal_method_name.rb
Ruby
mit
12,856
master
3,601
# frozen_string_literal: true module RuboCop module Cop module Style # Detects the use of the `public_send` method with a literal method name argument. # Since the `send` method can be used to call private methods, by default, # only the `public_send` method is detected. # # NOTE: W...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/and_or.rb
Ruby
mit
12,856
master
4,890
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/map_into_array.rb
Ruby
mit
12,856
master
8,013
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/empty_string_inside_interpolation.rb
Ruby
mit
12,856
master
3,361
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for empty strings being assigned inside string interpolation. # # Empty strings are a meaningless outcome inside of string interpolation, so we remove them. # Alternatively, when configured to do so, we prioriti...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/trailing_underscore_variable.rb
Ruby
mit
12,856
master
4,570
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/dir_empty.rb
Ruby
mit
12,856
master
1,661
# 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...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/return_nil.rb
Ruby
mit
12,856
master
2,827
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces consistency between `return nil` and `return`. # # This cop is disabled by default. Because there seems to be a perceived semantic difference # between `return` and `return nil`. The former can be seen as just...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/map_join.rb
Ruby
mit
12,856
master
3,929
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for `map { |x| x.to_s }.join` and similar calls where the # `map` is redundant because `Array#join` implicitly calls `#to_s` on # each element. # # @safety # This cop is unsafe because it cannot gu...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_return.rb
Ruby
mit
12,856
master
5,424
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for redundant `return` expressions. Ruby methods # implicitly return the value of the last evaluated expression, # so an explicit `return` at the end of a method body is unnecessary. # # @example # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/keyword_parameters_order.rb
Ruby
mit
12,856
master
2,619
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces that optional keyword parameters are placed at the # end of the parameters list. # # This improves readability, because when looking through the source, # it is expected to find required parameters at th...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/next.rb
Ruby
mit
12,856
master
7,831
# frozen_string_literal: true module RuboCop module Cop module Style # Use `next` to skip iteration instead of a condition at the end. # # @example EnforcedStyle: skip_modifier_ifs (default) # # bad # [1, 2].each do |a| # if a == 1 # puts a # end ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/method_call_without_args_parentheses.rb
Ruby
mit
12,856
master
3,951
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for unwanted parentheses in parameterless method calls. # # This cop's allowed methods can be customized with `AllowedMethods`. # By default, there are no allowed methods. # # NOTE: This cop allows t...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/array_intersect_with_single_element.rb
Ruby
mit
12,856
master
1,223
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb
Ruby
mit
12,856
master
3,445
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/variable_interpolation.rb
Ruby
mit
12,856
master
1,084
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for variable interpolation (like "#@ivar"). # # @example # # bad # "His name is #$name" # /check #$pattern/ # "Let's go to the #@store" # # # good # "His name is #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/combinable_loops.rb
Ruby
mit
12,856
master
4,066
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for places where multiple consecutive loops over the same data # can be combined into a single loop. It is very likely that combining them # will make the code more efficient and more concise. # # NOTE: Au...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_initialize.rb
Ruby
mit
12,856
master
4,785
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for `initialize` methods that are redundant. # # An initializer is redundant if it does not do anything, or if it only # calls `super` with the same arguments given to it. If the initializer takes # an arg...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/min_max.rb
Ruby
mit
12,856
master
1,681
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for potential uses of `Enumerable#minmax`. # # @example # # # bad # bar = [foo.min, foo.max] # return foo.min, foo.max # # # good # bar = foo.minmax # return...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/ternary_parentheses.rb
Ruby
mit
12,856
master
7,984
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for the presence of parentheses around ternary # conditions. It is configurable to enforce inclusion or omission of # parentheses using `EnforcedStyle`. Omission is only enforced when # removing the parentheses ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/static_class.rb
Ruby
mit
12,856
master
3,551
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for places where classes with only class methods can be # replaced with a module. Classes should be used only when it makes sense to create # instances out of them. # # @safety # This cop is unsafe...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_string_escape.rb
Ruby
mit
12,856
master
5,517
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for redundant escapes in string literals. # # @example # # bad - no need to escape # without following {/$/@ # "\#foo" # # # bad - no need to escape single quotes inside double quoted str...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/unless_else.rb
Ruby
mit
12,856
master
1,396
# 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 # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/safe_navigation.rb
Ruby
mit
12,856
master
16,003
# frozen_string_literal: true module RuboCop module Cop module Style # Transforms usages of a method call safeguarded by a non `nil` # check for the variable whose method is being called to # safe navigation (`&.`). If there is a method chain, all of the methods # in the chain need to be ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb
Ruby
mit
12,856
master
1,629
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for redundant heredoc delimiter quotes. # # @example # # # bad # do_something(<<~'EOS') # no string interpolation style text # EOS # # # good # do_somethin...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_line_continuation.rb
Ruby
mit
12,856
master
8,420
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for redundant line continuation. # # This cop marks a line continuation as redundant if removing the backslash # does not result in a syntax error. # However, a backslash at the end of a comment or #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/if_unless_modifier.rb
Ruby
mit
12,856
master
12,408
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for `if` and `unless` statements that would fit on one line if # written as modifier `if`/`unless`. The cop also checks for modifier # `if`/`unless` lines that exceed the maximum line length. # # The maxim...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/predicate_with_kind.rb
Ruby
mit
12,856
master
2,996
# frozen_string_literal: true module RuboCop module Cop module Style # Looks for uses of `any?`, `all?`, `none?`, or `one?` with a block # containing only an `is_a?`, `kind_of?`, or `instance_of?` check, and # suggests using the predicate method with the class argument directly. # #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/parentheses_around_condition.rb
Ruby
mit
12,856
master
3,745
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for the presence of superfluous parentheses around the # condition of if/unless/while/until. # # `AllowSafeAssignment` option for safe assignment. # By safe assignment we mean putting parentheses around ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/double_negation.rb
Ruby
mit
12,856
master
4,720
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of double negation (`!!`) to convert something to a boolean value. # # When using `EnforcedStyle: allowed_in_returns`, allow double negation in contexts # that use boolean as a return value. When using ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/inline_comment.rb
Ruby
mit
12,856
master
960
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for trailing inline comments. Inline comments can # make lines harder to read, especially when they are long. # Placing comments on their own line above the code they # describe is often clearer. # #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/partition_instead_of_double_select.rb
Ruby
mit
12,856
master
9,517
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for consecutive calls to `select`/`filter`/`find_all` and `reject` # on the same receiver with the same block body, where `partition` could be # used instead. Also detects two `select` or two `reject` calls where one ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/bitwise_predicate.rb
Ruby
mit
12,856
master
2,993
# 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 ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/empty_heredoc.rb
Ruby
mit
12,856
master
1,301
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for using empty heredoc to reduce redundancy. # # @example # # # bad # <<~EOS # EOS # # <<-EOS # EOS # # <<EOS # EOS # # # good ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/nested_modifier.rb
Ruby
mit
12,856
master
2,891
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for nested use of if, unless, while and until in their # modifier form. # # @example # # # bad # something if a if b # # # good # something if b && a class Neste...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_array_flatten.rb
Ruby
mit
12,856
master
1,384
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for redundant calls of `Array#flatten`. # # `Array#join` joins nested arrays recursively, so flattening an array # beforehand is redundant. # # @safety # Cop is unsafe because the receiver of...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/negated_if.rb
Ruby
mit
12,856
master
2,085
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of if with a negated condition. Only ifs # without else are considered. There are three different styles: # # * both # * prefix # * postfix # # @example EnforcedStyle: both (defa...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/not.rb
Ruby
mit
12,856
master
2,161
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of the keyword `not` instead of `!`. # The `not` keyword has lower precedence than `!`, which can # lead to surprising behavior and often requires parentheses. # # @example # # # bad...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/infinite_loop.rb
Ruby
mit
12,856
master
3,936
# frozen_string_literal: true module RuboCop module Cop module Style # Use `Kernel#loop` for infinite loops. # # @safety # This cop is unsafe as the rule should not necessarily apply if the loop # body might raise a `StopIteration` exception; contrary to other infinite # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/exponential_notation.rb
Ruby
mit
12,856
master
3,060
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces consistency when using exponential notation # for numbers in the code (eg 1.2e4). Different styles are supported: # # * `scientific` which enforces a mantissa between 1 (inclusive) and 10 (exclusive). # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/multiline_when_then.rb
Ruby
mit
12,856
master
1,415
# frozen_string_literal: true module RuboCop module Cop module Style # Checks uses of the `then` keyword # in multi-line when statements. # # @example # # bad # case foo # when bar then # end # # # good # case foo # when bar ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb
Ruby
mit
12,856
master
1,993
# frozen_string_literal: true module RuboCop module Cop module Style class MethodCallWithArgsParentheses # Style require_parentheses module RequireParentheses REQUIRE_MSG = 'Use parentheses for method calls with arguments.' private_constant :REQUIRE_MSG privat...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb
Ruby
mit
12,856
master
9,435
# frozen_string_literal: true module RuboCop module Cop module Style class MethodCallWithArgsParentheses # Style omit_parentheses # rubocop:disable Metrics/ModuleLength, Metrics/CyclomaticComplexity module OmitParentheses include RangeHelp TRAILING_WHITESPACE_RE...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/bisected_attr_accessor/macro.rb
Ruby
mit
12,856
master
1,381
# frozen_string_literal: true module RuboCop module Cop module Style class BisectedAttrAccessor # Representation of an `attr_reader`, `attr_writer` or `attr` macro # for use by `Style/BisectedAttrAccessor`. # @api private class Macro include VisibilityHelp ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/plugin.rb
Ruby
mit
12,856
master
906
# frozen_string_literal: true require 'lint_roller' module RuboCop module InternalAffairs # A Plugin for `InternalAffairs` department, which has internal cops. class Plugin < LintRoller::Plugin def about LintRoller::About.new( name: 'rubocop-internal_affairs', version: Vers...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb
Ruby
mit
12,856
master
2,834
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for cops that define `on_send` without define `on_csend`. # # Although in some cases it can be predetermined that safe navigation # will never be used with the code checked by a specific cop, in genera...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/empty_line_between_expect_offense_and_correction.rb
Ruby
mit
12,856
master
2,086
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks whether `expect_offense` and correction expectation methods # (i.e. `expect_correction` and `expect_no_corrections`) are separated by empty line. # # @example # # bad # it 'registers an...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb
Ruby
mit
12,856
master
1,482
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for useless `RESTRICT_ON_SEND`. # # @example # # bad # class FooCop # RESTRICT_ON_SEND = %i[bad_method].freeze # end # # # good # class FooCop # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/redundant_message_argument.rb
Ruby
mit
12,856
master
1,591
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for redundant message arguments to `#add_offense`. This method # will automatically use `#message` or `MSG` (in that order of priority) # if they are defined. # # @example # # # bad...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/redundant_location_argument.rb
Ruby
mit
12,856
master
1,430
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for redundant `location` argument to `#add_offense`. `location` # argument has a default value of `:expression` and this method will # automatically use it. # # @example # # # bad ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/single_line_comparison.rb
Ruby
mit
12,856
master
1,778
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Enforces the use of `node.single_line?` instead of # comparing `first_line` and `last_line` for equality. # # @example # # bad # node.loc.first_line == node.loc.last_line # # # b...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/node_destructuring.rb
Ruby
mit
12,856
master
1,242
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks that node destructuring is using the node extensions. # # @example Using splat expansion # # # bad # _receiver, method_name, _arguments = send_node.children # # # bad ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/style_detected_api_use.rb
Ruby
mit
12,856
master
5,019
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for correct use of the style_detected API provided by # `ConfigurableEnforcedStyle`. If `correct_style_detected` is used # then `opposite_style_detected`, `unexpected_style_detected`, # `ambiguous_styl...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/node_type_group.rb
Ruby
mit
12,856
master
2,878
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks that node types are checked against their group when all types of a # group are checked. # # @example # # bad # node.type?(:irange, :erange) # # # good # node.rang...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb
Ruby
mit
12,856
master
2,248
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks that `let` is `RuboCop::Config.new` with no arguments. # # @example # # bad # RSpec.describe RuboCop::Cop::Department::Foo, :config do # let(:config) { RuboCop::Config.new } #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
Ruby
mit
12,856
master
865
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for redundant arguments of `RuboCop::RSpec::ExpectOffense`'s methods. # # @example # # # bad # expect_no_offenses('code', keyword: keyword) # # # good # expect_no_...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/itblock_handler.rb
Ruby
mit
12,856
master
1,840
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for missing `itblock` handlers. The blocks with the `it` # parameter introduced in Ruby 3.4 are parsed with a node type of # `itblock` instead of block. Cops that define `block` handlers # need to defi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/lambda_or_proc.rb
Ruby
mit
12,856
master
1,276
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Enforces the use of `node.lambda_or_proc?` instead of `node.lambda? || node.proc?`. # # @example # # bad # node.lambda? || node.proc? # node.proc? || node.lambda? # # # good ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/cop_enabled.rb
Ruby
mit
12,856
master
2,509
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Use `config.cop_enabled?('Department/CopName')` instead of # traversing the config hash. # # @example # # `for_cop(...)['Enabled'] # # # bad # config.for_cop('Department/CopName'...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/undefined_config.rb
Ruby
mit
12,856
master
3,028
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Looks for references to a cop configuration key that isn't defined in config/default.yml. class UndefinedConfig < Base # `FileFinder` is a private API not intended to be used by cops, # but it's fine for ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/method_name_end_with.rb
Ruby
mit
12,856
master
2,305
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks potentially usage of method identifier predicates # defined in rubocop-ast instead of `method_name.end_with?`. # # @example # # bad # node.method_name.to_s.end_with?('=') # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/example_description.rb
Ruby
mit
12,856
master
4,028
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks that RSpec examples that use `expects_offense` # or `expects_no_offenses` do not have conflicting # descriptions. # # @example # # bad # it 'does not register an offense' do ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/offense_location_keyword.rb
Ruby
mit
12,856
master
1,728
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for potential uses of the location keywords which can be used as # shortcut arguments to `#add_offense`. # # @example # # # bad # add_offense(node, location: node.loc.selector) ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/numblock_handler.rb
Ruby
mit
12,856
master
1,855
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for missing `numblock` handlers. The blocks with numbered # arguments introduced in Ruby 2.7 are parsed with a node type of # `numblock` instead of block. Cops that define `block` handlers # need to de...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb
Ruby
mit
12,856
master
1,190
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Checks for redundant `:config` parameter in the `context` arguments. # # @example # # # bad # context 'foo', :config do # end # # # good # context 'foo' do ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb
Ruby
mit
12,856
master
1,807
# frozen_string_literal: true module RuboCop module Cop module InternalAffairs # Enforces the use of `same_line?` instead of location line comparison for equality. # # @example # # bad # node.loc.line == node.parent.loc.line # # # bad # node.loc.first_line ...