pronto-yamllint 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +17 -0
- data/lib/pronto/yamllint.rb +1 -0
- data/lib/pronto/yamllint_runner.rb +70 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3b28534e56b775e4c791fce9de8bb4e7f0dcaf53
|
4
|
+
data.tar.gz: 756fc9ed34ffa05056089d2e7cf968a64c1a93ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 937c110f5797d33fa3bcdea50008cb66e7ad022bc0c2aa8ab479d98ac71dcd362defec7557b344102743d44997314dcd88396d6df6d8d4231cd4e778a53ca6e3
|
7
|
+
data.tar.gz: ff0c9159ebfe191c09b4d99acc5fb60248aaba9adef2cc6337595a85d8846e073fd4ec1f97e2345e5b6a53d773ed0a07ff56f0849f62f820b5ac5c7a1a0ba9b6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Paulius Mazeika
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Pronto runner for ShellCheck
|
2
|
+
|
3
|
+
[](https://codeclimate.com/github/pclalv/pronto-shellcheck)
|
4
|
+
[](https://travis-ci.org/pclalv/pronto-shellcheck)
|
5
|
+
|
6
|
+
|
7
|
+
Pronto runner for [ShellCheck](https://www.shellcheck.net). [What is Pronto?](https://github.com/mmozuras/pronto)
|
8
|
+
|
9
|
+
## Prerequisites
|
10
|
+
|
11
|
+
You'll need to install [shellcheck by yourself](https://github.com/koalaman/shellcheck#installing). If `shellcheck` is in your `PATH`, everything will simply work.
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
Pass any options you would pass to `shellcheck` with the [`SHELLCHECK_OPTS` environment variable](shellcheck_opts) to `pronto run`; e.g., `SHELLCHECK_OPTS='-x' pronto run`.
|
16
|
+
|
17
|
+
[shellcheck_opts]: [https://github.com/koalaman/shellcheck/wiki/Integration#allow-passing-through-or-configuring-the-environment-variable-shellcheck_opts]
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'yamllint_runner'
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'pronto'
|
2
|
+
require 'shellwords'
|
3
|
+
|
4
|
+
module Pronto
|
5
|
+
# runner for yamllint
|
6
|
+
class YAMLLintRunner < Runner
|
7
|
+
def yamllint_opts
|
8
|
+
ENV['YAMLLINT_OPTS']
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
return [] if !@patches || @patches.count.zero?
|
13
|
+
|
14
|
+
@patches
|
15
|
+
.select { |patch| patch.additions > 0 && yaml?(patch.new_file_full_path) }
|
16
|
+
.map { |patch| inspect(patch) }
|
17
|
+
.flatten.compact
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def yaml?(path)
|
23
|
+
path.to_s.end_with?('.yaml', 'yml')
|
24
|
+
end
|
25
|
+
|
26
|
+
def git_repo_path
|
27
|
+
@git_repo_path ||= Rugged::Repository.discover(File.expand_path(Dir.pwd)).workdir
|
28
|
+
end
|
29
|
+
|
30
|
+
def inspect(patch)
|
31
|
+
line_numbers = offending_line_numbers(patch)[0]
|
32
|
+
lines = offending_line_numbers(patch)[1]
|
33
|
+
line_numbers.map do |line_number|
|
34
|
+
patch
|
35
|
+
.added_lines
|
36
|
+
.select { |line| line.new_lineno == line_number }
|
37
|
+
.map { |line| new_message(lines[line_number], line) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def new_message(offence, line)
|
42
|
+
path = line.patch.delta.new_file[:path]
|
43
|
+
level = if offence.include?('[error]')
|
44
|
+
:error
|
45
|
+
else
|
46
|
+
:warning
|
47
|
+
end
|
48
|
+
|
49
|
+
Message.new(path, line, level, offence, nil, self.class)
|
50
|
+
end
|
51
|
+
|
52
|
+
def offending_line_numbers(patch)
|
53
|
+
line_numbers = []
|
54
|
+
lines = []
|
55
|
+
|
56
|
+
Dir.chdir(git_repo_path) do
|
57
|
+
escaped_file_path = Shellwords.escape(patch.new_file_full_path.to_s)
|
58
|
+
|
59
|
+
output = `yamllint -f parsable #{yamllint_opts} #{escaped_file_path}`
|
60
|
+
output.split("\n").each do |l|
|
61
|
+
line_number = l.split(':')[1].to_i
|
62
|
+
line_numbers << line_number
|
63
|
+
lines[line_number] = l.split(patch.new_file_full_path.to_s + ':')[1]
|
64
|
+
end
|
65
|
+
|
66
|
+
[line_numbers, lines]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pronto-yamllint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paulius Mazeika
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pronto
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.0
|
27
|
+
description: Enables pronto to check .yaml files using yamllint
|
28
|
+
email: paulius@chroot.lt
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
35
|
+
- lib/pronto/yamllint.rb
|
36
|
+
- lib/pronto/yamllint_runner.rb
|
37
|
+
homepage: http://rubygems.org/gems/pronto-yamllint
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements:
|
56
|
+
- yamllint (in PATH)
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 2.6.13
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: Pronto runner for yamllint
|
62
|
+
test_files: []
|