danger-puppet_lint 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +88 -0
- data/.travis.yml +20 -0
- data/.yardoc/checksums +4 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +149 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +23 -0
- data/danger-puppet_lint.gemspec +52 -0
- data/lib/danger_plugin.rb +1 -0
- data/lib/danger_puppet_lint.rb +1 -0
- data/lib/puppet_lint/gem_version.rb +3 -0
- data/lib/puppet_lint/plugin.rb +80 -0
- data/spec/puppet_lint_spec.rb +35 -0
- data/spec/spec_helper.rb +62 -0
- data/spec/test_empty_summary.report +0 -0
- data/spec/test_summary.report +22 -0
- metadata +226 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a2b94a098586d9ee1c75ce00d35c1de14e9543b4
|
4
|
+
data.tar.gz: 189db5d9e0b2b1e60d1334c673b6af84f3cc42a3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1537882e384648e7e84e48faa74ab9d070483de4d2c85f3deec79c6d39a98ed12d2febe86c438aac6cd36877ea12f076a89f08726d8b4772cc0e2e3373f2ec96
|
7
|
+
data.tar.gz: 4739fa20f2ab6bd99784043e514f1caa92ba7d83a38528ee7c2ba3137ed7e1cb4c2ea666d6fad07976a14dc2d45ff68b1c20904f1bb200b34eb32cc0d5eb8879
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# kind_of? is a good way to check a type
|
2
|
+
Style/ClassCheck:
|
3
|
+
EnforcedStyle: kind_of?
|
4
|
+
|
5
|
+
# It's better to be more explicit about the type
|
6
|
+
Style/BracesAroundHashParameters:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
# specs sometimes have useless assignments, which is fine
|
10
|
+
Lint/UselessAssignment:
|
11
|
+
Exclude:
|
12
|
+
- '**/spec/**/*'
|
13
|
+
|
14
|
+
# HoundCI doesn't like this rule
|
15
|
+
Style/DotPosition:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
Lint/UnusedBlockArgument:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
# We want to allow class Fastlane::Class
|
23
|
+
Style/ClassAndModuleChildren:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Metrics/AbcSize:
|
27
|
+
Max: 60
|
28
|
+
|
29
|
+
# The %w might be confusing for new users
|
30
|
+
Style/WordArray:
|
31
|
+
MinSize: 19
|
32
|
+
|
33
|
+
# raise and fail are both okay
|
34
|
+
Style/SignalException:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
# Better too much 'return' than one missing
|
38
|
+
Style/RedundantReturn:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
# Having if in the same line might not always be good
|
42
|
+
Style/IfUnlessModifier:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
# Configuration parameters: CountComments.
|
46
|
+
Metrics/ClassLength:
|
47
|
+
Max: 320
|
48
|
+
|
49
|
+
Metrics/CyclomaticComplexity:
|
50
|
+
Max: 17
|
51
|
+
|
52
|
+
# Configuration parameters: AllowURI, URISchemes.
|
53
|
+
Metrics/LineLength:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# Configuration parameters: CountKeywordArgs.
|
57
|
+
Metrics/ParameterLists:
|
58
|
+
Max: 10
|
59
|
+
|
60
|
+
Metrics/PerceivedComplexity:
|
61
|
+
Max: 18
|
62
|
+
|
63
|
+
# Sometimes it's easier to read without guards
|
64
|
+
Style/GuardClause:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
# something = if something_else
|
68
|
+
# that's confusing
|
69
|
+
Style/ConditionalAssignment:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
# Better to have too much self than missing a self
|
73
|
+
Style/RedundantSelf:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Metrics/MethodLength:
|
77
|
+
Max: 60
|
78
|
+
|
79
|
+
Metrics/BlockLength:
|
80
|
+
Max: 50
|
81
|
+
|
82
|
+
# We're not there yet
|
83
|
+
Style/Documentation:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
# Adds complexity
|
87
|
+
Style/IfInsideElse:
|
88
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache:
|
3
|
+
directories:
|
4
|
+
- bundle
|
5
|
+
|
6
|
+
before_install:
|
7
|
+
- gem update --system
|
8
|
+
- gem install bundler
|
9
|
+
|
10
|
+
sudo: false
|
11
|
+
|
12
|
+
rvm:
|
13
|
+
- 2.0.0
|
14
|
+
- 2.1.10
|
15
|
+
- 2.2.6
|
16
|
+
- 2.3.3
|
17
|
+
- 2.4.0
|
18
|
+
|
19
|
+
script:
|
20
|
+
- bundle exec rake spec
|
data/.yardoc/checksums
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
/Users/patrick/Developer/danger-puppet_lint/lib/danger_plugin.rb 346ce1ac8177427c62f1144e41d657f0f8624a88
|
2
|
+
/Users/patrick/Developer/danger-puppet_lint/lib/danger_puppet_lint.rb 1308caa9b4514d2dd3ade6cbc41c493122bf7bb0
|
3
|
+
/Users/patrick/Developer/danger-puppet_lint/lib/puppet_lint/gem_version.rb 389cb59090e9eaee1880f66bf4688668529c211d
|
4
|
+
/Users/patrick/Developer/danger-puppet_lint/lib/puppet_lint/plugin.rb ec31dd7511a2928934af5d66270b023343727a58
|
data/.yardoc/complete
ADDED
File without changes
|
Binary file
|
Binary file
|
data/.yardoc/proxy_types
ADDED
Binary file
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
danger-puppet_lint (1.0.0)
|
5
|
+
danger-plugin-api (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.5.1)
|
11
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
12
|
+
ast (2.3.0)
|
13
|
+
claide (1.0.1)
|
14
|
+
claide-plugins (0.9.2)
|
15
|
+
cork
|
16
|
+
nap
|
17
|
+
open4 (~> 1.3)
|
18
|
+
coderay (1.1.1)
|
19
|
+
colored2 (3.1.2)
|
20
|
+
cork (0.3.0)
|
21
|
+
colored2 (~> 3.1)
|
22
|
+
coveralls (0.8.20)
|
23
|
+
json (>= 1.8, < 3)
|
24
|
+
simplecov (~> 0.14.1)
|
25
|
+
term-ansicolor (~> 1.3)
|
26
|
+
thor (~> 0.19.4)
|
27
|
+
tins (~> 1.6)
|
28
|
+
danger (4.3.5)
|
29
|
+
claide (~> 1.0)
|
30
|
+
claide-plugins (>= 0.9.2)
|
31
|
+
colored2 (~> 3.1)
|
32
|
+
cork (~> 0.1)
|
33
|
+
faraday (~> 0.9)
|
34
|
+
faraday-http-cache (~> 1.0)
|
35
|
+
git (~> 1)
|
36
|
+
kramdown (~> 1.5)
|
37
|
+
octokit (~> 4.2)
|
38
|
+
terminal-table (~> 1)
|
39
|
+
danger-plugin-api (1.0.0)
|
40
|
+
danger (> 2.0)
|
41
|
+
diff-lcs (1.3)
|
42
|
+
docile (1.1.5)
|
43
|
+
faraday (0.12.0.1)
|
44
|
+
multipart-post (>= 1.2, < 3)
|
45
|
+
faraday-http-cache (1.3.1)
|
46
|
+
faraday (~> 0.8)
|
47
|
+
ffi (1.9.18)
|
48
|
+
formatador (0.2.5)
|
49
|
+
git (1.3.0)
|
50
|
+
guard (2.14.1)
|
51
|
+
formatador (>= 0.2.4)
|
52
|
+
listen (>= 2.7, < 4.0)
|
53
|
+
lumberjack (~> 1.0)
|
54
|
+
nenv (~> 0.1)
|
55
|
+
notiffany (~> 0.0)
|
56
|
+
pry (>= 0.9.12)
|
57
|
+
shellany (~> 0.0)
|
58
|
+
thor (>= 0.18.1)
|
59
|
+
guard-compat (1.2.1)
|
60
|
+
guard-rspec (4.7.3)
|
61
|
+
guard (~> 2.1)
|
62
|
+
guard-compat (~> 1.1)
|
63
|
+
rspec (>= 2.99.0, < 4.0)
|
64
|
+
json (2.0.4)
|
65
|
+
kramdown (1.13.2)
|
66
|
+
listen (3.0.7)
|
67
|
+
rb-fsevent (>= 0.9.3)
|
68
|
+
rb-inotify (>= 0.9.7)
|
69
|
+
lumberjack (1.0.11)
|
70
|
+
method_source (0.8.2)
|
71
|
+
multipart-post (2.0.0)
|
72
|
+
nap (1.1.0)
|
73
|
+
nenv (0.3.0)
|
74
|
+
notiffany (0.1.1)
|
75
|
+
nenv (~> 0.1)
|
76
|
+
shellany (~> 0.0)
|
77
|
+
octokit (4.7.0)
|
78
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
79
|
+
open4 (1.3.4)
|
80
|
+
parser (2.4.0.0)
|
81
|
+
ast (~> 2.2)
|
82
|
+
powerpack (0.1.1)
|
83
|
+
pry (0.10.4)
|
84
|
+
coderay (~> 1.1.0)
|
85
|
+
method_source (~> 0.8.1)
|
86
|
+
slop (~> 3.4)
|
87
|
+
public_suffix (2.0.5)
|
88
|
+
rainbow (2.2.1)
|
89
|
+
rake (10.5.0)
|
90
|
+
rb-fsevent (0.9.8)
|
91
|
+
rb-inotify (0.9.8)
|
92
|
+
ffi (>= 0.5.0)
|
93
|
+
rspec (3.5.0)
|
94
|
+
rspec-core (~> 3.5.0)
|
95
|
+
rspec-expectations (~> 3.5.0)
|
96
|
+
rspec-mocks (~> 3.5.0)
|
97
|
+
rspec-core (3.5.4)
|
98
|
+
rspec-support (~> 3.5.0)
|
99
|
+
rspec-expectations (3.5.0)
|
100
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
101
|
+
rspec-support (~> 3.5.0)
|
102
|
+
rspec-mocks (3.5.0)
|
103
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
104
|
+
rspec-support (~> 3.5.0)
|
105
|
+
rspec-support (3.5.0)
|
106
|
+
rubocop (0.48.1)
|
107
|
+
parser (>= 2.3.3.1, < 3.0)
|
108
|
+
powerpack (~> 0.1)
|
109
|
+
rainbow (>= 1.99.1, < 3.0)
|
110
|
+
ruby-progressbar (~> 1.7)
|
111
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
112
|
+
ruby-progressbar (1.8.1)
|
113
|
+
sawyer (0.8.1)
|
114
|
+
addressable (>= 2.3.5, < 2.6)
|
115
|
+
faraday (~> 0.8, < 1.0)
|
116
|
+
shellany (0.0.1)
|
117
|
+
simplecov (0.14.1)
|
118
|
+
docile (~> 1.1.0)
|
119
|
+
json (>= 1.8, < 3)
|
120
|
+
simplecov-html (~> 0.10.0)
|
121
|
+
simplecov-html (0.10.0)
|
122
|
+
slop (3.6.0)
|
123
|
+
term-ansicolor (1.5.0)
|
124
|
+
tins (~> 1.0)
|
125
|
+
terminal-table (1.7.3)
|
126
|
+
unicode-display_width (~> 1.1.1)
|
127
|
+
thor (0.19.4)
|
128
|
+
tins (1.13.2)
|
129
|
+
unicode-display_width (1.1.3)
|
130
|
+
yard (0.9.8)
|
131
|
+
|
132
|
+
PLATFORMS
|
133
|
+
ruby
|
134
|
+
|
135
|
+
DEPENDENCIES
|
136
|
+
bundler (~> 1.3)
|
137
|
+
coveralls
|
138
|
+
danger-puppet_lint!
|
139
|
+
guard (~> 2.14)
|
140
|
+
guard-rspec (~> 4.7)
|
141
|
+
listen (= 3.0.7)
|
142
|
+
pry
|
143
|
+
rake (~> 10.0)
|
144
|
+
rspec (~> 3.4)
|
145
|
+
rubocop (~> 0.41)
|
146
|
+
yard (~> 0.8)
|
147
|
+
|
148
|
+
BUNDLED WITH
|
149
|
+
1.14.6
|
data/Guardfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# A guardfile for making Danger Plugins
|
2
|
+
# For more info see https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
# To run, use `bundle exec guard`.
|
5
|
+
|
6
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
7
|
+
require 'guard/rspec/dsl'
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
9
|
+
|
10
|
+
# RSpec files
|
11
|
+
rspec = dsl.rspec
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_files)
|
15
|
+
|
16
|
+
# Ruby files
|
17
|
+
ruby = dsl.ruby
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
19
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2017 Patrick Butkiewicz <patrick@intrepid.io>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# danger-puppet_lint
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/IntrepidPursuits/danger-puppet_lint.svg?branch=master)](https://travis-ci.org/IntrepidPursuits/danger-puppet_lint)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/github/IntrepidPursuits/danger-puppet_lint/badge.svg?branch=master)](https://coveralls.io/github/IntrepidPursuits/danger-puppet_lint?branch=master)
|
5
|
+
![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)
|
6
|
+
|
7
|
+
A [Danger](http://danger.systems/) plugin that shows the static analysis output generated by [Puppet-Lint](https://puppet-lint.com).
|
8
|
+
|
9
|
+
To use this plugin, you need to generate a report file using [Puppet-Lint](https://puppet-lint.com) for this plugin to read.
|
10
|
+
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
$ gem install danger-puppet_lint
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
Somewhere in your build process, call puppet-lint and pipe it's output into a report file.
|
19
|
+
|
20
|
+
puppet-lint ./ > puppet.report
|
21
|
+
|
22
|
+
At a minimum, add this line to your `Dangerfile`:
|
23
|
+
|
24
|
+
danger-puppet_lint.report 'puppet.report'
|
25
|
+
|
26
|
+
You can also set a different project root if you need to
|
27
|
+
|
28
|
+
# Set a different project root
|
29
|
+
danger-puppet_lint.project_root = 'MyProject/NewRoot/'
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
1. Clone this repo
|
34
|
+
2. Run `bundle install` to setup dependencies.
|
35
|
+
3. Run `bundle exec rake spec` to run the tests.
|
36
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
37
|
+
5. Make your changes.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:specs)
|
6
|
+
|
7
|
+
task default: :specs
|
8
|
+
|
9
|
+
task :spec do
|
10
|
+
Rake::Task['specs'].invoke
|
11
|
+
Rake::Task['rubocop'].invoke
|
12
|
+
Rake::Task['spec_docs'].invoke
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run RuboCop on the lib/specs directory'
|
16
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
17
|
+
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Ensure that the plugin passes `danger plugins lint`'
|
21
|
+
task :spec_docs do
|
22
|
+
sh 'bundle exec danger plugins lint'
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'puppet_lint/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'danger-puppet_lint'
|
8
|
+
spec.version = PuppetLint::VERSION
|
9
|
+
spec.authors = ['Patrick Butkiewicz']
|
10
|
+
spec.email = ['patrick@intrepid.io']
|
11
|
+
spec.description = %q{Shows formatted puppet lint violations using Danger}
|
12
|
+
spec.summary = %q{Reads puppet-lint output files and reports them using Danger}
|
13
|
+
spec.homepage = 'https://github.com/IntrepidPursuits/danger-puppet_lint'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
22
|
+
|
23
|
+
# General ruby development
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
|
27
|
+
# Testing support
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
29
|
+
|
30
|
+
# Linting code and docs
|
31
|
+
spec.add_development_dependency "rubocop", "~> 0.41"
|
32
|
+
spec.add_development_dependency "yard", "~> 0.8"
|
33
|
+
|
34
|
+
# Makes testing easy via `bundle exec guard`
|
35
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
36
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
37
|
+
|
38
|
+
# If you want to work on older builds of ruby
|
39
|
+
spec.add_development_dependency 'listen', '3.0.7'
|
40
|
+
|
41
|
+
# Coveralls support
|
42
|
+
spec.add_development_dependency 'coveralls'
|
43
|
+
|
44
|
+
# This gives you the chance to run a REPL inside your tests
|
45
|
+
# via:
|
46
|
+
#
|
47
|
+
# require 'pry'
|
48
|
+
# binding.pry
|
49
|
+
#
|
50
|
+
# This will stop test execution and let you inspect the results
|
51
|
+
spec.add_development_dependency 'pry'
|
52
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'puppet_lint/plugin'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'puppet_lint/gem_version'
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Danger
|
2
|
+
# Shows linter errors and warnings from puppet_lint
|
3
|
+
# You'll need [puppet-lint](https://http://puppet-lint.com/) installed and
|
4
|
+
# generating a report file to use this plugin
|
5
|
+
#
|
6
|
+
# @example Showing summary
|
7
|
+
#
|
8
|
+
# puppet-lint ./ > puppet-lint.report
|
9
|
+
# danger-puppet_lint.report 'puppet-lint.report'
|
10
|
+
#
|
11
|
+
#
|
12
|
+
# @see IntrepidPursuits/danger-puppet_lint
|
13
|
+
# @tags puppet, lint, configuration
|
14
|
+
#
|
15
|
+
class DangerPuppetLint < Plugin
|
16
|
+
# The project root, which will be used to make the paths relative.
|
17
|
+
# Defaults to `pwd`.
|
18
|
+
# @return [String] project_root value
|
19
|
+
attr_accessor :project_root
|
20
|
+
|
21
|
+
# Defines if the test summary will be sticky or not.
|
22
|
+
# Defaults to `false`.
|
23
|
+
# @return [Boolean] sticky
|
24
|
+
attr_accessor :sticky_summary
|
25
|
+
|
26
|
+
def project_root
|
27
|
+
root = @project_root || Dir.pwd
|
28
|
+
root += '/' unless root.end_with? '/'
|
29
|
+
root
|
30
|
+
end
|
31
|
+
|
32
|
+
def sticky_summary
|
33
|
+
@sticky_summary || false
|
34
|
+
end
|
35
|
+
|
36
|
+
# Reads a puppet-lint summary file and reports it.
|
37
|
+
#
|
38
|
+
# @param [String] file_path Path for puppet-lint report.
|
39
|
+
# @return [void]
|
40
|
+
def report(file_path)
|
41
|
+
raise 'Summary file not found' unless File.file?(file_path)
|
42
|
+
run_summary(file_path)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def run_summary(report_file)
|
48
|
+
warning_count = 0
|
49
|
+
error_count = 0
|
50
|
+
|
51
|
+
# Read line-by-line to determine violations
|
52
|
+
File.readlines(report_file).each do |line|
|
53
|
+
if line.index('WARNING:').nil? == false
|
54
|
+
warning_count += 1
|
55
|
+
warn(format_violation(line), sticky: false)
|
56
|
+
elsif line.index('ERROR:').nil? == false
|
57
|
+
error_count += 1
|
58
|
+
fail(format_violation(line), sticky: false)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Record the summary
|
63
|
+
message(summary_message(warning_count, error_count), sticky: sticky_summary)
|
64
|
+
end
|
65
|
+
|
66
|
+
def summary_message(warning_count, error_count)
|
67
|
+
violations = warning_count + error_count
|
68
|
+
|
69
|
+
"Puppet-Lint Summary: Found #{violations} violations. #{warning_count}
|
70
|
+
Warnings and #{error_count} Errors."
|
71
|
+
end
|
72
|
+
|
73
|
+
# A method that returns a formatted string for a violation
|
74
|
+
# @return String
|
75
|
+
#
|
76
|
+
def format_violation(violation)
|
77
|
+
violation.to_s
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
describe Danger::DangerPuppetLint do
|
5
|
+
it 'should be a plugin' do
|
6
|
+
expect(Danger::DangerPuppetLint.new(nil)).to be_a Danger::Plugin
|
7
|
+
end
|
8
|
+
|
9
|
+
#
|
10
|
+
# You should test your custom attributes and methods here
|
11
|
+
#
|
12
|
+
describe 'with Dangerfile' do
|
13
|
+
before do
|
14
|
+
@dangerfile = testing_dangerfile
|
15
|
+
@my_plugin = @dangerfile.puppet_lint
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'Parses file with warnings and errors' do
|
19
|
+
path = File.expand_path('../test_summary.report', __FILE__)
|
20
|
+
@my_plugin.report(path)
|
21
|
+
expect(@dangerfile.status_report[:errors].length).to be == 3
|
22
|
+
expect(@dangerfile.status_report[:warnings].length).to be == 19
|
23
|
+
expect(@dangerfile.status_report[:markdowns]).to eq([])
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'Parses empty file' do
|
27
|
+
path = File.expand_path('../test_empty_summary.report', __FILE__)
|
28
|
+
@my_plugin.report(path)
|
29
|
+
expect(@dangerfile.status_report[:errors]).to eq([])
|
30
|
+
expect(@dangerfile.status_report[:warnings]).to eq([])
|
31
|
+
expect(@dangerfile.status_report[:markdowns]).to eq([])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
6
|
+
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
|
7
|
+
$LOAD_PATH.unshift((ROOT + 'spec').to_s)
|
8
|
+
|
9
|
+
require 'bundler/setup'
|
10
|
+
require 'pry'
|
11
|
+
|
12
|
+
require 'rspec'
|
13
|
+
require 'danger'
|
14
|
+
|
15
|
+
# Use coloured output, it's the best.
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.filter_gems_from_backtrace 'bundler'
|
18
|
+
config.color = true
|
19
|
+
config.tty = true
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'danger_plugin'
|
23
|
+
|
24
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
25
|
+
# If you are expanding these files, see if it's already been done ^.
|
26
|
+
|
27
|
+
# A silent version of the user interface,
|
28
|
+
# it comes with an extra function `.string` which will
|
29
|
+
# strip all ANSI colours from the string.
|
30
|
+
|
31
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
32
|
+
def testing_ui
|
33
|
+
@output = StringIO.new
|
34
|
+
def @output.winsize
|
35
|
+
[20, 9999]
|
36
|
+
end
|
37
|
+
|
38
|
+
cork = Cork::Board.new(out: @output)
|
39
|
+
def cork.string
|
40
|
+
out.string.gsub(/\e\[([;\d]+)?m/, '')
|
41
|
+
end
|
42
|
+
cork
|
43
|
+
end
|
44
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
45
|
+
|
46
|
+
# Example environment (ENV) that would come from
|
47
|
+
# running a PR on TravisCI
|
48
|
+
def testing_env
|
49
|
+
{
|
50
|
+
'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
|
51
|
+
'TRAVIS_PULL_REQUEST' => '800',
|
52
|
+
'TRAVIS_REPO_SLUG' => 'artsy/eigen',
|
53
|
+
'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
|
54
|
+
'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# A stubbed out Dangerfile for use in tests
|
59
|
+
def testing_dangerfile
|
60
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
61
|
+
Danger::Dangerfile.new(env, testing_ui)
|
62
|
+
end
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
.//environments/production/manifests/classes/build_scripts_repo.pp - ERROR: build_scripts_repo not in autoload module layout on line 3
|
2
|
+
.//environments/production/manifests/classes/node_tools/common_build_tools.pp - ERROR: common_build_tools not in autoload module layout on line 4
|
3
|
+
.//environments/production/manifests/classes/services/default_services.pp - ERROR: default_services not in autoload module layout on line 3
|
4
|
+
.//environments/production/manifests/nodes/ci.pp - WARNING: line has more than 140 characters on line 75
|
5
|
+
.//environments/production/manifests/nodes/ci.pp - WARNING: line has more than 140 characters on line 83
|
6
|
+
.//environments/production/manifests/nodes/ci.pp - WARNING: line has more than 140 characters on line 91
|
7
|
+
.//environments/production/manifests/nodes/ci.pp - WARNING: line has more than 140 characters on line 99
|
8
|
+
.//environments/production/manifests/nodes/ci.pp - WARNING: line has more than 140 characters on line 107
|
9
|
+
.//environments/production/manifests/nodes/ci.pp - WARNING: line has more than 140 characters on line 115
|
10
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: /* */ comment found on line 19
|
11
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: /* */ comment found on line 28
|
12
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: double quoted string containing no variables on line 31
|
13
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: double quoted string containing no variables on line 31
|
14
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: indentation of => is not properly aligned (expected in column 13, but found it in column 14) on line 30
|
15
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: indentation of => is not properly aligned (expected in column 13, but found it in column 14) on line 31
|
16
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: indentation of => is not properly aligned (expected in column 13, but found it in column 14) on line 32
|
17
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: indentation of => is not properly aligned (expected in column 13, but found it in column 14) on line 33
|
18
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: indentation of => is not properly aligned (expected in column 13, but found it in column 14) on line 34
|
19
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: unquoted node name found on line 1
|
20
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: unquoted node name found on line 1
|
21
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: unquoted node name found on line 1
|
22
|
+
.//environments/production/manifests/nodes/puppet_master.pp - WARNING: unquoted node name found on line 1
|
metadata
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-puppet_lint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patrick Butkiewicz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: danger-plugin-api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.41'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.41'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.8'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.14'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.14'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.7'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: listen
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.0.7
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.0.7
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: coveralls
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: Shows formatted puppet lint violations using Danger
|
168
|
+
email:
|
169
|
+
- patrick@intrepid.io
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- ".coveralls.yml"
|
175
|
+
- ".gitignore"
|
176
|
+
- ".rubocop.yml"
|
177
|
+
- ".travis.yml"
|
178
|
+
- ".yardoc/checksums"
|
179
|
+
- ".yardoc/complete"
|
180
|
+
- ".yardoc/object_types"
|
181
|
+
- ".yardoc/objects/root.dat"
|
182
|
+
- ".yardoc/proxy_types"
|
183
|
+
- Gemfile
|
184
|
+
- Gemfile.lock
|
185
|
+
- Guardfile
|
186
|
+
- LICENSE.txt
|
187
|
+
- README.md
|
188
|
+
- Rakefile
|
189
|
+
- danger-puppet_lint.gemspec
|
190
|
+
- lib/danger_plugin.rb
|
191
|
+
- lib/danger_puppet_lint.rb
|
192
|
+
- lib/puppet_lint/gem_version.rb
|
193
|
+
- lib/puppet_lint/plugin.rb
|
194
|
+
- spec/puppet_lint_spec.rb
|
195
|
+
- spec/spec_helper.rb
|
196
|
+
- spec/test_empty_summary.report
|
197
|
+
- spec/test_summary.report
|
198
|
+
homepage: https://github.com/IntrepidPursuits/danger-puppet_lint
|
199
|
+
licenses:
|
200
|
+
- MIT
|
201
|
+
metadata: {}
|
202
|
+
post_install_message:
|
203
|
+
rdoc_options: []
|
204
|
+
require_paths:
|
205
|
+
- lib
|
206
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0'
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
requirements: []
|
217
|
+
rubyforge_project:
|
218
|
+
rubygems_version: 2.6.8
|
219
|
+
signing_key:
|
220
|
+
specification_version: 4
|
221
|
+
summary: Reads puppet-lint output files and reports them using Danger
|
222
|
+
test_files:
|
223
|
+
- spec/puppet_lint_spec.rb
|
224
|
+
- spec/spec_helper.rb
|
225
|
+
- spec/test_empty_summary.report
|
226
|
+
- spec/test_summary.report
|