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 #365] Mark Rails/SquishedSQLHeredocs unsafe for autocorrection #366

Merged
merged 1 commit into from
Nov 24, 2020

Conversation

tejasbubane
Copy link
Contributor

Closes #365


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.
  • If this is a new cop, consider making a corresponding update to the Rails Style Guide.

@koic
Copy link
Member

koic commented Sep 30, 2020

I think this cop should be aware of false positives in SQL comment line. So I think it can be resolved safely to the issue.

@andyw8
Copy link
Contributor

andyw8 commented Sep 30, 2020

I'm not sure where would be appropriate, but I think would be helpful to mention the reason somewhere, since it's safe as long as comments aren't used.

@greenfork
Copy link

It is also not safe when using with postgres functions, in my example in returns error when squishing $$ which is used for function beginning or ending

@Drenmi
Copy link
Contributor

Drenmi commented Nov 20, 2020

@tejasbubane I added a suggestion documenting the rationale for this above. 🙂

@koic
Copy link
Member

koic commented Nov 20, 2020

Is this really unsafe? I think this cop can make safety by noticing SQL comment and other suggestion. I think these false positives are essential issue in the current implementation.

@Drenmi
Copy link
Contributor

Drenmi commented Nov 20, 2020

Is this really unsafe? I think this cop can make safety by noticing SQL comment and other suggestion.

Hm. We'd need to embed knowledge about several possible SQL dialects into RuboCop and also keep that up to date? 😅

@koic
Copy link
Member

koic commented Nov 20, 2020

Ah, I see. Let's separate the two issues.

First, I think that it is difficult to collect SQL dialects and embed them. So, I agree with @Drenmi's opinion :-)

Second, I think SQL comment (and other SQL dialects) reported in the issue can be treated (fixes the false positive). So, I think this cop can make aware of SQL comment and provide an allow list for unknown SQL dialects. This feature will be an extension different from this PR.

@tejasbubane
Copy link
Contributor Author

@koic @Drenmi I have added the suggested comment.

@koic
Copy link
Member

koic commented Nov 24, 2020

Thanks!

@tejasbubane tejasbubane deleted the fix-365 branch November 24, 2020 16:18
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.

Rails/SquishedSQLHeredocs not safe for autocorrect
5 participants