Skip to content
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

[Fix #7777, #7776]: Generate valid code if comment present before closing brace #7835

Closed
wants to merge 14 commits into from
Closed

[Fix #7777, #7776]: Generate valid code if comment present before closing brace #7835

wants to merge 14 commits into from

Conversation

shekhar-patil
Copy link
Contributor

closes #7777 #7776


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

CHANGELOG.md Outdated Show resolved Hide resolved
relnotes/v0.81.0.md Outdated Show resolved Hide resolved
shekhar-patil and others added 12 commits April 1, 2020 23:35
…rective

implement Style/DisableCopsWithinSourceCodeDirective cop
Resolve part of #7842.

This PR fixes a false positive for `Lint/RaiseException`
when raising Exception with explicit namespace.

`Exception` belonging to a namespace is expected to
inherit `StandardError`.

This PR makes `Lint/RaiseException` aware of the following differences:

```ruby
Gem::Exception.new.is_a?(StandardError) # => true
Exception.new.is_a?(StandardError)      # => false
```

On the other hand, the following case have not been resolved by this PR.

```ruby
module Gem
  def self.foo
    raise Exception
  end
end

Gem.foo #=> Gem::Exception
```

The above case will be resolved separately from this PR.
…exception

[#7842] Fix a false positive for `Lint/RaiseException`
Fix `Lint/UriRegexp` to register offense with array arguments
Fixes #7841.

This PR fixes an error for `Style/TrailingCommaInBlockArgs` cop
when lambda literal (`->`) has multiple arguments.
It will not be checked in the case of lambda literal because
lambda literal (`->`) never have a block arguments.

```console
# Valid syntax
% ruby -ce '-> (foo, bar) { do_something(foo, bar) }'
Syntax OK

# Syntax error
% ruby -ce '-> { |foo| do_something }'
-e:1: syntax error, unexpected '|'
-> { |foo| do_something }
      ^

# Also syntax error
% ruby -ce '-> (foo, bar,) { do_something(foo, bar) }'
-e:1: syntax error, unexpected ')'
-> (foo, bar,) { do_something(foo, bar) }
              ^
-e:1: syntax error, unexpected '}', expecting end-of-input
r,) { do_something(foo, bar) }
                              ^
```
…_in_block_args

[Fix #7841] Fix an error for `Style/TrailingCommaInBlockArgs` cop
@shekhar-patil shekhar-patil deleted the Fix-7777-7776-generate-valid-code-if-comment-present-before-closing-brace branch April 7, 2020 07:29
@shekhar-patil shekhar-patil changed the title [Fix #7777, #7776]: Generate valid code if comment present before closing-brace [Fix #7777, #7776]: Generate valid code if comment present before closing brace Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rubocop places commas into comments, generating invalid ruby code
6 participants