pronto-perl_lint 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +9 -0
- data/README.md +17 -0
- data/bin/perllint +12 -0
- data/lib/pronto/perl_lint/version.rb +5 -0
- data/lib/pronto/perl_lint.rb +56 -0
- data/pronto-perl_lint.gemspec +26 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 41f9ecc5d0d6e3a98010c464c1832a96411fa274
|
4
|
+
data.tar.gz: 98dfd115fe8388b2778568efc9e39f4ec8954639
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e932f92bd9364a0d441c26c5aa95dc64a1fed2aa0b02991b7138a3fa13641a8cd46011db9501b8088da193e76280c094dd40e75dba78309de0091b12a3b257b
|
7
|
+
data.tar.gz: 5053406a80569f2be5de7c50045212f9f01a2e81b639355a0d98ee214667b753f01fef2d26e3520a51c2bad5fe6b2ebab2e0886897e945ce7d4a30f39e41cad1
|
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Daiki Hayakawa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Pronto runner for Perl::Lint
|
2
|
+
|
3
|
+
Pronto runner for [Perl::Lint](https://github.com/moznion/Perl-Lint).
|
4
|
+
[What is Pronto?](https://github.com/mmozuras/pronto)
|
5
|
+
|
6
|
+
|
7
|
+
Requirement Perl Modules
|
8
|
+
-------------
|
9
|
+
|
10
|
+
- Perl::Lint
|
11
|
+
- JSON
|
12
|
+
|
13
|
+
|
14
|
+
Copyright
|
15
|
+
---------
|
16
|
+
|
17
|
+
Copyright (c) 2017 Daiki Hayakawa. See [LICENSE](LICENSE) for further details.
|
data/bin/perllint
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'pronto'
|
2
|
+
require 'json'
|
3
|
+
require 'shellwords'
|
4
|
+
require 'linguist'
|
5
|
+
|
6
|
+
module Pronto
|
7
|
+
class PerlLint < Runner
|
8
|
+
def initialize(patches, commit = nil)
|
9
|
+
super
|
10
|
+
@lint = "#{File.expand_path(File.dirname(__FILE__))}/../../bin/perllint"
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
return [] unless @patches
|
15
|
+
|
16
|
+
@patches.select { |patch| valid_patch?(patch) }
|
17
|
+
.map { |patch| inspect(patch) }
|
18
|
+
.flatten.compact
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid_patch?(patch)
|
22
|
+
patch.additions > 0 && perl_file?(patch.new_file_full_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def inspect(patch)
|
26
|
+
path = patch.new_file_full_path.to_s
|
27
|
+
offences = run_perl_lint(path)
|
28
|
+
|
29
|
+
offences.map do |offence|
|
30
|
+
patch.added_lines
|
31
|
+
.select { |line| line.new_lineno == offence['line'] }
|
32
|
+
.map { |line| new_message(offence, line) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def new_message(offence, line)
|
37
|
+
path = line.patch.delta.new_file[:path]
|
38
|
+
level = :error
|
39
|
+
|
40
|
+
Message.new(path, line, level, message(offence), nil, self.class)
|
41
|
+
end
|
42
|
+
|
43
|
+
def message(offence)
|
44
|
+
"#{offence['policy']}: #{offence['description']}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def run_perl_lint(path)
|
48
|
+
json = `#{Shellwords.escape(@lint)} #{Shellwords.escape(path)}`
|
49
|
+
JSON.parse(json)
|
50
|
+
end
|
51
|
+
|
52
|
+
def perl_file?(path)
|
53
|
+
Linguist::FileBlob.new(path, Dir.pwd).language.name == 'Perl'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pronto/perl_lint/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'pronto-perl_lint'
|
8
|
+
spec.version = Pronto::PerlLintVersion::VERSION
|
9
|
+
spec.authors = ['Daiki Hayakawa']
|
10
|
+
spec.email = ['bells171@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Pronto runner for Perl Lint'
|
13
|
+
spec.homepage = 'https://github.com/belsl17/pronto-perl_lint'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = Dir.glob('lib/**/*.rb') +
|
17
|
+
Dir.glob('bin/*') +
|
18
|
+
['pronto-perl_lint.gemspec', 'LICENSE', 'README.md']
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency('pronto', '~> 0.8')
|
22
|
+
spec.add_runtime_dependency('json', '~> 1.8')
|
23
|
+
spec.add_runtime_dependency('github-linguist', '~> 5.0')
|
24
|
+
spec.add_development_dependency('rake', '~> 11.0')
|
25
|
+
spec.add_development_dependency('rspec', '~> 3.4')
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pronto-perl_lint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daiki Hayakawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-19 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.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: github-linguist
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '11.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '11.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.4'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- bells171@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- LICENSE
|
91
|
+
- README.md
|
92
|
+
- bin/perllint
|
93
|
+
- lib/pronto/perl_lint.rb
|
94
|
+
- lib/pronto/perl_lint/version.rb
|
95
|
+
- pronto-perl_lint.gemspec
|
96
|
+
homepage: https://github.com/belsl17/pronto-perl_lint
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.5.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Pronto runner for Perl Lint
|
120
|
+
test_files: []
|