pronto-dialyzer 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e49ba55878bb58b224f139b50a0e77c7c283fd0
4
- data.tar.gz: 6ea04263140baf7f6ca926411bada9a424e3ddca
3
+ metadata.gz: a26f118ce3d5d50d47feec9aa47f5fe127892fd6
4
+ data.tar.gz: 56e0cf6be31059b77cb0c5b7d65b131eb99ffa89
5
5
  SHA512:
6
- metadata.gz: 4f4e7199e68baa32fd067a9b09188032428184edb3d8651add7b273063923414bf2e2abcf8278805614134795aecedbf0bdcb40226e5dce096512933e3d5994c
7
- data.tar.gz: b0b62041ed1f794b5fc58b3fc36bf240563a2591dd68edc647c7e42fa7bcc561881e2ed0e42b8fc9d01faf03fd27ee416f525b322618434c0626f96edcdfd148
6
+ metadata.gz: b3a12f301614e1c058f34d2cdfc82f1bd108d6748d73ea1a36ff87a78bd4fe9dbb63509feb0cd4c4aa062a745515eede59c5bd059ce1ebbce3f60007971a4074
7
+ data.tar.gz: 992bb88a6dbe86f6c0e0ac09edc1975e1175f0ef8fc0aa17c6632aab78015df3949aa77c4d1920ba19d6f343909328c2b35ceb2a83c56844f6e83e54dd8cadc8
data/README.md CHANGED
@@ -1,17 +1,31 @@
1
1
  # Pronto runner for Dialyzer
2
2
 
3
- This allows you to take the output of Dialyzer and submit its errors with Pronto
3
+ This allows you to take the output of Dialyzer and submit its errors with
4
+ [Pronto]. It works both with Elixir and Erlang.
4
5
 
5
6
  ## Installation
6
7
 
7
- As an Elixir application will probably not have a Gemfile, install it with:
8
+ As an Elixir/Erlang application will probably not have a `Gemfile`, install it with:
8
9
 
9
10
  $ gem install pronto-dialyzer
10
11
 
12
+ After the gem is installed, [Pronto] will already be detected the Dialyzer
13
+ runner.
14
+
11
15
  ## Usage
12
16
 
13
- It uses the environment variable `PRONTO_DIALYZER_OUTPUT` to define the location
14
- of Dialyzer's output file. If that is not defined, the default is `dialyzer.out`
17
+ It's important to enable the `-fullpath` option in your Dialyzer configuration
18
+ and send the output to a file with `-o`.
19
+
20
+ The path for Dialyzer's output file should then be passed to the runner. It uses
21
+ the environment variable `PRONTO_DIALYZER_OUTPUT` to define the location of
22
+ Dialyzer's output file. If this variable is not defined, it will look for the
23
+ file `dialyzer.out`.
24
+
25
+ ### Running on Travis CI
26
+
27
+ Pronto works perfectly to create comment on PRs and commits. For that, use
28
+ `pronto run` as described in the readme for [Pronto].
15
29
 
16
30
  ## Contributing
17
31
 
@@ -21,3 +35,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/iurifq
21
35
  ## License
22
36
 
23
37
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
38
+
39
+
40
+ [Pronto]: https://github.com/mmozuras/pronto
@@ -3,10 +3,11 @@ require 'pronto'
3
3
 
4
4
  module Pronto::Dialyzer
5
5
  class Runner < Pronto::Runner
6
+ BEAM_EXTENSIONS = %w(.ex .erl).freeze
6
7
 
7
8
  def run
8
- return [] unless File.exists?(self.class.dialyzer_output_path)
9
- elixir_patches
9
+ return [] unless dialyzer_output_pathname.exist?
10
+ beam_patches
10
11
  .select { |patch| patch.delta.status != :deleted }
11
12
  .flat_map { |patch| affected_lines(patch) }
12
13
  end
@@ -14,8 +15,9 @@ module Pronto::Dialyzer
14
15
  def affected_lines(patch)
15
16
  candidate_lines = patch.lines.select { |line| line.addition? }
16
17
  candidate_lines.reduce([]) do |accum, line|
17
- affected_line = self.class.dialyzer_lines.find do |dline|
18
- patch.repo.path.join(dline.path) == patch.new_file_full_path && dline.lineno == line.new_lineno
18
+ affected_line = dialyzer_lines.find do |dline|
19
+ patch.repo.path.join(dline.path) == patch.new_file_full_path &&
20
+ dline.lineno == line.new_lineno
19
21
  end
20
22
 
21
23
  if affected_line
@@ -30,19 +32,35 @@ module Pronto::Dialyzer
30
32
  Pronto::Message.new(dline.path, line, :warning, dline.error)
31
33
  end
32
34
 
33
- def elixir_patches
34
- @patches.select {|patch| File.extname(patch.new_file_full_path) == '.ex' }
35
+ def beam_patches
36
+ @patches.select do |patch|
37
+ BEAM_EXTENSIONS.member?(File.extname(patch.new_file_full_path))
38
+ end
39
+ end
40
+
41
+ def dialyzer_output_pathname
42
+ @dialyzer_output_path ||= Pathname.new(
43
+ ENV["PRONTO_DIALYZER_OUTPUT"] || "dialyzer.out"
44
+ )
35
45
  end
36
46
 
37
- def self.dialyzer_output_path
38
- ENV["PRONTO_DIALYZER_OUTPUT"] || "dialyzer.out"
47
+ def dialyzer_lines
48
+ @dialyzer_lines ||= matching_lines(
49
+ dialyzer_output_pathname,
50
+ /(?<path>.+\.[a-z]{2,3}):(?<lineno>[0-9]+): (?<error_msg>.+)/
51
+ )
39
52
  end
40
53
 
41
- def self.dialyzer_lines
42
- File.readlines(dialyzer_output_path).reduce([]) do |accum, line|
43
- match = line.match(/(.+\.ex):([0-9]+): (.+)/)
44
- if match
45
- accum << OpenStruct.new(path: match[1], lineno: match[2].to_i, error: match[3])
54
+ private
55
+
56
+ def matching_lines(pathname, line_regex)
57
+ pathname.readlines.reduce([]) do |accum, line|
58
+ if match = line.match(line_regex)
59
+ accum << OpenStruct.new(
60
+ path: match[:path],
61
+ lineno: match[:lineno].to_i,
62
+ error: match[:error_msg]
63
+ )
46
64
  else
47
65
  accum
48
66
  end
@@ -1,5 +1,5 @@
1
1
  module Pronto
2
2
  module Dialyzer
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-dialyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iuri Fernandes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-03 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pronto