pronto-infer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 362137ff4843ffbc2f8e9f968b3f38a958730432dfbd666fdb4af861801bc101
4
+ data.tar.gz: b870f12eb48639ae83b0265574f75bab711bc6ffdc012c862e2599e6c47a0798
5
+ SHA512:
6
+ metadata.gz: 8c9e6ce493a134b97d6cbee1123716e8de0ecd376b5690427497fafb4683904a9b5e30152aae47e8925f9a67e0a0417496daaa326f1e01c2c36ab5b37a2347d7
7
+ data.tar.gz: 12cfdf90837ac5c54bf628ae475fd4b56b9b542ff58461d61fda880eefce8a6f828c7e9cefbe9a41d585d393d45342befcac4d6e1c73ab51911e7a6540fd31c2
@@ -0,0 +1,60 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+
11
+ ### https://raw.github.com/github/gitignore/18654b47c86bef38add5cd091ec2dac7d6e6e37b/Global/Emacs.gitignore
12
+
13
+ # -*- mode: gitignore; -*-
14
+ *~
15
+ \#*\#
16
+ /.emacs.desktop
17
+ /.emacs.desktop.lock
18
+ *.elc
19
+ auto-save-list
20
+ tramp
21
+ .\#*
22
+
23
+ # Org-mode
24
+ .org-id-locations
25
+ *_archive
26
+
27
+ # flymake-mode
28
+ *_flymake.*
29
+
30
+ # eshell files
31
+ /eshell/history
32
+ /eshell/lastdir
33
+
34
+ # elpa packages
35
+ /elpa/
36
+
37
+ # reftex files
38
+ *.rel
39
+
40
+ # AUCTeX auto folder
41
+ /auto/
42
+
43
+ # cask packages
44
+ .cask/
45
+ dist/
46
+
47
+ # Flycheck
48
+ flycheck_*.el
49
+
50
+ # server auth directory
51
+ /server/
52
+
53
+ # projectiles files
54
+ .projectile
55
+
56
+ # directory configuration
57
+ .dir-locals.el
58
+
59
+ # network security
60
+ /network-security.data
@@ -0,0 +1,5 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Metrics/LineLength:
5
+ Max: 120
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at seikichi@kmc.gr.jp. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in pronto-infer.gemspec
8
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Seiichi KONDO
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.
@@ -0,0 +1,49 @@
1
+ # Pronto::Infer
2
+
3
+ <!-- [![Gem Version](https://badge.fury.io/rb/pronto-infer.svg)](http://badge.fury.io/rb/pronto-infer) -->
4
+ <!-- [![Build Status](https://travis-ci.org/seikichi/pronto-infer.svg?branch=master)](https://travis-ci.org/seikichi/pronto-infer) -->
5
+ <!-- [![Coverage Status](https://coveralls.io/repos/seikichi/pronto-infer/badge.svg?branch=master&service=github)](https://coveralls.io/github/seikichi/pronto-infer?branch=master) -->
6
+
7
+ [Pronto](https://github.com/mmozuras/pronto) runner for [Infer](https://fbinfer.com/).
8
+
9
+ ## Configuration
10
+
11
+ You need to specify location of infer output by passing `PRONTO_INFER_OUT_DIR` env variable e.g:
12
+
13
+ ```bash
14
+ PRONTO_INFER_OUT_DIR=infer-out run --index
15
+ ```
16
+
17
+ See [seikichi/pronto-infer-example](https://github.com/seikichi/pronto-infer-example) for more details.
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'pronto-infer
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install pronto-infer
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bundle` to install dependencies. Then, run `rake test` to run the tests.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`.
40
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
41
+ 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).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/seikichi/pronto-infer.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'pronto/infer'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pronto'
4
+ require 'json'
5
+
6
+ module Pronto
7
+ class Infer < Runner
8
+ def run
9
+ return [] unless @patches
10
+
11
+ @patches
12
+ .select(&method(:valid_patch?))
13
+ .flat_map(&method(:inspect))
14
+ .compact
15
+ end
16
+
17
+ private
18
+
19
+ Offence = Struct.new(:path, :line, :message)
20
+
21
+ def infer_out_dir
22
+ ENV['PRONTO_INFER_OUT_DIR'] || (raise 'Please set `PRONTO_INFER_OUT_DIR` to use pronto-infer')
23
+ end
24
+
25
+ def valid_patch?(patch)
26
+ patch.additions.positive?
27
+ end
28
+
29
+ def inspect(patch)
30
+ offences = infer_offences.select { |offence| offence.path == patch.new_file_full_path.to_s }
31
+
32
+ offences.flat_map do |offence|
33
+ patch.added_lines
34
+ .select { |line| line.new_lineno == offence.line }
35
+ .map { |line| new_message(offence, line) }
36
+ end
37
+ end
38
+
39
+ def infer_offences
40
+ @infer_offences ||=
41
+ begin
42
+ pattern = File.join(infer_out_dir, 'report.json')
43
+ Dir.glob(pattern).flat_map(&method(:read_infer_report))
44
+ end
45
+ end
46
+
47
+ def read_infer_report(path)
48
+ report = JSON.parse(File.read(path))
49
+ report.map do |r|
50
+ Offence.new(File.join(Dir.pwd, r['file']), r['line'], r['qualifier'])
51
+ end
52
+ end
53
+
54
+ def new_message(offence, line)
55
+ path = line.patch.delta.new_file[:path]
56
+ Message.new(path, line, :warning, offence.message, nil, self.class)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pronto
4
+ module InferVersion
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'pronto/infer/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'pronto-infer'
9
+ spec.version = Pronto::InferVersion::VERSION
10
+ spec.authors = ['Seiichi KONDO']
11
+ spec.email = ['seikichi@kmc.gr.jp']
12
+
13
+ spec.summary = 'Pronto runner for infer'
14
+ spec.description = <<-DESCRIPTION
15
+ A pronto runner for infer.
16
+ Pronto runs analysis quickly by checking only the relevant changes.
17
+ Created to be used on pull requests, but suited for other scenarios as well.
18
+ DESCRIPTION
19
+ spec.homepage = 'https://github.com/seikichi/pronto-infer'
20
+ spec.license = 'MIT'
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match(%r{^(test|spec|features)/})
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_runtime_dependency 'pronto', '~> 0.9.5'
30
+ spec.add_development_dependency 'bundler', '~> 2.0'
31
+ spec.add_development_dependency 'coveralls'
32
+ spec.add_development_dependency 'pry'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rubocop', '~> 0.62'
35
+ spec.add_development_dependency 'simplecov'
36
+ spec.add_development_dependency 'test-unit', '~> 3.2.8'
37
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-infer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Seiichi KONDO
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-07 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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.62'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.62'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: test-unit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 3.2.8
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 3.2.8
125
+ description: |2
126
+ A pronto runner for infer.
127
+ Pronto runs analysis quickly by checking only the relevant changes.
128
+ Created to be used on pull requests, but suited for other scenarios as well.
129
+ email:
130
+ - seikichi@kmc.gr.jp
131
+ executables: []
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - ".gitignore"
136
+ - ".rubocop.yml"
137
+ - ".travis.yml"
138
+ - CODE_OF_CONDUCT.md
139
+ - Gemfile
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - bin/console
144
+ - bin/setup
145
+ - lib/pronto/infer.rb
146
+ - lib/pronto/infer/version.rb
147
+ - pronto-infer.gemspec
148
+ homepage: https://github.com/seikichi/pronto-infer
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubygems_version: 3.0.3
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Pronto runner for infer
171
+ test_files: []