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

Cop to detect redundant # frozen_string_literal: true magic comment #11043

Closed
yahonda opened this issue Oct 3, 2022 · 1 comment · Fixed by #11044
Closed

Cop to detect redundant # frozen_string_literal: true magic comment #11043

yahonda opened this issue Oct 3, 2022 · 1 comment · Fixed by #11044
Assignees

Comments

@yahonda
Copy link

yahonda commented Oct 3, 2022

Is your feature request related to a problem? Please describe.

I'd like to know if there are any cop that fixes duplicate / redundant # frozen_string_literal: true magic comments. Refer to rails/rails#46183 for the background.

Describe the solution you'd like

  • Bad
# frozen_string_literal: true

# frozen_string_literal: true

def foo; end
  • Good
# frozen_string_literal: true

def foo; end

Describe alternatives you've considered

Find each file manually to see if there are redundant # frozen_string_literal: true in each *.rb file.

Additional context

Add any other context or screenshots about the feature request here.

@koic
Copy link
Member

koic commented Oct 3, 2022

Yeah, I also saw that PR rails/rails#46183 and am just starting to implement it. And I'm considering including a slightly more comprehensive feature. Thank you ❤️

@koic koic self-assigned this Oct 3, 2022
koic added a commit to koic/rubocop that referenced this issue Oct 4, 2022
Fixes rubocop#11043

This PR adds new `Lint/DuplicateMagicComment` cop.

```ruby
# bad

# encoding: ascii
# encoding: ascii

# good

# encoding: ascii

# bad

# frozen_string_literal: true
# frozen_string_literal: true

# good

# frozen_string_literal: true
```
bbatsov pushed a commit that referenced this issue Oct 4, 2022
Fixes #11043

This PR adds new `Lint/DuplicateMagicComment` cop.

```ruby
# bad

# encoding: ascii
# encoding: ascii

# good

# encoding: ascii

# bad

# frozen_string_literal: true
# frozen_string_literal: true

# good

# frozen_string_literal: true
```
byroot pushed a commit to rails/rails that referenced this issue Nov 14, 2022
This PR enables `Lint/DuplicateMagicComment` cop to resolve
the background of rubocop/rubocop#11043.

And this PR bumps RuboCop version because the cop was introduced in RuboCop 1.37.0:
https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md#1370-2022-10-20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants