forked from rubocop/rubocop
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pull] master from rubocop:master #5
Open
pull
wants to merge
675
commits into
jessejay-ch:master
Choose a base branch
from
rubocop:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21,794
−4,866
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ng_a_method Fix `Style/BitwisePredicate` when using a method
…gative, depending on `AllowModifiersOnSymbols` value) access modifiers with multiple symbols.
…mes for `IgnoreNotImplementedMethods` to be configured.
Fixes #13412. This PR fixes a false positive for `Style/RedundantLineContinuation` when there is a line continuation at the end of Ruby code followed by `__END__` data.
Fixes #13199. This PR makes `Style/RedundantCondition` skip autocorrection to avoid removing comments when a branch has a comment.
…moized_instance_variable_name [Fix #13415] Fix false positives for `Naming/MemoizedInstanceVariableName`
… is a safe navigation method call.
…ssl-constant Fix `Lint/DeprecatedOpenSSLConstant` false positive when the argument is a `csend` node
… receiver is `self`.
Use a newer rubocop-ast version, and reduce node destructuring on MasgnNode, OpAsgnNode, CasgnNode, AsgnNode nodes etc.
Reduce node destructuring
Update `Lint/RedundantSafeNavigation` to register an offense when the receiver is `self`
…e_navigation [Fix #13421] Fix false positives for `Style/SafeNavigation`
This is one of those where it is not immediatly obvious what you should actually do. Add code demonstrating what this cop is for and add basic example implementations
```sh $ ruby-parse --27 -e 'def foo(bar: bar); end' (fragment:0):1:14: error: circular argument reference bar (fragment:0):1: def foo(bar: bar); end (fragment:0):1: ^~~ ```
…alse-positive-against-nil Fix false positive for `Lint/FloatComparison` against nil
…tants This works fine: ```console echo 'File.delete(path) if File.exist?(path)' | rubocop --stdin bug.rb --only Lint/NonAtomicFileOperation Inspecting 1 file W Offenses: bug.rb:1:1: W: Lint/NonAtomicFileOperation: Use atomic file operation method FileUtils.rm_f. (https://rubystyle.guide#atomic-file-operations) File.delete(path) if File.exist?(path) ``` This does not: ```console echo 'File.delete(path) if ::File.exist?(path)' | rubocop --stdin bug.rb --only Lint/NonAtomicFileOperation Inspecting 1 file . 1 file inspected, no offenses detected ```
…peration-cop-to-detect-offenses-with-full-constants Fix `Lint/NonAtomicFileOperation` cop to detect offenses with FQ constants
This PR fixes false positives for `Style/MultipleComparison` when using multiple safe navigation method calls.
False negatives were appearing in non-modifier form of if blocks, e.g. ``` if condition 42 end something_else ``` This likely indicates a missing assignment or return. Clean up comments, changelog.
…fier-conditionals [Fix #12393] Fix false negative in Lint/Void inside of non-modifier if blocks
…uations inside a regexp or xstr
[Fix #13578] Update `Layout/LineContinuationSpacing` to ignore continuations inside a `regexp` or `xstr`
…`if` ```console echo 's ? s : (raise s unless $VERBOSE)' | rubocop --stdin /bin/true --only Style/RedundantCondition -d An error occurred while Style/RedundantCondition cop was inspecting /bin/true:1:0. undefined method `line' for nil lib/rubocop/cop/mixin/comments_help.rb:88:in `find_end_line' lib/rubocop/cop/mixin/comments_help.rb:22:in `comments_in_range' lib/rubocop/cop/mixin/comments_help.rb:15:in `contains_comments?' ```
```console echo 'if false; end; p :ok' | rubocop --stdin /bin/true --only Lint/Void -d For /bin: An error occurred while Lint/Void cop was inspecting /bin/true:1:0. undefined method `type' for nil /home/viralpraxis/Documents/open_source/ruby-gems/rubocop/lib/rubocop/cop/lint/void.rb:248:in `entirely_literal?' /home/viralpraxis/Documents/open_source/ruby-gems/rubocop/lib/rubocop/cop/lint/void.rb:158:in `check_literal' /home/viralpraxis/Documents/open_source/ruby-gems/rubocop/lib/rubocop/cop/lint/void.rb:119:in `check_expression' /home/viralpraxis/Documents/open_source/ruby-gems/rubocop/lib/rubocop/cop/lint/void.rb:111:in `block in check_begin' /home/viralpraxis/Documents/open_source/ruby-gems/rubocop/lib/rubocop/cop/lint/void.rb:104:in `each' /home/viralpraxis/Documents/open_source/ruby-gems/rubocop/lib/rubocop/cop/lint/void.rb:104:in `check_begin' /home/viralpraxis/Documents/open_source/ruby-gems/rubocop/lib/rubocop/cop/lint/void.rb:91:in `on_begin' ```
…ion-cop-error-on-parentheses-and-modifier-if Fix `Style/RedundantCondition` cop error on parentheses and modifier `if`
…-if-without-body Fix `Lint/Void` cop error on `if` without body
…ferent comparison operators were aligned with each other
This PR fixes false positives for `Lint/NestedMethodDefinition` when defining a method on a constant or a method call. It follows the same reasoning as #12961. This should respect the intent of the code and should not be linted.
Since we have two cops that need to safely parse regular expressions, it makes sense to add a specific method to the RuboCop::Cop::Util module.
[Fix #11013] Guards against bugs from mutable literals used as default arguments during Hash initialization. Since that will return the same mutable objectfor all missing keys, it would allow each mutation to affect the values of all keys initialized with the default value simultaneously. Reference: https://stackoverflow.com/questions/2698460/strange-unexpected-behavior-disappearing-changing-values-when-using-hash-defa
[DOC] Fix typo in `Style/ExponentialNotation`
Add a new search method for determining the target ruby version: the RUBOCOP_TARGET_RUBY_VERSION environment variable. This is now the first source checked, allowing it to override all other sources of the target ruby version.
Currently, there are exactly three instances where the receiver-mutating `String#force_encoding` method is used. In all cases except for `to_string_literal`, a `String#dup` call is included to ensure compatibility with frozen strings. I couldn't identify any counterexamples in rubocop core that would result in a runtime error, but there is at least one instance in `rubocop-performance` [1] where a frozen string might be passed. To ensure everything works correctly, we need to add a `#dup` call in the implementation of `to_string_literal`. For additional context, it's worth noting that the Prism parser might start freezing AST leaf nodes in the future [2], and whitequark's parser has some unpredictability in this regard [3]. [1] rubocop/rubocop-performance#480 [2] ruby/prism#3309 [3] rubocop/rubocop-ast#342
… when continuations are inside begin nodes
…-in-to-string-literal-helper Dup possibly frozen string in `to_string_literal` helper
```console echo '"#{"\201\203"}"' | rubocop --stdin bug.rb --only Lint/LiteralInInterpolation -d An error occurred while Lint/LiteralInInterpolation cop was inspecting bug.rb:1:0. invalid byte sequence in UTF-8 lib/active_support/core_ext/object/blank.rb:159:in `match?' lib/active_support/core_ext/object/blank.rb:159:in `blank?' lib/rubocop/cop/lint/literal_in_interpolation.rb:171:in `space_literal?' lib/rubocop/cop/lint/literal_in_interpolation.rb:51:in `offending?' lib/rubocop/cop/lint/literal_in_interpolation.rb:26:in `on_interpolation' ``` Co-authored-by: Koichi ITO <[email protected]>
… splat and triple dot forwarding
[Fix #13614] Fix false positives for `Style/RaiseArgs` with anonymous splat and triple dot forwarding
…olation-error-on-invalid-string Fix `Lint/LiteralInInterpolation` cop error on invalid string literal
Fix incorrect autocorrect for `Style/RedundantRegexpArgument` when the regex contains a single quote.
[Fix #12430] Fix false negatives in `Style/RedundantLineContinuation` when continuations are inside begin nodes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot]
Can you help keep this open source service alive? 💖 Please sponsor : )