puppet-lint-no_chaining_arrows-check 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7c8658a8b1133c39c0688ca268245e146fb1f88d
4
+ data.tar.gz: cea1663c148890be6d75bc85526c2baa085115ea
5
+ SHA512:
6
+ metadata.gz: 7d5d004d080718bec4475f0cd1f5de699ec6bc8d98d4dbda9481200db0999aa9bd9fea626757be62bc7a7ef1eac0d7fbdb8ce23508e19205a7ffe3aa1c4699dc
7
+ data.tar.gz: 34b3287d0091db0f8c92783e9ac4d8a36c8fd03b29600f985469ffd1357e1b30df7a66c14e9d9faae532a60a9da624b2ae706bcdbe268224f1929e320ca2faf9
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Dean Wilson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,65 @@
1
+ # puppet-lint no chaining arrows check
2
+
3
+ Extends puppet-lint to issue warnings if any chaining arrows
4
+ (`->`, `~>`, `<-`, `<~`) are found.
5
+
6
+ [![Build Status](https://travis-ci.org/deanwilson/puppet-lint-no_chaining_arrows-check.svg?branch=master)](https://travis-ci.org/deanwilson/puppet-lint-no_chaining_arrows-check)
7
+
8
+ Although puppet-lint has the included
9
+ [Right To Left Relationship](http://puppet-lint.com/checks/right_to_left_relationship/)
10
+ check I wanted one that went further and warned on any use of chaining
11
+ arrows. In my puppet code I'd rather have resources connected with
12
+ parameters, such as `require` and `notify`. I also find the indentation nicer
13
+ without the `type` being offset by the arrow.
14
+
15
+ ```puppet
16
+
17
+ # I think this -
18
+ file { '/tmp/foo':
19
+ content => 'foo',
20
+ require => Class['bar'],
21
+ ...
22
+ }
23
+
24
+ # - looks nicer than this
25
+ -> file { '/tmp/foo':
26
+ content => 'foo',
27
+ ...
28
+ }
29
+ ```
30
+
31
+ This plugin has one side effect, it disables the
32
+ [Right To Left Relationship](http://puppet-lint.com/checks/right_to_left_relationship/)
33
+ check that produces
34
+
35
+ WARNING: right-to-left (<-) relationship on line $foo
36
+
37
+ This is to ensure that some relationships, specified with
38
+ `<-` and `<~`, are not reported twice.
39
+
40
+ ## Installation
41
+
42
+ To use this plugin add the following line to your Gemfile
43
+
44
+ gem 'puppet-lint-no_chaining_arrows-check'
45
+
46
+ and then run `bundle install`.
47
+
48
+ ## Usage
49
+
50
+ This plugin provides a new check to `puppet-lint`.
51
+
52
+ WARNING: chaining arrow found on line 3
53
+
54
+ ## Other puppet-lint plugins
55
+
56
+ You can find a list of my `puppet-lint` plugins in the
57
+ [unixdaemon puppet-lint-plugins](https://github.com/deanwilson/unixdaemon-puppet-lint-plugins) repo.
58
+
59
+ ### Author
60
+
61
+ [Dean Wilson](https://www.unixdaemon.net)
62
+
63
+ ### License
64
+
65
+ * MIT
@@ -0,0 +1,19 @@
1
+ PuppetLint.new_check(:no_chaining_arrows) do
2
+
3
+ # stop puppet-lint raising its own arrow check
4
+ # this way we don't get two warnings on <- and <~
5
+ PuppetLint.configuration.send('disable_right_to_left_relationship')
6
+
7
+ def check
8
+ arrow_tokens = [:OUT_EDGE, :OUT_EDGE_SUB, :IN_EDGE, :IN_EDGE_SUB]
9
+
10
+ tokens.select { |r| arrow_tokens.include? r.type }.each do |token|
11
+ notify(
12
+ :warning,
13
+ :message => 'chaining arrow found',
14
+ :line => token.line,
15
+ :column => token.column
16
+ )
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'no_chaining_arrows' do
4
+ let(:msg) { 'chaining arrow found' }
5
+
6
+ %w[-> ~> <- <~].each do |op|
7
+ context "chaining resources with #{op}" do
8
+ let(:code) { "Class[foo] #{op} Class[bar]" }
9
+
10
+ it 'should only detect a single problem' do
11
+ expect(problems).to have(1).problem
12
+ end
13
+
14
+ it 'should create a warning' do
15
+ expect(problems).to contain_warning(msg).on_line(1).in_column(12)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ require 'puppet-lint'
2
+
3
+ PuppetLint::Plugins.load_spec_helper
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-lint-no_chaining_arrows-check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dean Wilson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: puppet-lint
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 3.5.0
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 3.5.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec-its
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec-collection_matchers
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.47.1
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.47.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 11.2.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 11.2.0
103
+ - !ruby/object:Gem::Dependency
104
+ name: rspec-json_expectations
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.4'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '1.4'
117
+ - !ruby/object:Gem::Dependency
118
+ name: simplecov
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ description: |2
132
+ Extends puppet-lint to issue warnings if any chaining arrows
133
+ ('->', '~>', '<-', '<~') are found.
134
+ email: dean.wilson@gmail.com
135
+ executables: []
136
+ extensions: []
137
+ extra_rdoc_files: []
138
+ files:
139
+ - LICENSE
140
+ - README.md
141
+ - lib/puppet-lint/plugins/no_chaining_arrows.rb
142
+ - spec/puppet-lint/plugins/puppet-lint-no_chaining_arrows_spec.rb
143
+ - spec/spec_helper.rb
144
+ homepage: https://github.com/deanwilson/puppet-lint-no_chaining_arrows-check
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.6.11
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: puppet-lint no_chaining_arrows check
168
+ test_files:
169
+ - spec/spec_helper.rb
170
+ - spec/puppet-lint/plugins/puppet-lint-no_chaining_arrows_spec.rb