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

Add new Rails/CalendarTypeSuffix cop #367

Closed
wants to merge 1 commit into from

Conversation

jmks
Copy link

@jmks jmks commented Oct 4, 2020

Adds a new cop that checks for column names to match a convention for calendar types (time, date, and datetime).
Inspired from here, specifically:

  • Name date columns with _on suffixes.
  • Name datetime columns with _at suffixes.
  • Name time columns (referring to a time of day with no date) with _time suffixes.

These suffixes are configurable.

I have a question: The db/schema.rb is excluded by default on all Cops. AFAIK, there's no way to override that on a per-cop basis? I tried the Include option but it does not show up in --list-target-files.

For testing, I can force it to run agains the file with bundle exec rubocop db/schema.rb --only Rails/CalendarTypeSuffix.

Maybe this makes the cop a no-go?


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.

@jmks jmks force-pushed the calendar_type_suffix_conventions branch from b6fb70b to 6dc2586 Compare October 4, 2020 17:03
@andyw8
Copy link
Contributor

andyw8 commented Oct 4, 2020

This seem very similar to #335 ?

@jmks
Copy link
Author

jmks commented Oct 4, 2020

Ah, I ported this from some internal cop I had.

#335 scans the db/migrations which I guess avoids the issue with violations against db/schema.rb. But it also would not have a "backlog" of violations to fix (migrations tend to not stay around forever).

I think that one would work well enough. I can close this.

@jmks jmks closed this Oct 9, 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.

2 participants