rubocop-config-captive 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d97b68d10ca94ef35962dc273c1157d64839ac6b2fced7c99aed0f07f5eb4a7
4
- data.tar.gz: c98e237061db822fc35993bc780260340eb59bcae41b3cd252d04025effa8216
3
+ metadata.gz: 9e81a471fa3598969b05e170d8e0c4306d92e23c3cbd94004a04fe5b158974ce
4
+ data.tar.gz: 22035f11b13c2d090985a2ae076f79622e6ab2924db3010283539a4a96fb2b25
5
5
  SHA512:
6
- metadata.gz: 87ded8aca4ebc42f5eff1ff4bc5aa57c7f3289d02ba1f95c7b08b46f8ecd75927ffe49aa127d3f0066f004f6c5b81969a30f2137960e607c70c7b43230e74b83
7
- data.tar.gz: aa6036eeabf88151a60b912c0d805e1bbcedcfb36bf5e80d07c0ad5b4b6e55c98c3fc6fe7427e7ede5939657f5050d0227d5d6ac0698b4c6630118edd9ea38fa
6
+ metadata.gz: e5e5960449fab282489dd89f18d7d0c4d03aafb413c64144519d2009ba811587f18c3a158da27349ad435976f8608c7e7eab6942a22e3f31e8caacdc9ba14440
7
+ data.tar.gz: 743c84ce65acf593a6a11d7712a451f53a096545686d61a1f42428553dc9ad6d7eff7f5d24a28dad80b7fd84c4913d7bd33a3ce59c6c8ef6e589e81d42cd7338
@@ -7,6 +7,7 @@ require:
7
7
  - ../lib/rubocop/cop/captive/rails/force_ssl_enabled_in_production.rb
8
8
  - ../lib/rubocop/cop/captive/rails/migration_methods.rb
9
9
  - ../lib/rubocop/cop/captive/rails/no_email_from_controller.rb
10
+ - ../lib/rubocop/cop/captive/rails/no_float_price_columns.rb
10
11
  - ../lib/rubocop/cop/captive/string_where_in_scope.rb
11
12
  - ../lib/rubocop/cop/captive/no_app_env.rb
12
13
 
@@ -56,6 +57,12 @@ Captive/Rails/NoEmailFromController:
56
57
  Include:
57
58
  - 'app/controllers/**/*'
58
59
 
60
+ # Rails
61
+ Captive/Rails/NoFloatPriceColumns:
62
+ Description: "Avoid using `float` type for price columns. Use `decimal, precision: 10, scale: 2` instead."
63
+ Include:
64
+ - 'db/migrate/**/*'
65
+
59
66
  # other
60
67
  Captive/StringWhereInScope:
61
68
  Description: 'The `where` method should be used in a scope in a model.'
@@ -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.11.0"
6
+ VERSION = "1.12.0"
7
7
  end
8
8
  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.11.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: 2024-02-14 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
@@ -187,6 +187,7 @@ files:
187
187
  - lib/rubocop/cop/captive/rails/force_ssl_enabled_in_production.rb
188
188
  - lib/rubocop/cop/captive/rails/migration_methods.rb
189
189
  - lib/rubocop/cop/captive/rails/no_email_from_controller.rb
190
+ - lib/rubocop/cop/captive/rails/no_float_price_columns.rb
190
191
  - lib/rubocop/cop/captive/rspec/specify_before_parameter.rb
191
192
  - lib/rubocop/cop/captive/string_where_in_scope.rb
192
193
  - lib/rubocop/cop/captive/translation/devise_i18n_presence.rb
@@ -212,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
213
  - !ruby/object:Gem::Version
213
214
  version: '0'
214
215
  requirements: []
215
- rubygems_version: 3.3.26
216
+ rubygems_version: 3.3.27
216
217
  signing_key:
217
218
  specification_version: 4
218
219
  summary: Shared rubocop configurations