spektr 0.5.4 → 0.5.5

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: 3856f34c87bf7f347c90149e5cc0a824e68d80df6c6a4704a204e4862ea3e54b
4
- data.tar.gz: f0c98f054f09841c3de0e7f756c80537b5d0a409a2fe0a70d555b63715958691
3
+ metadata.gz: b3f2e35ede68f8a611ce58a5ad3a4fc251e3d18191b9f1bc7fb314666d789063
4
+ data.tar.gz: 908740bb4515316fa1c5a69a0b583ea282251a3483fc33a704f83e63521fe249
5
5
  SHA512:
6
- metadata.gz: fb99134225086acbaab6417f03594c7cb1b44893bdd413faf5056d3990afdd8e6bea3812c6a5a61344fc518e7d47b78bdbe49dfdb49e75722f6c5303df43101a
7
- data.tar.gz: 7c20a2d6f2ec1a7c1a5e006b2ce4bb41e527a55fae099fd66d4e120f7fdffd9c6849496269abd998226f303b4602b5ac23b703a8be448abcd851a4f25bdb974a
6
+ metadata.gz: f92ec1f4949da94bad355d9062b825fbb96480bdf6fe9fb424a421afbaa132cae4b9d0313d0f7af902e25b6ac6141ddc871ecd01cc8f4e4118bd0e7082f362d3
7
+ data.tar.gz: b6e240e0449e4fb858ae591aaeec936a18502741e105b56b30f00c05c6286a7ce690cfb3ae7d66ce07c5f53c64eb8f6bff55420b0f016d2764d30cba5bb090eb
data/CHANGELOG.md CHANGED
@@ -2,11 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.5.5
6
+
7
+ * fix false positives
8
+
5
9
  ## 0.5.4
6
10
 
7
11
  * more parser fixes
8
12
 
9
-
10
13
  ## 0.5.3
11
14
 
12
15
  * parser fixes
@@ -106,10 +106,10 @@ module Spektr
106
106
  node.body.body.each do |item|
107
107
  return user_input? item
108
108
  end
109
- when :string_node, :symbol_node, :constant_read_node, :integer_node, :true_node, :constant_path_node, :nil_node, :true_node, :false_node, :self_node, :global_variable_read_node, :and_node
109
+ when :string_node, :symbol_node, :constant_read_node, :integer_node, :constant_path_node, :nil_node, :true_node, :false_node, :self_node, :global_variable_read_node
110
110
  # do nothing
111
111
  else
112
- Spektr::Logger.debug "Unknown argument type #{node.type.inspect} #{node.inspect}"
112
+ ::Spektr.logger.debug "Unknown argument type #{node.type.inspect} #{node.inspect}"
113
113
  end
114
114
  false
115
115
  end
@@ -199,7 +199,7 @@ module Spektr
199
199
  when :string_node, :symbol_node, :integer_node, :constant_path_node, :nil_node, :true_node, :false_node, :self_node, :global_variable_read_node
200
200
  # do nothing
201
201
  else
202
- Spektr::Logger.debug "Unknown argument type #{node.type}"
202
+ Spektr.logger.debug "Unknown argument type #{node.type}"
203
203
  end
204
204
  end
205
205
 
@@ -23,13 +23,20 @@ module Spektr
23
23
  argument = call.arguments&.arguments&.first
24
24
  next if argument.nil?
25
25
  ::Spektr.logger.debug "Mass assignment check at #{call.location.start_line}"
26
- if user_input?(argument)
27
- # we check for permit! separately
28
- next if argument.respond_to?(:name) && argument.name == :permit!
29
- # check for permit with arguments
30
- next if argument.respond_to?(:name) && argument.name == :permit && argument.arguments
31
- warn! @target, self, call.location, "Mass assignment"
26
+ next unless user_input?(argument)
27
+ if argument.type == :local_variable_read_node
28
+ variable = @target.lvars.find do |n|
29
+ n.name == argument.name
30
+ end
31
+ param = variable.value
32
+ else
33
+ param = argument
32
34
  end
35
+ # we check for permit! separately
36
+ next if param.respond_to?(:name) && param.name == :permit!
37
+ # check for permit with arguments
38
+ next if param.respond_to?(:name) && param.name == :permit && param.arguments
39
+ warn! @target, self, call.location, "Mass assignment"
33
40
  end
34
41
  @target.find_calls(:permit!).each do |call|
35
42
  unless call.arguments
@@ -19,7 +19,9 @@ module Spektr
19
19
 
20
20
  ].each do |m|
21
21
  @target.find_calls(m).each do |call|
22
- check_argument(call.arguments&.arguments&.first, m, call)
22
+ arguments = call.arguments&.arguments&.first
23
+ next if arguments && arguments.type == :keyword_hash_node
24
+ check_argument(arguments, m, call)
23
25
  end
24
26
  end
25
27
  [:calculate].each do |m|
@@ -1,3 +1,3 @@
1
1
  module Spektr
2
- VERSION = '0.5.4'
2
+ VERSION = '0.5.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spektr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Molnar