pronto-android_lint 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 849db2c4d95f24edc595e5b596c8ff825ccc64c8
4
+ data.tar.gz: ff87d5defa1f62607faec2d4e694470b46911870
5
+ SHA512:
6
+ metadata.gz: 7a70337d67970deaec7d7a5a7989f3133865592f8eb761357703efb60d36696101c71bd946f4e9aeaf1f3145c2e220aad50bbabd923b491ae711a7645e741afa
7
+ data.tar.gz: 23a432ea51d5b87d3d49fd849ddb5098db9892dfa36fb626cc627ae16c017db59fd699a3686ba4ba8969f55eb18e52123b06c30043426ec5f73850c9372b59b2
@@ -0,0 +1,46 @@
1
+ require 'nokogiri'
2
+
3
+ module Pronto
4
+ module AndroidLint
5
+ class OutputParser
6
+ attr_reader :path
7
+
8
+ TYPE_WARNINGS = {
9
+ "Warning" => :warning,
10
+ "Info" => :info
11
+ }
12
+
13
+ def initialize(path)
14
+ @path = path
15
+ end
16
+
17
+ def parse
18
+ lint_result = File.open(@path) { |f| Nokogiri::XML(f) }
19
+ lint_result.xpath("//issue").map do |issue|
20
+ {
21
+ path: parse_path(issue.xpath(".//location").attribute("file").value),
22
+ line: issue.xpath(".//location").attribute("line").value.to_i,
23
+ level: TYPE_WARNINGS[issue.attribute("severity").value],
24
+ message: create_message(issue)
25
+ }
26
+ end
27
+ end
28
+
29
+ private
30
+ # removed `/builds/group/project/` from path
31
+ # to match pronto patch path
32
+ def parse_path(path)
33
+ path.split("/")
34
+ .reject(&:empty?)
35
+ .drop(ENV["PRONTO_ANDROID_LINT_PATH_SHIFT"].to_i)
36
+ .join("/")
37
+ end
38
+
39
+ def create_message(issue)
40
+ "#{issue.attribute("summary").value}\n\n#{issue.attribute("message").value}
41
+
42
+ #{issue.attribute("explanation").value}"
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module AndroidLint
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "pronto/android_lint/version"
2
+ require_relative "android_lint_runner"
@@ -0,0 +1,44 @@
1
+ require "pronto"
2
+ require "pronto/android_lint/output_parser"
3
+
4
+ module Pronto
5
+ class AndroidLintRunner < Runner
6
+ def run
7
+ paths = ENV["PRONTO_ANDROID_LINT_RESULT_PATHS"]
8
+ return [] unless @patches && paths
9
+
10
+ offences = paths.split(",")
11
+ .map{ |path| AndroidLint::OutputParser.new(path).parse }
12
+ .flatten
13
+ .compact
14
+
15
+ @patches.select { |p| p.additions > 0 }
16
+ .map { |p| inspect(p, offences) }
17
+ .flatten
18
+ .compact
19
+ end
20
+
21
+ private
22
+
23
+ def inspect(patch, offences)
24
+ patch_path = patch.delta.new_file[:path]
25
+
26
+ messages = []
27
+
28
+ offences.select { |offence| offence[:path] == patch_path }
29
+ .each do |offence|
30
+ messages += patch.added_lines
31
+ .select { |line| line.new_lineno == offence[:line] }
32
+ .map{ |line| new_message(offence, line) }
33
+ end
34
+
35
+ messages.compact
36
+ end
37
+
38
+ def new_message(offence, line)
39
+ path = line.patch.delta.new_file[:path]
40
+
41
+ Message.new(path, line, offence[:level], offence[:message])
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-android_lint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tobiasz Małecki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-19 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
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
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.5'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.5'
83
+ description:
84
+ email:
85
+ - tobiasz.malecki@appunite.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/pronto/android_lint.rb
91
+ - lib/pronto/android_lint/output_parser.rb
92
+ - lib/pronto/android_lint/version.rb
93
+ - lib/pronto/android_lint_runner.rb
94
+ homepage: https://github.com/appunite/pronto-android_lint
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.6.13
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Pronto runner for android lint
118
+ test_files: []