spbtv_code_style 1.6.0 → 1.7.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
  SHA1:
3
- metadata.gz: 0de24f59699801bfff09af903c583958f4b3c755
4
- data.tar.gz: 197af631ec792872175430b8c7ccfe1dfacdb1a2
3
+ metadata.gz: 4956a8305ed40f13b8cd8755a32f328387249738
4
+ data.tar.gz: 520b8c516309e102eb5d82647064150747d21116
5
5
  SHA512:
6
- metadata.gz: 0abe4066eb2bb1c5ef46f06f721d97d2d0f3b771533e5feb483f6d00a9fea89c16b3dd1c28d6c2da4d6ef573df3e0f21161a72d69f4f3a566fc4b0edf765b5b7
7
- data.tar.gz: 259dfdec5f01c3632aef02bec2f6445dbcd2120c310e2ec59177107a0d33e72b212a29bd95a7ac2eedb6c222416a0c3637ea62b5ca3222717e026a8b2394132e
6
+ metadata.gz: 3d3a932c5e7d4d53c43bc7760a42895f77073d84a9c9f66754c745254cd3c92890ef39caef3e1f2d8c2aa6ec5b4d2cf7867d6b0ce9fd83d869cabbad19b30d26
7
+ data.tar.gz: 3a544aab231e45442c74a3bc180a20ede42eda2ee6cb5b700862030da35722d3c7e486edf663a8086e2c9226a36e3ed9ffaa3566cc47abb9e492d3b7cbe4569b
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Spbtv
6
+ module Postgres
7
+ # Do not use find_each with Postgresql.
8
+ #
9
+ # ActiveRecord's find_each and find_in_batches ignore non-integer primary keys,
10
+ # thus limiting output to 1000 records.
11
+ # Workaround: use https://github.com/afair/postgresql_cursor gem with its each_instance method.
12
+ #
13
+ # @example
14
+ # @bad
15
+ # Model.find_each { |instance| instance.do_something }
16
+ # @good
17
+ # Model.each_instance { |instance| instance.do_something }
18
+ #
19
+ class FindEach < Cop
20
+ MSG = 'Do not use find_each or find_in_batches, as the keys are non-integer.'.freeze
21
+
22
+ def on_send(node)
23
+ _, method, * = *node
24
+ if method == :find_each || method == :find_in_batches
25
+ add_offense(node, :selector, MSG)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -3,4 +3,5 @@ require_relative 'cop/spbtv/postgres/add_column_with_default'
3
3
  require_relative 'cop/spbtv/postgres/add_column_with_not_null'
4
4
  require_relative 'cop/spbtv/postgres/add_index'
5
5
  require_relative 'cop/spbtv/postgres/change_column'
6
+ require_relative 'cop/spbtv/postgres/find_each'
6
7
  require_relative 'cop/spbtv/multiple_validation'
@@ -1,4 +1,4 @@
1
1
  # Just namespace for version number
2
2
  module SpbtvCodeStyle
3
- VERSION = '1.6.0'.freeze
3
+ VERSION = '1.7.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spbtv_code_style
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tema Bolshakov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop-checkstyle_formatter
@@ -130,6 +130,7 @@ files:
130
130
  - lib/rubocop/cop/spbtv/postgres/add_column_with_not_null.rb
131
131
  - lib/rubocop/cop/spbtv/postgres/add_index.rb
132
132
  - lib/rubocop/cop/spbtv/postgres/change_column.rb
133
+ - lib/rubocop/cop/spbtv/postgres/find_each.rb
133
134
  - lib/rubocop/spbtv.rb
134
135
  - lib/spbtv_code_style.rb
135
136
  - spbtv_code_style.gemspec