eager_eye 1.1.8 → 1.1.10

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: b43ce92b9c6437cbf79890d4bac363d23a81c1297429e70bd7d47ffda5c179ef
4
- data.tar.gz: 913b85723206ed1c0b9d193bbad46394ff8bbf4cce6cbacf9b9e33ef6e7f7be3
3
+ metadata.gz: 28c53330ec88bd4b8125e357ad3d11bc3155e6425d7feef88ccf4fd8bec93123
4
+ data.tar.gz: c671ff6c33dd1fef2a0be359452a195ecc5a72b27d534ca09d92c17f1928c89f
5
5
  SHA512:
6
- metadata.gz: d065cbff74e8d0499fc9cd2218b1e0c1ed2629200cb8447b0c9fd53bfc4814c914b942514872cd8b76181f41c773fb50737f108dc954fc58d1ad64cec6469991
7
- data.tar.gz: 21b23f430fecc8a4137e18e55a0c9d0bcfb40ebb7c0c36adaff7c92f86eedec895ec37dd1073b0124199fe43833aed8d04fdc55107e3a1532a726f5c060f6b28
6
+ metadata.gz: 75dd57d12d3b869f4ae9246130de9ae497ec6240f0f81adeaae1d7c2aaf48eed0f5d2626a62ba2f72a0b0adf8d207129322977c60639986881c1cd9fec91ecec
7
+ data.tar.gz: 265a28c9086ae7a215f31f7295b9d48be4882b926718a70029678b7c46d80ef171c308060507670477385cb52fd8aba66d7fac0bc05c1da13cd246e3eab56ed9
data/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.1.10] - 2026-01-12
11
+
12
+ ### Fixed
13
+
14
+ - **CustomMethodQuery False Positive** - Skip `pluck` and `ids` results
15
+ - `Model.pluck(:id).each { |id| ... }` no longer flagged
16
+ - Supports tracking local variable assignments for pluck results
17
+
18
+ ## [1.1.9] - 2026-01-11
19
+
20
+ ### Fixed
21
+
22
+ - **CustomMethodQuery False Positive** - Skip `ActionController::Parameters` and Hash tuple access
23
+ - `params.each { |p| p.last }` no longer flagged (tuple access)
24
+ - `hash.each { |k, v| [k, v].last }` no longer flagged
25
+
10
26
  ## [1.1.8] - 2026-01-10
11
27
 
12
28
  ### Fixed
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  <p align="center">
12
12
  <a href="https://github.com/hamzagedikkaya/eager_eye/actions/workflows/main.yml"><img src="https://github.com/hamzagedikkaya/eager_eye/actions/workflows/main.yml/badge.svg" alt="CI"></a>
13
- <a href="https://rubygems.org/gems/eager_eye"><img src="https://img.shields.io/badge/gem-v1.1.8-red.svg" alt="Gem Version"></a>
13
+ <a href="https://rubygems.org/gems/eager_eye"><img src="https://img.shields.io/badge/gem-v1.1.10-red.svg" alt="Gem Version"></a>
14
14
  <a href="https://github.com/hamzagedikkaya/eager_eye"><img src="https://img.shields.io/badge/coverage-95%25-brightgreen.svg" alt="Coverage"></a>
15
15
  <a href="https://www.ruby-lang.org/"><img src="https://img.shields.io/badge/ruby-%3E%3D%203.1-ruby.svg" alt="Ruby"></a>
16
16
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
@@ -21,8 +21,8 @@ module EagerEye
21
21
  @issues = []
22
22
  @file_path = file_path
23
23
 
24
- find_iteration_blocks(ast) do |block_body, block_var, collection|
25
- is_array_collection = collection_is_array?(collection)
24
+ find_iteration_blocks(ast) do |block_body, block_var, collection, definitions|
25
+ is_array_collection = collection_is_array?(collection, definitions)
26
26
  check_block_for_query_methods(block_body, block_var, is_array_collection)
27
27
  end
28
28
 
@@ -31,15 +31,17 @@ module EagerEye
31
31
 
32
32
  private
33
33
 
34
- def find_iteration_blocks(node, &block)
34
+ def find_iteration_blocks(node, definitions = {}, &block)
35
35
  return unless node.is_a?(Parser::AST::Node)
36
36
 
37
+ definitions[node.children[0]] = node.children[1] if node.type == :lvasgn
38
+
37
39
  if iteration_block?(node)
38
40
  block_var = extract_block_variable(node)
39
41
  block_body = node.children[2]
40
- yield(block_body, block_var, node.children[0]) if block_var && block_body
42
+ yield(block_body, block_var, node.children[0], definitions) if block_var && block_body
41
43
  end
42
- node.children.each { |child| find_iteration_blocks(child, &block) }
44
+ node.children.each { |child| find_iteration_blocks(child, definitions, &block) }
43
45
  end
44
46
 
45
47
  def iteration_block?(node)
@@ -93,15 +95,28 @@ module EagerEye
93
95
  first_arg&.type == :arg ? first_arg.children[0] : nil
94
96
  end
95
97
 
96
- def collection_is_array?(node)
98
+ def collection_is_array?(node, definitions = {})
97
99
  return false unless node.is_a?(Parser::AST::Node)
100
+ return true if %i[array hash].include?(node.type)
101
+ return check_lvar_collection?(node, definitions) if node.type == :lvar
102
+ return check_send_collection?(node, definitions) if node.type == :send
98
103
 
99
- case node.type
100
- when :array then true
101
- when :send then %i[map select collect flat_map to_a uniq compact keys values split
102
- []].include?(node.children[1])
103
- else false
104
- end
104
+ false
105
+ end
106
+
107
+ def check_lvar_collection?(node, definitions)
108
+ return false unless definitions
109
+
110
+ definition = definitions[node.children[0]]
111
+ definition ? collection_is_array?(definition, definitions) : false
112
+ end
113
+
114
+ def check_send_collection?(node, definitions)
115
+ method_name = node.children[1]
116
+ return true if %i[map select collect flat_map to_a uniq compact keys values split []
117
+ params sort pluck ids].include?(method_name)
118
+
119
+ collection_is_array?(node.children[0], definitions)
105
120
  end
106
121
 
107
122
  def receiver_ends_with_hash_array_method?(node)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EagerEye
4
- VERSION = "1.1.8"
4
+ VERSION = "1.1.10"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eager_eye
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - hamzagedikkaya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-01-10 00:00:00.000000000 Z
11
+ date: 2026-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast