pronto-rubocop 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/lib/pronto/rubocop.rb +67 -0
- data/lib/pronto/rubocop/version.rb +5 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 20961532cbd99bcdbbd65f2817cb91df348a4d51
|
4
|
+
data.tar.gz: e0e190f75f5d81eb73e2cf989310c222239a3316
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9c759e035d287e770aedd50e560b737cd1c62143f827060f8ce9ac3c1573e346956c332eac3cea0c2edc3d08521eddb44f65d9cc306b6b0172f92ef8deb6511a
|
7
|
+
data.tar.gz: 614d557ae0640377f5272dd2b2763b1c087dd2f3a506d84f4f21b7a029c89b657ac6a86b118df674e3df0843a93b4f4b52906decfaaccf8e2bfa86000868cb33
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2013 Mindaugas Mozūras
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# pronto-rubocop
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'pronto'
|
2
|
+
require 'rubocop'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
module Pronto
|
6
|
+
class Rubocop < Runner
|
7
|
+
def initialize
|
8
|
+
@cli = ::Rubocop::CLI.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def run(diffs)
|
12
|
+
return [] unless diffs
|
13
|
+
|
14
|
+
diffs.select { |patch| patch.additions > 0 }
|
15
|
+
.map { |patch| inspect(patch) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def inspect(patch)
|
19
|
+
new_file = patch.delta.new_file
|
20
|
+
|
21
|
+
if File.extname(new_file[:path]) == '.rb'
|
22
|
+
repo = patch.diff.instance_eval { @owner.instance_eval { @owner } }
|
23
|
+
blob = repo.lookup(new_file[:oid])
|
24
|
+
file = create_tempfile(blob)
|
25
|
+
offences = @cli.inspect_file(file.path)
|
26
|
+
messages_from(offences, patch)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def added_lines(patch)
|
31
|
+
patch.map do |hunk|
|
32
|
+
hunk.lines.select(&:addition?)
|
33
|
+
end.flatten.compact
|
34
|
+
end
|
35
|
+
|
36
|
+
def messages_from(offences, patch)
|
37
|
+
offences.map do |offence|
|
38
|
+
line = added_lines(patch).select do |added_line|
|
39
|
+
added_line.new_lineno == offence.line
|
40
|
+
end.first
|
41
|
+
|
42
|
+
path = patch.delta.new_file[:path]
|
43
|
+
message_from(path, offence, line) if line
|
44
|
+
end.compact
|
45
|
+
end
|
46
|
+
|
47
|
+
def message_from(path, offence, line)
|
48
|
+
Pronto::Message.new(path,
|
49
|
+
line,
|
50
|
+
level(offence.severity),
|
51
|
+
offence.message)
|
52
|
+
end
|
53
|
+
|
54
|
+
def level(severity)
|
55
|
+
case severity
|
56
|
+
when :refactor, :convention
|
57
|
+
:info
|
58
|
+
when :warning
|
59
|
+
:warning
|
60
|
+
when :error
|
61
|
+
:error
|
62
|
+
when :fatal
|
63
|
+
:fatal
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pronto-rubocop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mindaugas Mozūras
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pronto
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.2
|
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.1.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.1.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: 2.13.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.13.0
|
69
|
+
description: pronto-rubocop
|
70
|
+
email: mindaugas.mozuras@gmail.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- lib/pronto/rubocop/version.rb
|
76
|
+
- lib/pronto/rubocop.rb
|
77
|
+
- LICENSE
|
78
|
+
- README.md
|
79
|
+
homepage: http://github.org/mmozuras/pronto-rubocop
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.6
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.0.3
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: pronto-rubocop
|
103
|
+
test_files: []
|