Skip to content

Commit

Permalink
[Fix rubocop#365] Mark Rails/SquishedSQLHeredocs unsafe for autocor…
Browse files Browse the repository at this point in the history
…rection

Closes rubocop#365
  • Loading branch information
tejasbubane committed Nov 23, 2020
1 parent 9808efd commit f62403c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
### Changes

* [#383](https://github.com/rubocop-hq/rubocop-rails/pull/383): Require RuboCop 0.90 or higher. ([@koic][])
* [#365](https://github.com/rubocop-hq/rubocop-rails/issues/365): Mark `Rails/SquishedSQLHeredocs` unsafe for autocorrection. ([@tejasbubane][])

## 2.8.1 (2020-09-16)

Expand Down
4 changes: 4 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ Rails/SquishedSQLHeredocs:
StyleGuide: 'https://rails.rubystyle.guide/#squished-heredocs'
Enabled: 'pending'
VersionAdded: '2.8'
VersionChanged: '2.9'
# Some SQL syntax (e.g. PostgreSQL comments and functions) requires newlines
# to be preserved in order to work, thus auto-correction is not safe.
SafeAutoCorrect: false

Rails/TimeZone:
Description: 'Checks the correct usage of time zone aware methods.'
Expand Down
7 changes: 5 additions & 2 deletions docs/modules/ROOT/pages/cops_rails.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4056,13 +4056,16 @@ user.touch

| Pending
| Yes
| Yes
| Yes (Unsafe)
| 2.8
| -
| 2.9
|===

Checks SQL heredocs to use `.squish`.

Some SQL syntax (e.g. PostgreSQL comments and functions) requires newlines
to be preserved in order to work, thus auto-correction for this cop is not safe.

=== Examples

[source,ruby]
Expand Down
3 changes: 3 additions & 0 deletions lib/rubocop/cop/rails/squished_sql_heredocs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ module Rails
# WHERE post_id = 1
# SQL
#
# Some SQL syntax (e.g. PostgreSQL comments and functions) requires newlines
# to be preserved in order to work, thus auto-correction for this cop is not safe.
#
class SquishedSQLHeredocs < Base
include Heredoc
extend AutoCorrector
Expand Down

0 comments on commit f62403c

Please sign in to comment.