simplycop 1.7.4 → 1.9.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: 51da31df3951047a568a81ec7504c1930411afcf0e857b2e65ace63d1f488ac0
4
- data.tar.gz: 85d46a288f0d262dda7ba5d45499af3f7e8091ca74a66631eafae6cb1f140a00
3
+ metadata.gz: 88ed5a7c12b016aa0efc6a92e43929528815b273a23909e4a326f3e1dcff6c66
4
+ data.tar.gz: 24cb00aab9c999085a80b5b4f9f74da88e4e070708ba9427ae4dcb287b5fd889
5
5
  SHA512:
6
- metadata.gz: 5557171cf6f61cfb26ea0cefcb6a3cc8d50bd6310fbdd061bae01e3ff50232a0bc2c8c0316737408baec401ac3e6426b4c82f72e07dd2a5804d56a8a50a67253
7
- data.tar.gz: 6c4f41690117b681f990ed6dc631a5def48e4881b0040ec2f9446b1931e35f61a426a3d0a7205dc63e2f08eb86a699f56a55b140232e5f071a1e75d6b68459b7
6
+ metadata.gz: 6ed0a5a152bdbb61bb03f7d30730732446505019b9b2b36107cd302c3960791fe3b841e4ab7d60ea8c2792aa286bacbc8258d91d8e68473df8065ee5ce1d1388
7
+ data.tar.gz: a7ddf0c5a20dd568d3ce16cb0d11279156b9f7627f0683515ff94b64cb079a941cb4dc8f8623447dcd343c59278819b3dfbc972cb8e2553be9e0ba56ec0c174a
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CustomCops
4
+ class VariableNameShadowingMethod < RuboCop::Cop::Cop
5
+ # For each source file, Rubocop calls on_new_investigation, then walks the abstract syntax
6
+ # tree calling on_foo methods for each "foo" AST node - e.g on_begin, on_def, on_args,
7
+ # on_int, etc.
8
+
9
+ # We need to do two passes over the source so that we can find all the method names before
10
+ # we start looking at the nodes that assign local variables (some methods may be defined
11
+ # _after_ code that assigns shadowing local variables. We do the first one in
12
+ # on_new_investigation
13
+
14
+ def_node_search :method_names, <<~PATTERN
15
+ (:def $_ ...)
16
+ PATTERN
17
+
18
+ def on_new_investigation
19
+ ast = processed_source.ast
20
+ @declared_method_names = ast ? method_names(processed_source.ast).to_a : []
21
+ end
22
+
23
+ def on_lvasgn(node)
24
+ if @declared_method_names.include?(node.name)
25
+ add_offense(
26
+ node,
27
+ message: "Shadowing method name - `#{node.name}`."
28
+ )
29
+ end
30
+ end
31
+ end
32
+ end
@@ -7,5 +7,5 @@
7
7
  #
8
8
 
9
9
  module Simplycop
10
- VERSION = '1.7.4'
10
+ VERSION = '1.9.0'
11
11
  end
data/simplycop.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency 'rubocop', '~> 1.12.1'
21
21
  spec.add_dependency 'rubocop-rails', '~> 2.9.0'
22
22
  spec.add_dependency 'rubocop-rspec', '~> 2.2.0'
23
- spec.add_development_dependency 'bundler'
23
+ spec.add_development_dependency 'bundler', '>= 2.2.15'
24
24
  spec.add_development_dependency 'rake', '>= 12.3.3'
25
25
  spec.add_development_dependency 'rspec', '~> 3.10'
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplycop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.4
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simply Business
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-18 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 2.2.15
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 2.2.15
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +132,7 @@ files:
132
132
  - lib/simplycop/custom_cops/instance_eval.rb
133
133
  - lib/simplycop/custom_cops/method_missing.rb
134
134
  - lib/simplycop/custom_cops/timecop_without_block.rb
135
+ - lib/simplycop/custom_cops/variable_name_shadowing_method.rb
135
136
  - lib/simplycop/security/check_for_vulnerable_code.rb
136
137
  - lib/simplycop/security/csrf_token_validation.rb
137
138
  - lib/simplycop/security/reject_all_requests_local.rb