Skip to content

missing_presence_validation: ignore counter cache columns#180

Merged
gregnavis merged 1 commit intogregnavis:masterfrom
fatkodima:ignore-counter-caches
Jan 4, 2025
Merged

missing_presence_validation: ignore counter cache columns#180
gregnavis merged 1 commit intogregnavis:masterfrom
fatkodima:ignore-counter-caches

Conversation

@fatkodima
Copy link
Contributor

This check produces false positives for counter cache columns.
These are expected to be set by ActiveRecord, not by users.

@fatkodima
Copy link
Contributor Author

@gregnavis Can you please merge all the open PRs?

@gregnavis
Copy link
Owner

Thanks for the nudge, @fatkodima! I won't merge them all today, as I'd like to see some changes made, but I definitely need to pay attention to the outstanding PRs. I left some comments on a few other PRs.

Here, I'm not sure what to do with older Rails versions. I think we'll drop 4.2 soon (I'm sure you'd love that decision!), but that would require a new major release.

For now, I suggest the following: Rails versions that fail in CI due to outdated APIs should:

  1. Show a warning to the user with the following content: "missing_presence_validation: counter cache columns will receive complaints about missing presence validations in Rails versions older than X.Y; you can add them to ignore_attributes"
  2. Skip counter cache detection for those older Rails versions.

@fatkodima, does that make sense?

@fatkodima fatkodima force-pushed the ignore-counter-caches branch from 55443af to bbbaada Compare August 26, 2024 18:28
@fatkodima
Copy link
Contributor Author

Sorry, I am lazy and will wait when you drop the old version.

Imo, you can easily drop activerecord < 7 and release v2 version of the gem. People on rails 4.2 don't care about best practices, so they are not the target audience of this gem.

@gregnavis gregnavis added the false positive An error is reported when it shouldn't label Aug 27, 2024
@gregnavis gregnavis added this to the 2.0 milestone Aug 27, 2024
@gregnavis
Copy link
Owner

@fatkodima, you are not lazy at all! I totally understand supporting 4.2 is a total pain in the ass.

I marked this and a few other PRs for 2.0.

@fatkodima fatkodima force-pushed the ignore-counter-caches branch from bbbaada to 4bc0eef Compare September 5, 2024 22:09
@gregnavis gregnavis force-pushed the master branch 3 times, most recently from afcda83 to 4ee897c Compare November 10, 2024 14:43
@gregnavis gregnavis merged commit 88c85d0 into gregnavis:master Jan 4, 2025
@gregnavis gregnavis modified the milestones: 2.0, 1.16 Jan 4, 2025
@fatkodima fatkodima deleted the ignore-counter-caches branch January 4, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

false positive An error is reported when it shouldn't

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants