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 idea: replace #strip_heredoc with squiggly heredoc in heredoc declarations #704

Closed
ojab opened this issue May 27, 2022 · 0 comments · Fixed by #706
Closed

Cop idea: replace #strip_heredoc with squiggly heredoc in heredoc declarations #704

ojab opened this issue May 27, 2022 · 0 comments · Fixed by #706
Labels
feature request Request for new functionality

Comments

@ojab
Copy link
Contributor

ojab commented May 27, 2022

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

ruby>=2.3 has squiggly heredoc (<<~) which does the same as Rails #strip_heredoc method.

Describe the solution you'd like

Would be good to have a cop that suggests/autofixes code that using <<-TEXT.strip_heredoc -> <<~TEXT.

Describe alternatives you've considered

/shrug

Additional context

x = <<~TEXT
  some text
    second line
TEXT

y = <<-TEXT.strip_heredoc
  some text
    second line
TEXT

p x == y # => true
@koic koic added the feature request Request for new functionality label May 27, 2022
koic added a commit to koic/rubocop-rails that referenced this issue May 27, 2022
Enforces the use of squiggly heredoc over `strip_heredoc`.

```ruby
# bad
<<EOS.strip_heredoc
  some text
EOS

<<-EOS.strip_heredoc
  some text
EOS

# good
<<~EOS
  some text
EOS
```
koic added a commit to koic/rubocop-rails that referenced this issue May 27, 2022
Enforces the use of squiggly heredoc over `strip_heredoc`.

```ruby
# bad
<<EOS.strip_heredoc
  some text
EOS

<<-EOS.strip_heredoc
  some text
EOS

# good
<<~EOS
  some text
EOS
```
koic added a commit to koic/rubocop-rails that referenced this issue May 27, 2022
Closes rubocop#704.

Enforces the use of squiggly heredoc over `strip_heredoc`.

```ruby
# bad
<<EOS.strip_heredoc
  some text
EOS

<<-EOS.strip_heredoc
  some text
EOS

# good
<<~EOS
  some text
EOS
```
koic added a commit to koic/rubocop-rails that referenced this issue May 27, 2022
Closes rubocop#704.

Enforces the use of squiggly heredoc over `strip_heredoc`.

```ruby
# bad
<<EOS.strip_heredoc
  some text
EOS

# bad
<<-EOS.strip_heredoc
  some text
EOS

# good
<<~EOS
  some text
EOS
```
koic added a commit to koic/rubocop-rails that referenced this issue May 28, 2022
Closes rubocop#704.

Enforces the use of squiggly heredoc over `strip_heredoc`.

```ruby
# bad
<<EOS.strip_heredoc
  some text
EOS

# bad
<<-EOS.strip_heredoc
  some text
EOS

# good
<<~EOS
  some text
EOS
```
koic added a commit to koic/rubocop-rails that referenced this issue May 28, 2022
Closes rubocop#704.

Enforces the use of squiggly heredoc over `strip_heredoc`.

```ruby
# bad
<<EOS.strip_heredoc
  some text
EOS

# bad
<<-EOS.strip_heredoc
  some text
EOS

# good
<<~EOS
  some text
EOS
```
koic added a commit to koic/rubocop-rails that referenced this issue May 30, 2022
Closes rubocop#704.

Enforces the use of squiggly heredoc over `strip_heredoc`.

```ruby
# bad
<<EOS.strip_heredoc
  some text
EOS

# bad
<<-EOS.strip_heredoc
  some text
EOS

# good
<<~EOS
  some text
EOS
```
@koic koic closed this as completed in #706 Jun 12, 2022
koic added a commit that referenced this issue Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants