pronto-querly 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +6 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/pronto/querly.rb +66 -0
- data/lib/pronto/querly/version.rb +3 -0
- data/pronto-querly.gemspec +29 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '0856a3893b6da2e01d506d09326cb255b546db5604649ef4b6223cb069a35d1f'
|
4
|
+
data.tar.gz: 38f7a27b52f81dc25d41edbf9670b5ef9d31328abb14f6c6d7961f5c3cea1392
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 834fc1c6e6b38598dae2bf75fb76310af8fb72f30199b4f2fffcf473c4a46bfa6683b2bd99187c1e17b321fc1ad11fe618068bebf86332e1f65ce5c64c9f55c6
|
7
|
+
data.tar.gz: d23743a0609851b909c0f2daf54223a185083f66d9af17c5397c7ffb661afae03d22fb50e2e1812545a6fd5aa25e14cfe114cf2ec1da337f23a5c020d9cb6ed7
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# pronto-querly
|
2
|
+
|
3
|
+
This is a pronto runner for Querly, a pattern based Ruby program checking tool.
|
4
|
+
|
5
|
+
* [pronto](https://github.com/prontolabs/pronto)
|
6
|
+
* [Querly](https://github.com/soutaro/querly)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'pronto'
|
14
|
+
gem 'pronto-querly', require: false
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install pronto-querly
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Use `pronto run` command.
|
28
|
+
|
29
|
+
$ bundle exec pronto run
|
30
|
+
$ bundle exec pronto run -r querly
|
31
|
+
|
32
|
+
### Configuration
|
33
|
+
|
34
|
+
There is no configuration option via `.pronto.yml`.
|
35
|
+
Define your rules in `querly.yml`.
|
36
|
+
|
37
|
+
The exceptions are ones given through `all:` section of `.pronto.yml`.
|
38
|
+
|
39
|
+
```yaml
|
40
|
+
all:
|
41
|
+
exclude:
|
42
|
+
- 'spec/**/*'
|
43
|
+
```
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/soutaro/pronto-querly.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pronto/querly"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require "pronto/querly/version"
|
2
|
+
require "pronto"
|
3
|
+
require "querly"
|
4
|
+
|
5
|
+
module Pronto
|
6
|
+
class Querly < Runner
|
7
|
+
attr_reader :stderr
|
8
|
+
|
9
|
+
def initialize(patches, commit=nil, stderr: STDERR)
|
10
|
+
super(patches, commit)
|
11
|
+
@stderr = stderr
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
repo_path = @patches.repo.path
|
16
|
+
|
17
|
+
config = begin
|
18
|
+
yaml = YAML.load(config_path.read)
|
19
|
+
::Querly::Config.load(yaml, config_path: config_path, root_dir: repo_path, stderr: stderr)
|
20
|
+
rescue => exn
|
21
|
+
stderr.puts "[pronto-querly] Failed to load Querly config from #{config_path.relative_path_from(repo_path)}: #{exn.inspect}"
|
22
|
+
return []
|
23
|
+
end
|
24
|
+
|
25
|
+
path_to_patch = @patches.each.with_object({}) do |patch, hash|
|
26
|
+
hash[patch.new_file_full_path] = patch
|
27
|
+
end
|
28
|
+
|
29
|
+
analyzer = ::Querly::Analyzer.new(config: config, rule: nil)
|
30
|
+
::Querly::ScriptEnumerator.new(paths: [repo_path], config: config).each do |path, script|
|
31
|
+
case script
|
32
|
+
when ::Querly::Script
|
33
|
+
if path_to_patch.key?(path)
|
34
|
+
analyzer.scripts << script
|
35
|
+
end
|
36
|
+
when StandardError, LoadError
|
37
|
+
stderr.puts "[pronto-querly] Failed to load Ruby script from #{path.relative_path_from(repo_path)}: #{script.inspect}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
[].tap do |messages|
|
42
|
+
analyzer.run do |script, rule, pair|
|
43
|
+
line_range = pair.node.loc.first_line..pair.node.loc.last_line
|
44
|
+
patch = path_to_patch[script.path]
|
45
|
+
|
46
|
+
if (intersection_line = patch.added_lines.find {|line| line_range.cover?(line.line.new_lineno) })
|
47
|
+
src = pair.node.loc.expression.source.split(/\n/).first.strip
|
48
|
+
message = "[#{rule.id}] #{rule.messages.join("\n").split(/\n/).first} (#{src})"
|
49
|
+
relative_path = script.path.relative_path_from(repo_path)
|
50
|
+
|
51
|
+
messages << Message.new(relative_path, intersection_line, :warning, message, nil, self.class)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def config_path
|
58
|
+
repo_path = @patches.repo.path
|
59
|
+
[
|
60
|
+
repo_path + Pathname("querly.yml"),
|
61
|
+
repo_path + Pathname("querly.yaml")].compact.find(&:file?) || Pathname(options[:config]
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "pronto/querly/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pronto-querly"
|
8
|
+
spec.version = ProntoQuerly::VERSION
|
9
|
+
spec.authors = ["Soutaro Matsumoto"]
|
10
|
+
spec.email = ["matsumoto@soutaro.com"]
|
11
|
+
|
12
|
+
spec.summary = "Pronto runner for Querly"
|
13
|
+
spec.description = "Pronto runner for Querly"
|
14
|
+
spec.homepage = "https://github.com/soutaro/pronto-querly"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "pronto", "~> 0.9.5"
|
24
|
+
spec.add_runtime_dependency "querly", "~> 0.11.0"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pronto-querly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Soutaro Matsumoto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-22 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.5
|
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.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: querly
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.11.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.11.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
description: Pronto runner for Querly
|
84
|
+
email:
|
85
|
+
- matsumoto@soutaro.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".ruby-version"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- lib/pronto/querly.rb
|
99
|
+
- lib/pronto/querly/version.rb
|
100
|
+
- pronto-querly.gemspec
|
101
|
+
homepage: https://github.com/soutaro/pronto-querly
|
102
|
+
licenses: []
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.7.6
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Pronto runner for Querly
|
124
|
+
test_files: []
|