simplycop 1.7.5 → 1.8.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7186eac4e8a769e55cefe3738cfbf45c967a6b2aab0f4744191d92b932175ea7
|
4
|
+
data.tar.gz: 604182eff86928d921da2831b08a1bb880b1a21660a252610619012f7059fa34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0be2768aceb033e5625ebd342c86c1ae8cbe356d348f8ad27d7cd9ef9d9faecb78907ff4a6f17f6369eade666f99b8e1697a35143b43b768b7ef73609024de0b
|
7
|
+
data.tar.gz: 0a09ff8fccde37b4b8f9eea6241a2c64ca76e5a775f34777eebfb7eda8751ec7471c7d080319d1cd420c67f28cf386a220f4870435b0b8d059a5ef8f6119aa37
|
data/.custom_simplycop.yml
CHANGED
@@ -0,0 +1,31 @@
|
|
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
|
+
@declared_method_names = method_names(processed_source.ast).to_a
|
20
|
+
end
|
21
|
+
|
22
|
+
def on_lvasgn(node)
|
23
|
+
if @declared_method_names.include?(node.name)
|
24
|
+
add_offense(
|
25
|
+
node,
|
26
|
+
message: "Shadowing method name - `#{node.name}`."
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/simplycop/version.rb
CHANGED
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.
|
4
|
+
version: 1.8.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-
|
11
|
+
date: 2021-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -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
|