Commit graph

23 commits

Author SHA1 Message Date
Michael Kozono
9beef18487 Add SaferBooleanColumn cop 2017-08-14 07:57:57 -07:00
Yorick Peterse
a004f9ec8c
Added cop to blacklist the use of hash indexes
These indexes are not recorded in the WAL (at least until PostgreSQL
10) and this isn't worth the minor performance improvement over btree
indexes.
2017-07-14 13:19:00 +02:00
Yorick Peterse
ff78af152c
Added EachBatch for iterating tables in batches
This module provides a class method called `each_batch` that can be used
to iterate tables in batches in a more efficient way compared to Rails'
`in_batches` method. This commit also includes a RuboCop cop to
blacklist the use of `in_batches` in favour of this new method.
2017-07-07 16:39:36 +02:00
Yorick Peterse
e1a3bf30b6
Rename ActiverecordSerialize cop
This cop has been renamed to ActiveRecordSerialize to match the way
"ActiveRecord" is usually written.
2017-07-06 12:01:36 +02:00
Yorick Peterse
8fbbf41e29
Added Cop to blacklist the use of dependent:
This is allowed for existing instances so we don't end up 76 offenses
right away, but for new code one should _only_ use this if they _have_
to remove non database data. Even then it's usually better to do this in
a service class as this gives you more control over how to remove the
data (e.g. in bulk).
2017-07-06 12:01:36 +02:00
Douwe Maan
873b40555b Add ProjectPathHelper cop 2017-07-05 11:12:00 -05:00
Robert Speicher
69ad827e82 Add a custom RSpec/SingleLineHook cop
This cop adds an offense when `before`, `after`, or `around` are used as
single-line blocks.
2017-06-14 13:16:44 -05:00
blackst0ne
bc00806a4e Add database helpers 'add_timestamps_with_timezone' and 'timestamps_with_timezone' 2017-06-13 22:44:13 +11:00
Yorick Peterse
5819ca1a24
Added Cop to blacklist polymorphic associations
One should really use a separate table instead of using polymorphic
associations.

See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11168 for
more information.
2017-06-07 17:36:55 +02:00
blackst0ne
a544e46bb0 Add a rubocop rule to check if a method 'redirect_to' is used without explicitly set 'status' in 'destroy' actions of controllers 2017-06-07 09:45:16 +11:00
Yorick Peterse
cd74c1434e
Added Cop to blacklist the use of serialize
This Cop blacklists the use of ActiveRecord's "serialize" method, except
for cases where we already use this.
2017-05-31 14:03:37 +02:00
Rémy Coutable
187e6c8d7c New Migration/UpdateColumnInBatches cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-05-29 11:28:23 +02:00
Robert Speicher
b9fa17d87b Add AddColumnWithDefaultToLargeTable cop 2017-04-28 15:55:55 -05:00
Robert Speicher
9c27c90b4a Rename AddColumnWithDefault to ReversibleAddColumnWithDefault
We're going to add another cop that deals with another aspect of
`add_column_with_default`, so we need to separate them.
2017-04-28 15:55:53 -05:00
blackst0ne
9997c58fc0 Add remove_concurrent_index to database helper 2017-04-06 09:53:57 +11:00
Douwe Maan
5d9762b3b5 Add cop to ensure reversibility of add_concurrent_index 2017-03-07 10:09:01 -06:00
Sean McGivern
811e598f60 Enable and autocorrect the CustomErrorClass cop 2017-03-01 15:28:10 +00:00
Yorick Peterse
766060bcdf
Enforce use of add_concurrent_foreign_key
This adds a Rubocop rule to enforce the use of
add_concurrent_foreign_key instead of the regular add_foreign_key
method. This cop has been disabled for existing migrations so we don't
need to change those.
2017-02-10 21:51:09 +01:00
Robert Speicher
f57989c2ed Add a spec for our custom GemFetcher cop 2017-02-09 12:11:19 -05:00
Douwe Maan
b0afed1aac Explicitly require rubocop migration_helpers 2017-02-08 16:47:48 -06:00
Douwe Maan
abc9548f8a Add cop that checks if add_column_with_default is used with up/down methods 2017-02-08 16:47:48 -06:00
Adam Pahlevi
78a3bba62e cop for gem fetched from a git source
code fix for aesthetic & conventions

remove unused proc
2017-01-31 09:24:15 +07:00
Yorick Peterse
c740445ad3
Added RuboCop cops for checking DB migrations
There are currently two cops for this:

* Migration/AddIndex: checks if indexes are added concurrently
* Migration/ColumnWithDefault: checks if columns with default values are
  added in a concurrent manner

Both cops are fairly simple and make no attempt at correcting the code
as this is quite hard to do (e.g. modifications may need to be applied
in various places in the same file). They however should provide enough
to catch people ignoring the comments in generated migrations telling
them to use add_concurrent_index or add_column_with_default.
2016-06-29 14:14:02 +02:00