rubocop-config-captive 1.10.0 → 1.12.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: 9e81a471fa3598969b05e170d8e0c4306d92e23c3cbd94004a04fe5b158974ce
4
+ data.tar.gz: 22035f11b13c2d090985a2ae076f79622e6ab2924db3010283539a4a96fb2b25
5
5
  SHA512:
6
- metadata.gz: '058a5f90001f073c9bb595a0dc14ed402f5e03640181ec849e24120cf29ed87d0417e4721f61df67a83087d7e23c65fdf3b9258691da16fc8ab617362a18e263'
7
- data.tar.gz: 3b67894e5523a7b7a45d7fd748caf54f05b184217c42a52197ab0a482f153b1de5801d807aa1bc4c434a1c12e21ed394c72ef4bc6fafeb4c223c10d9c03282a9
6
+ metadata.gz: e5e5960449fab282489dd89f18d7d0c4d03aafb413c64144519d2009ba811587f18c3a158da27349ad435976f8608c7e7eab6942a22e3f31e8caacdc9ba14440
7
+ data.tar.gz: 743c84ce65acf593a6a11d7712a451f53a096545686d61a1f42428553dc9ad6d7eff7f5d24a28dad80b7fd84c4913d7bd33a3ce59c6c8ef6e589e81d42cd7338
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,10 @@ 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
10
+ - ../lib/rubocop/cop/captive/rails/no_float_price_columns.rb
9
11
  - ../lib/rubocop/cop/captive/string_where_in_scope.rb
10
12
  - ../lib/rubocop/cop/captive/no_app_env.rb
11
13
 
@@ -37,6 +39,18 @@ Captive/RSpec/SpecifyBeforeParameter:
37
39
  Include:
38
40
  - 'spec/**/*'
39
41
 
42
+ # Rails
43
+ Captive/Rails/ForceSslEnabledInProduction:
44
+ Description: "Ensures SSL is forced in production, so that secure cookies are used."
45
+ Include:
46
+ - 'config/environments/production.rb'
47
+
48
+ # Rails
49
+ Captive/Rails/MigrationMethods:
50
+ Description: "Avoid using ActiveRecord::Migration methods in `up` and `down` methods. Use `change` instead."
51
+ Include:
52
+ - 'db/migrate/**/*'
53
+
40
54
  # Rails
41
55
  Captive/Rails/NoEmailFromController:
42
56
  Description: "Do not send emails from controllers. Because it doesn't follow the MVC standard"
@@ -44,10 +58,10 @@ Captive/Rails/NoEmailFromController:
44
58
  - 'app/controllers/**/*'
45
59
 
46
60
  # Rails
47
- Captive/Rails/ForceSslEnabledInProduction:
48
- Description: "Ensures SSL is forced in production, so that secure cookies are used."
61
+ Captive/Rails/NoFloatPriceColumns:
62
+ Description: "Avoid using `float` type for price columns. Use `decimal, precision: 10, scale: 2` instead."
49
63
  Include:
50
- - 'config/environments/production.rb'
64
+ - 'db/migrate/**/*'
51
65
 
52
66
  # other
53
67
  Captive/StringWhereInScope:
@@ -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.12.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
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Captive
6
+ module Rails
7
+ class NoFloatPriceColumns < Base
8
+ MSG = "Avoid using `float` type for price columns. \
9
+ Use `decimal, precision: 10, scale: 2` instead."
10
+
11
+ def_node_matcher :add_column_call?, <<~PATTERN
12
+ (send nil? :add_column _ $(sym {:price :prix}) (sym :float) ...)
13
+ PATTERN
14
+
15
+ def on_send(node)
16
+ add_column_call?(node) do |column|
17
+ add_offense(column, message: MSG)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ 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.12.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-07-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -185,7 +185,9 @@ 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
190
+ - lib/rubocop/cop/captive/rails/no_float_price_columns.rb
189
191
  - lib/rubocop/cop/captive/rspec/specify_before_parameter.rb
190
192
  - lib/rubocop/cop/captive/string_where_in_scope.rb
191
193
  - lib/rubocop/cop/captive/translation/devise_i18n_presence.rb
@@ -211,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
213
  - !ruby/object:Gem::Version
212
214
  version: '0'
213
215
  requirements: []
214
- rubygems_version: 3.3.26
216
+ rubygems_version: 3.3.27
215
217
  signing_key:
216
218
  specification_version: 4
217
219
  summary: Shared rubocop configurations