active_record_callbacks_cop 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +15 -1
- data/gemfiles/rails3.gemfile.lock +2 -2
- data/gemfiles/rails4.gemfile.lock +2 -2
- data/gemfiles/rails5.gemfile.lock +2 -2
- data/lib/active_record_callbacks_cop/cop.rb +2 -3
- data/lib/active_record_callbacks_cop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed5aeeab0dbabae7d8950a6b63b789324799494a32c838c816c694f96a5521df
|
4
|
+
data.tar.gz: 5c66d0f132c821466b2e3d15f82c19e867dafb3c1e5bfbe2a9ac936ad8abdd2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56158c76babf3f8b161fe7a4184400e20724ac682714605e761e8599e5f0953e746ddc01ac7ab02fa66c30f62c926fc24197dcb1c50b4d4fba6131a35a2e71ce
|
7
|
+
data.tar.gz: 0dd3cb356fa50bd82ff7081ae04122db54c4a6b524d4a51c8c64792483729421cbfba546e96e316df6fe8b52fb93f019eefe976957dd6fd8b0d6748ad6d9b692
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,23 @@
|
|
2
2
|
|
3
3
|
Use this [RuboCop](https://github.com/rubocop-hq/rubocop) extension to stop yourself from using ActiveRecord callbacks. They'll only hurt you in the long run and its best to avoid them from the start.
|
4
4
|
|
5
|
+
These are the callbacks ActiveRecord provides:
|
6
|
+
|
7
|
+
- `before_validation`/`after_validation`
|
8
|
+
- `before_create`/`around_create`/`after_create`
|
9
|
+
- `before_save`/`around_save`/`after_save`
|
10
|
+
- `before_destroy`/`around_destroy`/`after_destroy`
|
11
|
+
- `after_touch`
|
12
|
+
- `after_commit`
|
13
|
+
- `after_create_commit`/`after_update_commit`/`after_destroy_commit`
|
14
|
+
- `after_rollback`
|
15
|
+
- `after_initialize`/`after_find`
|
16
|
+
|
17
|
+
This cop registers offenses whenever it sees any of these class methods called in `ApplicationRecord` or `ActiveRecord::Base` subclasses, except for `after_iniitalize` and `after_find`.
|
18
|
+
|
5
19
|
## Installation
|
6
20
|
|
7
|
-
|
21
|
+
Install the `active_record_callbacks_cop` gem
|
8
22
|
|
9
23
|
```bash
|
10
24
|
gem install active_record_callbacks_cop
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
active_record_callbacks_cop (0.1.
|
4
|
+
active_record_callbacks_cop (0.1.1)
|
5
5
|
rubocop (>= 0.72.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -108,7 +108,7 @@ GEM
|
|
108
108
|
diff-lcs (>= 1.2.0, < 2.0)
|
109
109
|
rspec-support (~> 3.8.0)
|
110
110
|
rspec-support (3.8.2)
|
111
|
-
rubocop (0.
|
111
|
+
rubocop (0.73.0)
|
112
112
|
jaro_winkler (~> 1.5.1)
|
113
113
|
parallel (~> 1.10)
|
114
114
|
parser (>= 2.6)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
active_record_callbacks_cop (0.1.
|
4
|
+
active_record_callbacks_cop (0.1.1)
|
5
5
|
rubocop (>= 0.72.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -124,7 +124,7 @@ GEM
|
|
124
124
|
diff-lcs (>= 1.2.0, < 2.0)
|
125
125
|
rspec-support (~> 3.8.0)
|
126
126
|
rspec-support (3.8.2)
|
127
|
-
rubocop (0.
|
127
|
+
rubocop (0.73.0)
|
128
128
|
jaro_winkler (~> 1.5.1)
|
129
129
|
parallel (~> 1.10)
|
130
130
|
parser (>= 2.6)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
active_record_callbacks_cop (0.1.
|
4
|
+
active_record_callbacks_cop (0.1.1)
|
5
5
|
rubocop (>= 0.72.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -135,7 +135,7 @@ GEM
|
|
135
135
|
diff-lcs (>= 1.2.0, < 2.0)
|
136
136
|
rspec-support (~> 3.8.0)
|
137
137
|
rspec-support (3.8.2)
|
138
|
-
rubocop (0.
|
138
|
+
rubocop (0.73.0)
|
139
139
|
jaro_winkler (~> 1.5.1)
|
140
140
|
parallel (~> 1.10)
|
141
141
|
parser (>= 2.6)
|
@@ -23,18 +23,17 @@ module ActiveRecordCallbacksCop
|
|
23
23
|
%w(ActiveRecord::Base ApplicationRecord)
|
24
24
|
end
|
25
25
|
|
26
|
-
# TODO: decide whether to ban before_validation/after_validation
|
27
|
-
# TODO: decide whether to ban after_initialize/after_find
|
28
|
-
# TODO: decide whether to ban after_touch
|
29
26
|
# TODO: maybe there should be separate cops for groups of callbacks?
|
30
27
|
def callback_names
|
31
28
|
%i(
|
29
|
+
before_validation after_validation
|
32
30
|
before_save around_save after_save
|
33
31
|
before_create around_create after_create
|
34
32
|
before_destroy around_destroy after_destroy
|
35
33
|
after_commit
|
36
34
|
after_create_commit after_update_commit after_destroy_commit
|
37
35
|
after_rollback
|
36
|
+
after_touch
|
38
37
|
)
|
39
38
|
end
|
40
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_callbacks_cop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hoffman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|