bulletmark_repairer 0.1.2 → 0.1.3

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: 533eed3a74c78c89236e5c1355f588814c6a4017cf79af12f0a0e23fe030fcde
4
- data.tar.gz: bf8a718e822ba241ab3299f675db3809870d955257bc5279644285373a619141
3
+ metadata.gz: a7110364b32065ccdce57c9220481a6c3ab36265a1fbc1fcb0d40a5d6a92ceeb
4
+ data.tar.gz: e69d9ae29d6a2f0e013e8d974ac5634e98750c31cf57eacbbbee1ed48778f5ce
5
5
  SHA512:
6
- metadata.gz: a33cc9ba73a76ebca97b8293677d8498761a07c2a6680e5182a65b2d8f7cb6237196506aedee63ed4f798168beb4161072ee5e62cbcee9506c4040e4584a508f
7
- data.tar.gz: 2fb1af553ee13ca638023120306f6284b4d04ae567171616cee658ee5277f1bb33a589d769d7625ad0d6b445d06664a068dc49db479e8ac91934d36aef3553d6
6
+ metadata.gz: 4eb6a1e8d2274100f04d72f544c0dce8588b758216bfbe08968947fc535d7fe3e0fba8f7d722600737c18e52cbe468e0ed2482e48e9d9372ca18c3f66e1c05fa
7
+ data.tar.gz: fe6a169678171236abebdff07cf2adfef7af32066c07656ad327fbb33d692a0b9171c5b418932c653ae4a8c0eb95be823c8d29d2f17423f7fe7d8be663fd5aa2
data/.codespellignore ADDED
File without changes
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ ## [0.1.3] - 2023-10-18
2
+
3
+ - Fix a redundant auto-correct for multiple tests with n+1 queries when running RSpec [#6](https://github.com/makicamel/bulletmark_repairer/pull/6) ([@ydah])
4
+
1
5
  ## [0.1.2] - 2023-10-16
2
6
 
3
- - Reduce dependencies [#1](https://github.com/makicamel/bulletmark_repairer/pull/1) [@tricknotes]()
7
+ - Reduce dependencies [#1](https://github.com/makicamel/bulletmark_repairer/pull/1) ([@tricknotes])
4
8
  - Stop using class instance variables for thread safe [024f6c5](https://github.com/makicamel/bulletmark_repairer/commit/024f6c53f82b182a998c1e43de48d8c6c9ce5bf3)
5
9
 
6
10
  ## [0.1.1] - 2023-10-11
@@ -10,3 +14,6 @@
10
14
  ## [0.1.0] - 2023-10-10
11
15
 
12
16
  - Initial release
17
+
18
+ [@tricknotes]: https://github.com/tricknotes
19
+ [@ydah]: https://github.com/ydah
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulletmarkRepairer
4
- class Configration
4
+ class Configuration
5
5
  attr_accessor :skip_file_list, :logger
6
6
  attr_writer :debug
7
7
 
@@ -22,7 +22,7 @@ module BulletmarkRepairer
22
22
  end
23
23
 
24
24
  def config
25
- @config ||= Configration.new
25
+ @config ||= Configuration.new
26
26
  end
27
27
  end
28
28
  end
@@ -46,10 +46,12 @@ class ControllerCorrector < Parser::TreeRewriter
46
46
  return unless node.respond_to?(:to_sexp_array)
47
47
 
48
48
  type, identifier = node.to_sexp_array.take(2)
49
-
50
49
  if type == :ivasgn && identifier == instance_variable_name
51
- insert_after node.children.last.location.expression, ".includes(#{associations})"
52
- @patched = true
50
+ inserted = ".includes(#{associations})"
51
+ unless node.location.expression.source.include?(inserted)
52
+ insert_after node.children.last.location.expression, inserted
53
+ @patched = true
54
+ end
53
55
  else
54
56
  node
55
57
  .children
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulletmarkRepairer
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulletmark_repairer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - makicamel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2023-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".codespellignore"
76
77
  - ".rspec"
77
78
  - ".rubocop.yml"
78
79
  - CHANGELOG.md
@@ -86,7 +87,6 @@ files:
86
87
  - lib/bulletmark_repairer/associations_builder.rb
87
88
  - lib/bulletmark_repairer/configuration.rb
88
89
  - lib/bulletmark_repairer/controller_corrector.rb
89
- - lib/bulletmark_repairer/corrector.rb
90
90
  - lib/bulletmark_repairer/corrector_builder.rb
91
91
  - lib/bulletmark_repairer/markers.rb
92
92
  - lib/bulletmark_repairer/patcher.rb
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Corrector < Parser::TreeRewriter
4
- def on_def(node)
5
- return if patched?
6
-
7
- node.children.each { |child_node| insert_includes(node: child_node) }
8
- return if patched?
9
-
10
- node.children.each { |child_node| insert_includes_for_vasgn(node: child_node, type: :ivasgn) }
11
- return if patched?
12
-
13
- node.children.each { |child_node| insert_includes_for_vasgn(node: child_node, type: :lvasgn) }
14
- end
15
-
16
- private
17
-
18
- def patched?
19
- @patched ||= false
20
- end
21
-
22
- def insert_includes(node:)
23
- return if patched?
24
- return if !node.respond_to?(:children) || node.children.empty?
25
- return unless node.location.expression.line <= line_no && line_no <= node.location.expression.last_line
26
-
27
- # TODO: Patch Enumerable methods other than each and map
28
- if node.children.last.in?(%i[each map])
29
- insert_after node.children[0].location.expression, ".includes(#{associations})"
30
- @patched = true
31
- else
32
- node.children.each { |child_node| insert_includes(node: child_node) }
33
- end
34
- end
35
-
36
- def insert_includes_for_vasgn(node:, type:)
37
- return if patched?
38
- return if !node.respond_to?(:children) || node.children.empty?
39
- return unless node.location.expression.line <= line_no && line_no <= node.location.expression.last_line
40
-
41
- if node.type == type
42
- insert_after node.children.last.location.expression, ".includes(#{associations})"
43
- @patched = true
44
- else
45
- node.children.each { |child_node| insert_includes_for_vasgn(node: child_node, type: type) }
46
- end
47
- end
48
-
49
- def line_no
50
- __EMBEDDED_LINE_NO__
51
- end
52
-
53
- def associations
54
- '__EMBEDDED_ASSOCIATIONS__'
55
- end
56
- end