pronto-dialyxir 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 931181ef27d8ef1ca06f4e53901d3417f3a1b749
4
+ data.tar.gz: d17becd27f0f062452b94acdf4ef332106d7e32b
5
+ SHA512:
6
+ metadata.gz: 42b91cad5831006911f674ee4d4b94705ae744931734a98e702e02f5185fa1e53a37b5990cc37863ee7342aa7328cb1d1b130deedf99a69ce745f46cd6ab6497
7
+ data.tar.gz: 90acf93dd2935a85dd67a359c68e5c3b5db08447b421946bcf9d798d353cbfa0fc13da6efd860d2342acb3caffc5de0bcbffc02a98a9160c06437cadb8a38442
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016
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,38 @@
1
+ Dialyxir-pronto
2
+ ============
3
+
4
+ [Pronto](https://github.com/mmozuras/pronto) runner for [dialyxir](https://github.com/jeremyjh/dialyxir)
5
+
6
+ Configuring runner
7
+ ==================
8
+
9
+ First need install erlang-elixir-mix properly
10
+
11
+ Now you will need a global installation of [mix dialyxir](https://github.com/jeremyjh/dialyxir).
12
+
13
+ ```
14
+ {:dialyxir, "~> 1.0.0-rc.2", runtime: false}
15
+ ```
16
+
17
+ Installation
18
+ ============
19
+
20
+ After install successfully dialyxir globally you simple need install this gem
21
+
22
+ ```
23
+ gem install pronto-dialyxir
24
+ ```
25
+
26
+ After the gem is installed, Pronto will already detect dialyxir runner inside a
27
+ elixir project.
28
+
29
+ Configure checkers
30
+ ==================
31
+
32
+ You can configure in [mix.exs](https://github.com/jeremyjh/dialyxir#flags)
33
+
34
+ Credits
35
+ =======
36
+
37
+ - [pronto-credo](https://github.com/carakan/pronto-credo)
38
+ - [pronto-tailor](https://github.com/ajanauskas/pronto-tailor)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pronto/dialyxir"
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
@@ -0,0 +1,37 @@
1
+ module Pronto
2
+ module Dialyxir
3
+ class OutputParser
4
+ attr_reader :output, :file
5
+
6
+ def initialize(file, output)
7
+ @file = file
8
+ @output = output
9
+ end
10
+
11
+ def parse
12
+ return {} if output.to_s.empty?
13
+
14
+ if output.lines[2].start_with?("== Compilation error")
15
+ return [{
16
+ line: 0,
17
+ column: nil,
18
+ level: :error,
19
+ message: output.chomp("\n")
20
+ }]
21
+ end
22
+
23
+ output.lines.map do |line|
24
+ line_parts = line.split(':')
25
+ type, message = line_parts[2..-1].join(":").split(' ', 2)
26
+ next unless file.start_with?(line_parts[0])
27
+ {
28
+ line: line_parts[1].to_i,
29
+ column: nil,
30
+ level: :warning,
31
+ message: message.chomp("\n")
32
+ }
33
+ end.compact
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module Dialyxir
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ require 'open3'
2
+
3
+
4
+ module Pronto
5
+ module Dialyxir
6
+ class Wrapper
7
+ def initialize
8
+ @stdout = run_linter
9
+ end
10
+
11
+ def lint(patch)
12
+ return [] if patch.nil?
13
+ path = patch.delta.new_file[:path]
14
+ return {} if @stdout.nil? || @stdout == 0
15
+ OutputParser.new(path, @stdout).parse
16
+ end
17
+
18
+ private
19
+
20
+ def run_linter
21
+ stdout, stderr, _ = Open3.capture3(dialyxir_executable)
22
+ puts "WARN: pronto-dialyxir: #{stderr}" if stderr && stderr.size > 0
23
+ stdout
24
+ end
25
+
26
+ def dialyxir_executable
27
+ "mix dialyzer --format short --no-check --quiet"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,50 @@
1
+ require 'pronto'
2
+ require 'pronto/dialyxir/version'
3
+ require 'pronto/dialyxir/wrapper'
4
+ require 'pronto/dialyxir/output_parser'
5
+
6
+ module Pronto
7
+ class DialyxirRunner < Runner
8
+ def initialize(_, _)
9
+ super
10
+ end
11
+
12
+ def run
13
+ return [] unless @patches
14
+
15
+ wrapper = Dialyxir::Wrapper.new
16
+
17
+ @patches.select { |p| p.additions > 0 }
18
+ .select { |p| elixir_file?(p.new_file_full_path) }
19
+ .map { |p| inspect(p, wrapper) }
20
+ .flatten
21
+ .compact
22
+ end
23
+
24
+ private
25
+
26
+ def inspect(patch, wrapper)
27
+ offences = wrapper.lint(patch)
28
+ messages = []
29
+
30
+ offences.each do |offence|
31
+ messages += patch
32
+ .added_lines
33
+ .select { |line| line.new_lineno == offence[:line] }
34
+ .map { |line| new_message(offence, line) }
35
+ end
36
+
37
+ messages.compact
38
+ end
39
+
40
+
41
+ def new_message(offence, line)
42
+ path = line.patch.delta.new_file[:path]
43
+ Message.new(path, line, offence[:level], offence[:message])
44
+ end
45
+
46
+ def elixir_file?(path)
47
+ %w(.ex .exs).include?(File.extname(path))
48
+ end
49
+ end
50
+ 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/dialyxir/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'pronto-dialyxir'
8
+ spec.version = Pronto::Dialyxir::VERSION
9
+ spec.authors = ['Anastasiya Dyachenko']
10
+ spec.email = ['apelsinka223@gmail.com']
11
+
12
+ spec.summary = 'Pronto runner for Dialyxir'
13
+ spec.homepage = 'https://github.com/llcaeon/pronto-dialyxir'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.10'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '~> 3.3'
24
+
25
+ spec.add_runtime_dependency 'pronto', '~> 0.7', '> 0.7.0'
26
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-dialyxir
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Anastasiya Dyachenko
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pronto
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ - - ">"
63
+ - !ruby/object:Gem::Version
64
+ version: 0.7.0
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '0.7'
72
+ - - ">"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.7.0
75
+ description:
76
+ email:
77
+ - apelsinka223@gmail.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - CODE_OF_CONDUCT.md
83
+ - Gemfile
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - bin/console
88
+ - lib/pronto/dialyxir.rb
89
+ - lib/pronto/dialyxir/output_parser.rb
90
+ - lib/pronto/dialyxir/version.rb
91
+ - lib/pronto/dialyxir/wrapper.rb
92
+ - pronto-dialyxir.gemspec
93
+ homepage: https://github.com/llcaeon/pronto-dialyxir
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.5.2.3
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Pronto runner for Dialyxir
117
+ test_files: []