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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb076b244e5088e7e791398f5eb97c1e4605cfb1884f16926c77b950ff0227de
4
- data.tar.gz: a5fa8c99dc4df14eb42e1af6af351e96cece0b8e3a38b06cad1b42cca7f9e124
3
+ metadata.gz: 9c05d8e13dc59b97ef50ee7e38f9e728dc3e52ade3e648c4dc73241d3f32d60f
4
+ data.tar.gz: be29a3ae8643a818ef62e7f0a491cc161940b9a675641ae34343cdc082470ec2
5
5
  SHA512:
6
- metadata.gz: 0a2ff04f4194cae59aec606787a481529430883636c19d10324de5d45e579e842fe29ef5a8ecf2f67e6b61e2eb722d28bde84cc2c6ac073eebb8954fc16895ab
7
- data.tar.gz: 3ced9b66232704943c40220b303ecefd7fd58d39b35c00d753d71f95e566ca9574dfff0bd8e7d60f3c2663503dafe1e88dc0d50bedec04555cb184960e30af90
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: node.loc.selector)
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 isn't currently working even though my pattern works in Rubocop's bin/console
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 `#users` instead of `#user`. This property will be removed '\
31
- 'in InSpec 5'
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 |result|
45
- require 'pry'
46
- # binding.pry
47
- add_offense(node, message: message(result))
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 message(result)
54
- MSG #
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
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module InSpecStyle
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspecstyle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Schwaderer