simplycop 1.7.5 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +3 -0
- data/.github/workflows/dobby-actions.yml +2 -0
- data/.github/workflows/publish_gem.yml +2 -0
- data/.github/workflows/version_forget_me_not.yml +4 -1
- data/lib/simplycop/custom_cops/variable_name_shadowing_method.rb +32 -0
- data/lib/simplycop/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a29b770b541b2f3a6ef6168c4841716a7252e6177827b53da7ad4a699e3ad2d
|
4
|
+
data.tar.gz: 42d094390b9722d90b9702065b8999ef7e8b1546d5ff4c0b42d8c6f56c664589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: feec480c50cc3710054fd3f20d217bdc77b93f7564037fe71c67920c710b71dff8d4c37813d9f318a48410716acbd8cc5bcdd77c9ac30facd93ba8c80b815310
|
7
|
+
data.tar.gz: '0599f55d176c3f02dedb6b2628a5305f65e179a1c721305a042ab3dfeb8d7244638aaffc49010ebf1b02f3dd2c2e57cf112d05c686d1685ac85c53475432c6af'
|
data/.github/workflows/ci.yml
CHANGED
@@ -6,12 +6,15 @@ on:
|
|
6
6
|
branches:
|
7
7
|
- master
|
8
8
|
types: [opened, synchronize]
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
statuses: write
|
9
12
|
jobs:
|
10
13
|
build:
|
11
14
|
runs-on: ubuntu-18.04
|
12
15
|
|
13
16
|
steps:
|
14
|
-
- uses: simplybusiness/version-forget-me-not@v2
|
17
|
+
- uses: simplybusiness/version-forget-me-not@v2.1.0
|
15
18
|
env:
|
16
19
|
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
17
20
|
VERSION_FILE_PATH: "lib/simplycop/version.rb"
|
@@ -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
|
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.9.1
|
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-
|
11
|
+
date: 2021-12-08 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
|
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
159
|
- !ruby/object:Gem::Version
|
159
160
|
version: '0'
|
160
161
|
requirements: []
|
161
|
-
rubygems_version: 3.2.
|
162
|
+
rubygems_version: 3.2.32
|
162
163
|
signing_key:
|
163
164
|
specification_version: 4
|
164
165
|
summary: Provides a single point of reference for common rubocop rules.
|