rubocop-config-captive 1.10.0 → 1.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec090335cc21d999869f452a9a6b9b4cfe5dc6fa0a54b056c7d9bfd4ac5b50ee
4
- data.tar.gz: d117c41479893741eb461de0036b9bc617e07a27a2b1f5faaa1244f180bfa52c
3
+ metadata.gz: 3d97b68d10ca94ef35962dc273c1157d64839ac6b2fced7c99aed0f07f5eb4a7
4
+ data.tar.gz: c98e237061db822fc35993bc780260340eb59bcae41b3cd252d04025effa8216
5
5
  SHA512:
6
- metadata.gz: '058a5f90001f073c9bb595a0dc14ed402f5e03640181ec849e24120cf29ed87d0417e4721f61df67a83087d7e23c65fdf3b9258691da16fc8ab617362a18e263'
7
- data.tar.gz: 3b67894e5523a7b7a45d7fd748caf54f05b184217c42a52197ab0a482f153b1de5801d807aa1bc4c434a1c12e21ed394c72ef4bc6fafeb4c223c10d9c03282a9
6
+ metadata.gz: 87ded8aca4ebc42f5eff1ff4bc5aa57c7f3289d02ba1f95c7b08b46f8ecd75927ffe49aa127d3f0066f004f6c5b81969a30f2137960e607c70c7b43230e74b83
7
+ data.tar.gz: aa6036eeabf88151a60b912c0d805e1bbcedcfb36bf5e80d07c0ad5b4b6e55c98c3fc6fe7427e7ede5939657f5050d0227d5d6ac0698b4c6630118edd9ea38fa
data/README.md CHANGED
@@ -110,3 +110,18 @@ To contribute, here are some inspirations for good configurations :
110
110
  [license-image]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square
111
111
  <!-- AUTO-GENERATED-CONTENT:END -->
112
112
  [license-url]: ./LICENSE
113
+
114
+ About Captive
115
+ -------------
116
+
117
+ ![captive](https://raw.githubusercontent.com/Captive-Studio/assets/main/logo_captive_blue_avec_fond.webp)
118
+
119
+ rubocop-config-captive is maintained and funded by Captive.
120
+ The names and logos for captive are trademarks of captive-studio.
121
+
122
+ We love open source software!
123
+ See [our other projects][community] or
124
+ [hire us][hire] to design, develop, and grow your product.
125
+
126
+ [community]: https://github.com/Captive-Studio
127
+ [hire]: https://www.captive.fr/contact?utm_source=github
@@ -4,8 +4,9 @@ require:
4
4
  - ../lib/rubocop/cop/captive/translation/rails_i18n_presence.rb
5
5
  - ../lib/rubocop/cop/captive/translation/kaminari_i18n_presence.rb
6
6
  - ../lib/rubocop/cop/captive/rspec/specify_before_parameter.rb
7
- - ../lib/rubocop/cop/captive/rails/no_email_from_controller.rb
8
7
  - ../lib/rubocop/cop/captive/rails/force_ssl_enabled_in_production.rb
8
+ - ../lib/rubocop/cop/captive/rails/migration_methods.rb
9
+ - ../lib/rubocop/cop/captive/rails/no_email_from_controller.rb
9
10
  - ../lib/rubocop/cop/captive/string_where_in_scope.rb
10
11
  - ../lib/rubocop/cop/captive/no_app_env.rb
11
12
 
@@ -37,18 +38,24 @@ Captive/RSpec/SpecifyBeforeParameter:
37
38
  Include:
38
39
  - 'spec/**/*'
39
40
 
40
- # Rails
41
- Captive/Rails/NoEmailFromController:
42
- Description: "Do not send emails from controllers. Because it doesn't follow the MVC standard"
43
- Include:
44
- - 'app/controllers/**/*'
45
-
46
41
  # Rails
47
42
  Captive/Rails/ForceSslEnabledInProduction:
48
43
  Description: "Ensures SSL is forced in production, so that secure cookies are used."
49
44
  Include:
50
45
  - 'config/environments/production.rb'
51
46
 
47
+ # Rails
48
+ Captive/Rails/MigrationMethods:
49
+ Description: "Avoid using ActiveRecord::Migration methods in `up` and `down` methods. Use `change` instead."
50
+ Include:
51
+ - 'db/migrate/**/*'
52
+
53
+ # Rails
54
+ Captive/Rails/NoEmailFromController:
55
+ Description: "Do not send emails from controllers. Because it doesn't follow the MVC standard"
56
+ Include:
57
+ - 'app/controllers/**/*'
58
+
52
59
  # other
53
60
  Captive/StringWhereInScope:
54
61
  Description: 'The `where` method should be used in a scope in a model.'
@@ -27,13 +27,7 @@ MagicNumbers/NoAssignment:
27
27
  - '**/config/**/*'
28
28
 
29
29
  MagicNumbers/NoDefault:
30
- Enabled: true
31
- Exclude:
32
- - '**/spec/**/*.rb'
33
- - '**/test/**/*.rb'
34
- - '**/*_spec.rb'
35
- - '**/*_test.rb'
36
- - '**/config/**/*'
30
+ Enabled: false
37
31
 
38
32
  MagicNumbers/NoReturn:
39
33
  Enabled: true
@@ -13,3 +13,19 @@ RSpec/ScatteredSetup:
13
13
  RSpec/RepeatedExample:
14
14
  Exclude:
15
15
  - 'spec/requests/**/*'
16
+
17
+ RSpec/ContextWording:
18
+ Enabled: true
19
+ Prefixes:
20
+ - when
21
+ - with
22
+ - without
23
+ - if
24
+ - unless
25
+ - for
26
+ - quand
27
+ - avec
28
+ - sans
29
+ - si
30
+ - sauf si
31
+ - pour
@@ -3,6 +3,6 @@
3
3
  module RuboCop
4
4
  module Captive
5
5
  # Version information for the the Airbnb RuboCop plugin.
6
- VERSION = "1.10.0"
6
+ VERSION = "1.11.0"
7
7
  end
8
8
  end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Captive
6
+ module Rails
7
+ ##
8
+ # This cop ensures the use `change` method when is possible.
9
+ #
10
+ # Il est possible d'utiliser la méthode `change` lors de l'utilisation de méthode de ActiveRecord::Migration tel que : `remove_column`, `add_column`, `add_index`, ...
11
+ # La méthode gère automatiquement le UP et le DOWN.
12
+ # Il n'est donc pas nécéssaire définir le `def up` et `def down` seulement lors d'une migration de donnée
13
+ #
14
+ # @example
15
+ # # bad
16
+ # def up
17
+ # remove_column :table, :column, :type
18
+ # end
19
+ #
20
+ # def down
21
+ # add_column :table, :column, :type
22
+ # end
23
+ #
24
+ # # good
25
+ # def change
26
+ # remove_column :table, :column, :type
27
+ # end
28
+ #
29
+ # @see https://git.captive.fr/captive/iris-galerie/iris-platform/-/merge_requests/676#note_186669
30
+ class MigrationMethods < Base
31
+ MSG = "Avoid using ActiveRecord::Migration methods in `up` and `down` methods. \
32
+ Use `change` instead."
33
+
34
+ BLACKLISTED_METHODS = %i(
35
+ add_column
36
+ add_foreign_key
37
+ add_index
38
+ add_reference
39
+ add_timestamps
40
+ change_column
41
+ change_table
42
+ create_table
43
+ create_join_table
44
+ drop_table
45
+ remove_column
46
+ remove_foreign_key
47
+ remove_index
48
+ remove_reference
49
+ remove_timestamps
50
+ rename_column
51
+ rename_index
52
+ rename_table
53
+ ).freeze
54
+
55
+ def_node_search :migration_method?, <<~PATTERN
56
+ (send nil? {#{BLACKLISTED_METHODS.map(&:inspect).join(" ")}} ...)
57
+ PATTERN
58
+
59
+ def on_def(node)
60
+ return unless %i(up down).include?(node.method_name)
61
+ return unless migration_method?(node)
62
+
63
+ add_offense(node, message: MSG)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-config-captive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Captive
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-11-20 00:00:00.000000000 Z
13
+ date: 2024-02-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -185,6 +185,7 @@ files:
185
185
  - lib/rubocop/cop/captive/active_admin/active_admin_addons_presence.rb
186
186
  - lib/rubocop/cop/captive/no_app_env.rb
187
187
  - lib/rubocop/cop/captive/rails/force_ssl_enabled_in_production.rb
188
+ - lib/rubocop/cop/captive/rails/migration_methods.rb
188
189
  - lib/rubocop/cop/captive/rails/no_email_from_controller.rb
189
190
  - lib/rubocop/cop/captive/rspec/specify_before_parameter.rb
190
191
  - lib/rubocop/cop/captive/string_where_in_scope.rb