inspecstyle 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/inspecstyle/azure_generic_resource.rb +2 -1
- data/lib/rubocop/cop/inspecstyle/deprecated_attributes.rb +2 -1
- data/lib/rubocop/cop/inspecstyle/oracle_db_session_pass.rb +2 -1
- data/lib/rubocop/cop/inspecstyle/shadow_properties.rb +11 -9
- data/lib/rubocop/inspecstyle/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c05d8e13dc59b97ef50ee7e38f9e728dc3e52ade3e648c4dc73241d3f32d60f
|
4
|
+
data.tar.gz: be29a3ae8643a818ef62e7f0a491cc161940b9a675641ae34343cdc082470ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 460c48ff0252cbfff1fb0a1b0245366eba8ae3ed939c03dc418a0561ce9d8d31fc8d9beefaf941fe24ea93f52681057104e6ec8863b58b248399ea1072c7a3dd
|
7
|
+
data.tar.gz: e8bb21c13461a344f7ed3b75ef55634755adb454d0530672024ef8fb60d15fdfb3d0c06aedb60322ca864e7520f88cc65e4913979d5a76051467e3f44dafe49a
|
@@ -8,6 +8,7 @@ module RuboCop
|
|
8
8
|
# @example EnforcedStyle: InSpecStyle (default)
|
9
9
|
# # azure_generic_resource has been deprecated
|
10
10
|
# # 'https://github.com/inspec/inspec/issues/3131'
|
11
|
+
# # Since there are multiples replacements autocorrect is not supported.
|
11
12
|
#
|
12
13
|
# # bad
|
13
14
|
# azure_generic_resource
|
@@ -26,7 +27,7 @@ module RuboCop
|
|
26
27
|
def on_send(node)
|
27
28
|
return unless azure_generic_resource?(node)
|
28
29
|
|
29
|
-
add_offense(node, location:
|
30
|
+
add_offense(node, location: :selector)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -18,7 +18,8 @@ module RuboCop
|
|
18
18
|
class DeprecatedAttributes < Cop
|
19
19
|
include RangeHelp
|
20
20
|
|
21
|
-
MSG = 'Use `#input` instead of `#attribute`.'
|
21
|
+
MSG = 'Use `#input` instead of `#attribute`. This will be removed in '\
|
22
|
+
'InSpec 5'
|
22
23
|
|
23
24
|
def_node_matcher :attribute?, <<~PATTERN
|
24
25
|
(send nil? :attribute ...)
|
@@ -14,7 +14,8 @@ module RuboCop
|
|
14
14
|
# sql = oracledb_session(user: 'my_user', password: 'password')
|
15
15
|
class OracleDbSessionPass < Cop
|
16
16
|
include MatchRange
|
17
|
-
MSG = 'Use `:password` instead of `:pass`.'
|
17
|
+
MSG = 'Use `:password` instead of `:pass`. This will be removed in '\
|
18
|
+
'InSpec 5'
|
18
19
|
|
19
20
|
def_node_matcher :oracledb_session_pass?, <<~PATTERN
|
20
21
|
(send _ :oracledb_session
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# NOTE TO SELF - this one
|
3
|
+
# NOTE TO SELF - this one works BUT not if other its statements are defined. Needs
|
4
|
+
# to work in any arrangement. This is a powerful one to crack as this pattern
|
5
|
+
# will be used in a LOT of other cops.
|
4
6
|
|
5
7
|
module RuboCop
|
6
8
|
module Cop
|
@@ -27,8 +29,8 @@ module RuboCop
|
|
27
29
|
# See https://github.com/rubocop-hq/rubocop-ast/blob/master/lib/rubocop/node_pattern.rb
|
28
30
|
#
|
29
31
|
# For example
|
30
|
-
MSG = 'Use
|
31
|
-
|
32
|
+
MSG = 'Use `:%<modifier>ss` instead of `:%<modifier>s` as a property ' \
|
33
|
+
'for the `shadow` resource. This property will be removed in InSpec 5'
|
32
34
|
|
33
35
|
def_node_matcher :shadow_resource_user_property?, <<~PATTERN
|
34
36
|
(block
|
@@ -41,17 +43,17 @@ module RuboCop
|
|
41
43
|
PATTERN
|
42
44
|
|
43
45
|
def on_block(node)
|
44
|
-
return unless shadow_resource_user_property?(node) do |
|
45
|
-
|
46
|
-
|
47
|
-
add_offense(node, message: message
|
46
|
+
return unless shadow_resource_user_property?(node) do |modifier|
|
47
|
+
message = format(MSG, modifier: modifier)
|
48
|
+
range = locate_range(modifier, node)
|
49
|
+
add_offense(node, message: message, location: range)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
51
53
|
private
|
52
54
|
|
53
|
-
def
|
54
|
-
|
55
|
+
def locate_range(modifier, node)
|
56
|
+
node.children.find { |child| child.type == :block }.children.first.children.find{|x| x == s(:str, modifier)}.source_range
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|