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/exact_regexp_match.rb
Ruby
mit
12,856
master
1,813
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for exact regexp match inside `Regexp` literals. # # @example # # # bad # string =~ /\Astring\z/ # string === /\Astring\z/ # string.match(/\Astring\z/) # string.match?(/\A...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/document_dynamic_eval_definition.rb
Ruby
mit
12,856
master
5,910
# frozen_string_literal: true module RuboCop module Cop module Style # When using `class_eval` (or other `eval`) with string interpolation, # add a comment block showing its appearance if interpolated (a practice used in Rails code). # # @example # # from activesupport/lib/active_...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_capital_w.rb
Ruby
mit
12,856
master
1,099
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for usage of the %W() syntax when %w() would do. # # @example # # bad # %W(cat dog pig) # %W[door wall floor] # # # good # %w/swim run bike/ # %w[shirt pants shoes...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/ascii_comments.rb
Ruby
mit
12,856
master
1,775
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for non-ascii (non-English) characters # in comments. Non-ascii characters can cause issues with # portability and encoding across different environments # and editors. You could set an array of allowed non-asci...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_regexp_argument.rb
Ruby
mit
12,856
master
3,875
# frozen_string_literal: true module RuboCop module Cop module Style # Identifies places where argument can be replaced from # a deterministic regexp to a string. # # @example # # bad # 'foo'.byteindex(/f/) # 'foo'.byterindex(/f/) # 'foo'.gsub(/f/, 'x') ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/command_literal.rb
Ruby
mit
12,856
master
4,809
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces using `` or %x around command literals. # # @example EnforcedStyle: backticks (default) # # bad # folders = %x(find . -type d).split # # # bad # %x( # ln -s foo.exampl...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/nested_parenthesized_calls.rb
Ruby
mit
12,856
master
2,416
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for unparenthesized method calls in the argument list # of a parenthesized method call. # `be`, `be_a`, `be_an`, `be_between`, `be_falsey`, `be_kind_of`, `be_instance_of`, # `be_truthy`, `be_within`, `eq`, `eql`...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/object_then.rb
Ruby
mit
12,856
master
1,951
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of consistent method names # `Object#yield_self` or `Object#then`. # # @example EnforcedStyle: then (default) # # # bad # obj.yield_self { |x| x.do_something } # # #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/rescue_modifier.rb
Ruby
mit
12,856
master
3,466
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of `rescue` in its modifier form is added for following # reasons: # # * The syntax of modifier form `rescue` can be misleading because it # might lead us to believe that `rescue` handles the gi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/hash_transform_values.rb
Ruby
mit
12,856
master
3,399
# frozen_string_literal: true module RuboCop module Cop module Style # Looks for uses of `+_.each_with_object({}) {...}+`, # `+_.map {...}.to_h+`, and `+Hash[_.map {...}]+` that are actually just # transforming the values of a hash, and tries to use a simpler & faster # call to `transform...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/ip_addresses.rb
Ruby
mit
12,856
master
2,276
# frozen_string_literal: true require 'resolv' module RuboCop module Cop module Style # Checks for hardcoded IP addresses, which can make code # brittle. IP addresses are likely to need to be changed when code # is deployed to a different server or environment, which may break # a deploy...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/one_line_conditional.rb
Ruby
mit
12,856
master
4,591
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of `if/then/else/end` constructs on a single line. # A ternary operator (`?:`) or multi-line `if` is more readable. # `AlwaysCorrectToMultiline` config option can be set to `true` to autocorrect all offenses ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/select_by_regexp.rb
Ruby
mit
12,856
master
7,975
# frozen_string_literal: true module RuboCop module Cop module Style # Looks for places where a subset of an Enumerable (array, # range, set, etc.; see note below) is calculated based on a `Regexp` # match, and suggests `grep` or `grep_v` instead. # # NOTE: Hashes do not behave as y...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/conditional_assignment.rb
Ruby
mit
12,856
master
21,392
# frozen_string_literal: true module RuboCop module Cop module Style # Helper module to provide common methods to classes needed for the # ConditionalAssignment Cop. module ConditionalAssignmentHelper extend NodePattern::Macros EQUAL = '=' END_ALIGNMENT = 'Layout/EndAli...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/super_with_args_parentheses.rb
Ruby
mit
12,856
master
885
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the presence of parentheses in `super` containing arguments. # # `super` is a keyword and is provided as a distinct cop from those designed for method call. # # @example # # # bad # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/mixin_usage.rb
Ruby
mit
12,856
master
1,742
# frozen_string_literal: true module RuboCop module Cop module Style # Checks that `include`, `extend` and `prepend` statements appear # inside classes and modules, not at the top level, so as to not affect # the behavior of `Object`. # # @example # # bad # include M...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/line_end_concatenation.rb
Ruby
mit
12,856
master
4,607
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for string literal concatenation at # the end of a line. # # @safety # This cop is unsafe because it cannot be guaranteed that the # receiver is a string, in which case replacing `<<` with `\` ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/class_equality_comparison.rb
Ruby
mit
12,856
master
4,310
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of `Object#instance_of?` instead of class comparison # for equality. # `==`, `equal?`, and `eql?` custom method definitions are allowed by default. # These are customizable with `AllowedMethods` option...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/array_coercion.rb
Ruby
mit
12,856
master
2,682
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of `Array()` instead of explicit `Array` check or `[*var]`. # # The cop is disabled by default due to safety concerns. # # @safety # This cop is unsafe because a false positive may occur ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/yoda_expression.rb
Ruby
mit
12,856
master
2,497
# frozen_string_literal: true module RuboCop module Cop module Style # Forbids Yoda expressions, i.e. binary operations (using `*`, `+`, `&`, `|`, # and `^` operators) where the order of expression is reversed, eg. `1 + x`. # This cop complements `Style/YodaCondition` cop, which has a similar p...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/fetch_env_var.rb
Ruby
mit
12,856
master
4,977
# frozen_string_literal: true module RuboCop module Cop module Style # Suggests `ENV.fetch` for the replacement of `ENV[]`. # `ENV[]` silently fails and returns `nil` when the environment variable is unset, # which may cause unexpected behaviors when the developer forgets to set it. # On ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/self_assignment.rb
Ruby
mit
12,856
master
2,612
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use the shorthand for self-assignment. # # @example # # # bad # x = x + 1 # # # good # x += 1 class SelfAssignment < Base extend AutoCorrector M...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_sort_by.rb
Ruby
mit
12,856
master
2,264
# frozen_string_literal: true module RuboCop module Cop module Style # Identifies places where `sort_by { ... }` can be replaced by # `sort`. # # @example # # bad # array.sort_by { |x| x } # array.sort_by do |var| # var # end # # # g...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/negative_array_index.rb
Ruby
mit
12,856
master
7,639
# frozen_string_literal: true module RuboCop module Cop module Style # Identifies usages of `arr[arr.length - n]`, `arr[arr.size - n]`, or # `arr[arr.count - n]` and suggests to change them to use `arr[-n]` instead. # Also handles range patterns like `arr[0..(arr.length - n)]`. # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/stabby_lambda_parentheses.rb
Ruby
mit
12,856
master
2,268
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for parentheses around stabby lambda arguments. # There are two different styles. Defaults to `require_parentheses`. # # @example EnforcedStyle: require_parentheses (default) # # bad # ->a,b,c { ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/global_vars.rb
Ruby
mit
12,856
master
2,355
# frozen_string_literal: true module RuboCop module Cop module Style # Looks for uses of global variables. Global variables introduce # shared mutable state that makes code harder to test, debug, # and reason about, since any part of the program can read or modify them. # # It does ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/stderr_puts.rb
Ruby
mit
12,856
master
1,481
# frozen_string_literal: true module RuboCop module Cop module Style # Identifies places where `$stderr.puts` can be replaced by # `warn`. The latter has the advantage of easily being disabled by, # the `-W0` interpreter flag or setting `$VERBOSE` to `nil`. # # @example # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/documentation_method.rb
Ruby
mit
12,856
master
3,465
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for missing documentation comment for public methods. # It can optionally be configured to also require documentation for # non-public methods. # # NOTE: This cop allows `initialize` method because `initia...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/nil_comparison.rb
Ruby
mit
12,856
master
2,264
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for comparison of something with nil using `==` and # `nil?`. Enforcing a consistent style (either the `nil?` # predicate or `==` comparison) improves readability. # # @example EnforcedStyle: predicate (de...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/string_methods.rb
Ruby
mit
12,856
master
931
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of consistent method names # from the `String` class. # # @example # # bad # 'name'.intern # 'var'.unfavored_method # # # good # 'name'.to_sym # 'v...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/rescue_standard_error.rb
Ruby
mit
12,856
master
3,274
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for rescuing `StandardError`. There are two supported # styles `implicit` and `explicit`. This cop will not register an offense # if any error other than `StandardError` is specified. # # @example Enforced...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/negated_if_else_condition.rb
Ruby
mit
12,856
master
4,018
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of `if-else` and ternary operators with a negated condition # which can be simplified by inverting condition and swapping branches. # # @example # # bad # if !x # do_something ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/accessor_grouping.rb
Ruby
mit
12,856
master
6,943
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for grouping of accessors in `class` and `module` bodies. # By default it enforces accessors to be placed in grouped # declarations, reducing boilerplate. It can also be configured # to enforce separating them i...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/multiline_block_chain.rb
Ruby
mit
12,856
master
1,242
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for chaining of a block after another block that spans # multiple lines. # # @example # # # bad # Thread.list.select do |t| # t.alive? # end.map do |t| # t.objec...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/collection_querying.rb
Ruby
mit
12,856
master
4,732
# frozen_string_literal: true module RuboCop module Cop module Style # Prefer `Enumerable` predicate methods over expressions with `count`. # # The cop checks calls to `count` without arguments, or with a # block. It doesn't register offenses for `count` with a positional # argument...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/string_literals_in_interpolation.rb
Ruby
mit
12,856
master
2,435
# frozen_string_literal: true module RuboCop module Cop module Style # Checks that quotes inside string, symbol, and regexp interpolations # match the configured preference. # # @example EnforcedStyle: single_quotes (default) # # bad # string = "Tests #{success ? "PASS" : ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_condition.rb
Ruby
mit
12,856
master
11,021
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for unnecessary conditional expressions. # # NOTE: Since the intention of the comment cannot be automatically determined, # autocorrection is not applied when a comment is used, as shown below: # # [...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/map_to_hash.rb
Ruby
mit
12,856
master
2,821
# frozen_string_literal: true module RuboCop module Cop module Style # Looks for uses of `map.to_h` or `collect.to_h` that could be # written with just `to_h` in Ruby >= 2.6. # # NOTE: `Style/HashTransformKeys` and `Style/HashTransformValues` will # also change this pattern if only ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/missing_else.rb
Ruby
mit
12,856
master
4,541
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for `if` expressions that do not have an `else` branch. # # NOTE: Pattern matching is allowed to have no `else` branch because unlike `if` and `case`, # it raises `NoMatchingPatternError` if the pattern doesn't ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/explicit_block_argument.rb
Ruby
mit
12,856
master
5,393
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of explicit block argument to avoid writing # block literal that just passes its arguments to another block. # # NOTE: This cop only registers an offense if the block args match the # yield args ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/map_compact_with_conditional_block.rb
Ruby
mit
12,856
master
4,787
# frozen_string_literal: true module RuboCop module Cop module Style # Prefer `select` or `reject` over `map { ... }.compact`. # This cop also handles `filter_map { ... }`, similar to `map { ... }.compact`. # # @example # # # bad # array.map { |e| some_condition? ? e...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/commented_keyword.rb
Ruby
mit
12,856
master
3,521
# frozen_string_literal: true require_relative '../../directive_comment' module RuboCop module Cop module Style # Checks for comments put on the same line as some keywords. # These keywords are: `class`, `module`, `def`, `begin`, `end`. # # Note that some comments # (`:nodoc:`, `:y...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_format.rb
Ruby
mit
12,856
master
9,560
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for calls to `Kernel#format` or `Kernel#sprintf` that are redundant. # # Calling `format` with only a single string or constant argument is redundant, # as it can be replaced by the string or constant itself. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_percent_q.rb
Ruby
mit
12,856
master
3,342
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for usage of the %q/%Q syntax when '' or "" would do. # # @example # # # bad # name = %q(Bruce Wayne) # time = %q(8 o'clock) # question = %q("What did you say?") # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/percent_literal_delimiters.rb
Ruby
mit
12,856
master
3,401
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the consistent usage of `%`-literal delimiters. # Using consistent delimiters across the codebase reduces # cognitive load when reading `%`-literals. # # Specify the 'default' key to set all preferred de...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/hash_conversion.rb
Ruby
mit
12,856
master
5,191
# frozen_string_literal: true module RuboCop module Cop module Style # Checks the usage of pre-2.1 `Hash[args]` method of converting enumerables and # sequences of values to hashes. # # Correction code from splat argument (`Hash[*ary]`) is not simply determined. For example, # `Hash...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/multiline_memoization.rb
Ruby
mit
12,856
master
2,358
# frozen_string_literal: true module RuboCop module Cop module Style # Checks expressions wrapping styles for multiline memoization. # # @example EnforcedStyle: keyword (default) # # bad # foo ||= ( # bar # baz # ) # # # good # f...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/random_with_offset.rb
Ruby
mit
12,856
master
4,768
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for the use of randomly generated numbers, # added/subtracted with integer literals, as well as those with # Integer#succ and Integer#pred methods. Prefer using ranges instead, # as it clearly states the intenti...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/class_methods_definitions.rb
Ruby
mit
12,856
master
4,105
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces using `def self.method_name` or `class << self` to define class methods. # # @example EnforcedStyle: def_self (default) # # bad # class SomeClass # class << self # attr_accessor...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/colon_method_call.rb
Ruby
mit
12,856
master
1,363
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for methods invoked via the `::` operator instead # of the `.` operator (like `FileUtils::rmdir` instead of # `FileUtils.rmdir`). The `::` operator is conventionally used to # reference constants, so using it fo...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/guard_clause.rb
Ruby
mit
12,856
master
9,321
# frozen_string_literal: true module RuboCop module Cop module Style # Use a guard clause instead of wrapping the code inside a conditional # expression # # A condition with an `elsif` or `else` branch is allowed unless # one of `return`, `break`, `next`, `raise`, or `fail` is used ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/hash_as_last_array_item.rb
Ruby
mit
12,856
master
3,263
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for presence or absence of braces around hash literal as a last # array item depending on configuration. # # NOTE: This cop will ignore arrays where multiple items are all hashes, # regardless of `Enforced...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/select_by_kind.rb
Ruby
mit
12,856
master
5,586
# frozen_string_literal: true module RuboCop module Cop module Style # Looks for places where a subset of an Enumerable (array, # range, set, etc.; see note below) is calculated based on a class type # check, and suggests `grep` or `grep_v` instead. # # NOTE: Hashes do not behave as...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/empty_case_condition.rb
Ruby
mit
12,856
master
3,631
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for case statements with an empty condition. # # @example # # # bad: # case # when x == 0 # puts 'x is 0' # when y == 0 # puts 'y is 0' # else # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/magic_comment_format.rb
Ruby
mit
12,856
master
9,036
# frozen_string_literal: true module RuboCop module Cop module Style # Ensures magic comments are written consistently throughout your code base. # Looks for discrepancies in separators (`-` vs `_`) and capitalization for # both magic comment directives and values. # # Required capi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/case_equality.rb
Ruby
mit
12,856
master
3,376
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of the case equality operator (`===`). # The `===` operator has different behavior depending on the # receiver and its use outside of `case`/`when` is confusing. # Prefer more explicit alternatives like...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/multiline_ternary_operator.rb
Ruby
mit
12,856
master
2,848
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for multi-line ternary op expressions. # # NOTE: `return if ... else ... end` is syntax error. If `return` is used before # multiline ternary operator expression, it will be autocorrected to single-line # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/method_call_with_args_parentheses.rb
Ruby
mit
12,856
master
8,502
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the presence (default) or absence of parentheses in # method calls containing arguments. # # In the default style (require_parentheses), macro methods are allowed. # Additional methods can be added to th...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/inverse_methods.rb
Ruby
mit
12,856
master
6,980
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for usages of not (`not` or `!`) called on a method # when an inverse of that method can be used instead. # # Methods that can be inverted by a not (`not` or `!`) should be defined # in `InverseMethods`. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/documentation.rb
Ruby
mit
12,856
master
5,863
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for missing top-level documentation of classes and # modules. Classes with no body are exempt from the check and so are # namespace modules - modules that have nothing in their bodies except # classes, other mod...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/access_modifier_declarations.rb
Ruby
mit
12,856
master
11,899
# frozen_string_literal: true module RuboCop module Cop module Style # Access modifiers should be declared to apply to a group of methods # or inline before each method, depending on configuration. # EnforcedStyle config covers only method definitions. # Applications of visibility methods...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/multiline_method_signature.rb
Ruby
mit
12,856
master
2,766
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for method signatures that span multiple lines. # # @example # # # good # # def foo(bar, baz) # end # # # bad # # def foo(bar, # baz) ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/trailing_body_on_method_definition.rb
Ruby
mit
12,856
master
1,349
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for trailing code after the method definition. # # NOTE: It always accepts endless method definitions that are basically on the same line. # # @example # # bad # def some_method; do_stuff ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/one_class_per_file.rb
Ruby
mit
12,856
master
2,816
# frozen_string_literal: true module RuboCop module Cop module Style # Checks that each source file defines at most one top-level class or module. # # Keeping one class or module per file makes it easier to find and navigate # code, and follows the convention used by most Ruby projects. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/attr.rb
Ruby
mit
12,856
master
2,520
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of `Module#attr`. The `attr` method has confusing # behavior: with a single argument it creates a reader (like `attr_reader`), # but with a second boolean argument it creates an accessor (deprecated in ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_self.rb
Ruby
mit
12,856
master
6,794
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for redundant uses of `self`. # # The usage of `self` is only needed when: # # * Sending a message to same object with zero arguments in # presence of a method name clash with an argument or a loca...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/bare_percent_literals.rb
Ruby
mit
12,856
master
1,999
# frozen_string_literal: true module RuboCop module Cop module Style # Checks if usage of `%()` or `%Q()` matches configuration. # Consistent use of one style makes the codebase easier # to read. # # @example EnforcedStyle: bare_percent (default) # # bad # %Q(He said...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/implicit_runtime_error.rb
Ruby
mit
12,856
master
1,114
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for `raise` or `fail` statements which do not specify an # explicit exception class. (This raises a `RuntimeError`. Some projects # might prefer to use exception classes which more precisely identify the # natur...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/select_by_range.rb
Ruby
mit
12,856
master
7,970
# frozen_string_literal: true module RuboCop module Cop module Style # Looks for places where a subset of an Enumerable (array, # range, set, etc.; see note below) is calculated based on a range # check, and suggests `grep` or `grep_v` instead. # # NOTE: Hashes do not behave as you ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/collection_methods.rb
Ruby
mit
12,856
master
2,571
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of consistent method names # from the Enumerable module. # # You can customize the mapping from undesired method to desired method. # # e.g. to use `detect` over `find`: # # S...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/option_hash.rb
Ruby
mit
12,856
master
1,317
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for options hashes and discourages them if the # current Ruby version supports keyword arguments. # # @example # # # bad # def fry(options = {}) # temperature = options.fetch(:tem...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/eval_with_location.rb
Ruby
mit
12,856
master
7,425
# frozen_string_literal: true module RuboCop module Cop module Style # Ensures that eval methods (`eval`, `instance_eval`, `class_eval` # and `module_eval`) are given filename and line number values (`+__FILE__+` # and `+__LINE__+`). This data is used to ensure that any errors raised # wi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/trailing_comma_in_arguments.rb
Ruby
mit
12,856
master
3,427
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for trailing comma in argument lists. # The supported styles are: # # * `consistent_comma`: Requires a comma after the last argument, # for all parenthesized multi-line method calls with arguments. #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_constant_base.rb
Ruby
mit
12,856
master
2,274
# frozen_string_literal: true module RuboCop module Cop module Style # Avoid redundant `::` prefix on constant. # # How Ruby searches constant is a bit complicated, and it can often be difficult to # understand from the code whether the `::` is intended or not. Where `Module.nesting` ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/bisected_attr_accessor.rb
Ruby
mit
12,856
master
3,898
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for places where `attr_reader` and `attr_writer` # for the same method can be combined into single `attr_accessor`. # # @example # # bad # class Foo # attr_reader :bar # attr_...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_self_assignment.rb
Ruby
mit
12,856
master
3,324
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for places where redundant assignments are made for in place # modification methods. # # @safety # This cop is unsafe, because it can produce false positives for # user defined methods having one...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/format_string.rb
Ruby
mit
12,856
master
4,818
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of a single string formatting utility. # Valid options include `Kernel#format`, `Kernel#sprintf`, and `String#%`. # # The detection of `String#%` cannot be implemented in a reliable # manner for ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/empty_lambda_parameter.rb
Ruby
mit
12,856
master
1,162
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for parentheses for empty lambda parameters. Parentheses # for empty lambda parameters do not cause syntax errors, but they are # redundant. # # @example # # bad # -> () { do_something } ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/unless_logical_operators.rb
Ruby
mit
12,856
master
3,597
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for the use of logical operators in an `unless` condition. # It discourages such code, as the condition becomes more difficult # to read and understand. # # This cop supports two styles: # # - ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/endless_method.rb
Ruby
mit
12,856
master
7,136
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for endless methods. # # It can enforce endless method definitions whenever possible or with single line methods. # It can also disallow multiline endless method definitions or all endless definitions. # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb
Ruby
mit
12,856
master
1,656
# frozen_string_literal: true module RuboCop module Cop module Style # Before Ruby 3.0, interpolated strings followed the frozen string literal # magic comment which sometimes made it necessary to explicitly unfreeze them. # Ruby 3.0 changed interpolated strings to always be unfrozen which make...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/hash_lookup_method.rb
Ruby
mit
12,856
master
3,379
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces the use of either `Hash#[]` or `Hash#fetch` for hash lookup. # # This cop can be configured to prefer either bracket-style (`[]`) # or fetch-style lookup. It is disabled by default. # # When enforc...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/string_hash_keys.rb
Ruby
mit
12,856
master
1,815
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for the use of strings as keys in hashes. The use of # symbols is preferred instead. # # @safety # This cop is unsafe because while symbols are preferred for hash keys, # there are instances when...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/character_literal.rb
Ruby
mit
12,856
master
1,736
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of the character literal ?x. # Starting with Ruby 1.9 character literals are # essentially one-character strings, so this syntax # is mostly redundant at this point. # # ? character literal ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/while_until_modifier.rb
Ruby
mit
12,856
master
1,642
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for while and until statements that would fit on one line # if written as a modifier while/until. The maximum line length is # configured in the `Layout/LineLength` cop. # # @example # # bad ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/quoted_symbols.rb
Ruby
mit
12,856
master
3,892
# frozen_string_literal: true module RuboCop module Cop module Style # Checks if the quotes used for quoted symbols match the configured defaults. # By default uses the same configuration as `Style/StringLiterals`; if that # cop is not enabled, the default `EnforcedStyle` is `single_quotes`. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/file_empty.rb
Ruby
mit
12,856
master
2,627
# frozen_string_literal: true module RuboCop module Cop module Style # Prefer to use `File.empty?('path/to/file')` when checking if a file is empty. # # @safety # This cop is unsafe, because `File.size`, `File.read`, and `File.binread` # raise `ENOENT` exception when there is no...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/word_array.rb
Ruby
mit
12,856
master
4,336
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for array literals made up of word-like # strings, that are not using the %w() syntax. # # Alternatively, it can check for uses of the %w() syntax, in projects # which do not want to include that syntax. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/module_member_existence_check.rb
Ruby
mit
12,856
master
3,938
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for usage of `Module` methods returning arrays that can be replaced # with equivalent predicates. # # Calling a method returning an array then checking if an element is inside # it is much slower than usin...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/block_comments.rb
Ruby
mit
12,856
master
1,747
# frozen_string_literal: true module RuboCop module Cop module Style # Looks for uses of block comments (=begin...=end). # # @example # # bad # =begin # Multiple lines # of comments... # =end # # # good # # Multiple lines # #...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_exception.rb
Ruby
mit
12,856
master
2,459
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for `RuntimeError` as the argument of `raise`/`fail`. # # @example # # bad # raise RuntimeError, 'message' # raise RuntimeError.new('message') # # # good # raise 'message'...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/nested_file_dirname.rb
Ruby
mit
12,856
master
1,734
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for nested `File.dirname`. # It replaces nested `File.dirname` with the level argument introduced in Ruby 3.1. # # @example # # # bad # File.dirname(File.dirname(path)) # # # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/operator_method_call.rb
Ruby
mit
12,856
master
3,454
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for redundant dot before operator method call. # The target operator methods are `|`, `^`, `&`, ``<=>``, `==`, `===`, `=~`, `>`, `>=`, `<`, # ``<=``, `<<`, `>>`, `+`, `-`, `*`, `/`, `%`, `**`, `~`, `!`, `!=`, and `!~`...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/sample.rb
Ruby
mit
12,856
master
4,485
# frozen_string_literal: true module RuboCop module Cop module Style # Identifies usages of `shuffle.first`, # `shuffle.last`, and `shuffle[]` and change them to use # `sample` instead. # # @example # # bad # [1, 2, 3].shuffle.first # [1, 2, 3].shuffle.first(...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/trailing_body_on_class.rb
Ruby
mit
12,856
master
980
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for trailing code after the class definition. # # @example # # bad # class Foo; def foo; end # end # # # good # class Foo # def foo; end # end # ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/comment_annotation.rb
Ruby
mit
12,856
master
3,908
# frozen_string_literal: true module RuboCop module Cop module Style # Checks that comment annotation keywords are written according # to guidelines. # # Annotation keywords can be specified by overriding the cop's `Keywords` # configuration. Keywords are allowed to be single words ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/proc.rb
Ruby
mit
12,856
master
947
# frozen_string_literal: true module RuboCop module Cop module Style # Checks for uses of `Proc.new` where `Kernel#proc` # would be more appropriate. `proc` is the shorter and # more idiomatic way to create procs in Ruby. # # @example # # bad # p = Proc.new { |n| put...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/redundant_sort.rb
Ruby
mit
12,856
master
6,547
# frozen_string_literal: true module RuboCop module Cop module Style # Identifies instances of sorting and then # taking only the first or last element. The same behavior can # be accomplished without a relatively expensive sort by using # `Enumerable#min` instead of sorting and taking th...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/file_null.rb
Ruby
mit
12,856
master
2,923
# frozen_string_literal: true module RuboCop module Cop module Style # Use `File::NULL` instead of hardcoding the null device (`/dev/null` on Unix-like # OSes, `NUL` or `NUL:` on Windows), so that code is platform independent. # Only looks for full string matches, substrings within a longer str...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
lib/rubocop/cop/style/regexp_literal.rb
Ruby
mit
12,856
master
7,135
# frozen_string_literal: true module RuboCop module Cop module Style # Enforces using `//` or `%r` around regular expressions. # # NOTE: The following `%r` cases using a regexp starts with a blank or `=` # as a method argument allowed to prevent syntax errors. # # [source,ruby...