danger-android_lint 0.0.2 → 0.0.3

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: 6032c641b6bfe75156ded93357b0108d7f52cd37
4
- data.tar.gz: 4e3a4911b701879fa141df99552cbaed3dee7da7
3
+ metadata.gz: 14a8b24ca402a1f8615991280e363bf0fe02eb9d
4
+ data.tar.gz: 4be292fab2a1db392f729bda485a831f1533c611
5
5
  SHA512:
6
- metadata.gz: 30cdfffe72726c2ae90796f052cd330cf31dc4d336c5d57e59bf38ef57f5e22375faaf81704180c5f3d5399b54a899713d8575a29771aeeb754a65602baac75f
7
- data.tar.gz: ae790c26a696b6331ae9e19f5c0000c2a572888d6a3f29931153b98ac6e844b32b2b0c281739c749a9546b16264df4cae680ed759e84e7dbbb4e1bfb03412b5c
6
+ metadata.gz: f5842a73db7eaac24acc5a704c582bbbcd690b95499392f57214e45fb6bd9eb71dbd510cc17456017922823a1544bda1bf8ee63dd62371cd1c47bdbc06c48301
7
+ data.tar.gz: 205b8756e1b4f3fdf34256b4baa551475fcec0e5ec239dc68fde22616856c6ae7052b44b66bd9898d6683c5aceeba93e44a7cef7d8427a715ef0f6d2fbada307
data/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
+ # 0.0.3
2
+ - Add `report_file` parameter, so users can set a custom path for their report xmls (@churowa)
3
+
1
4
  ## 0.0.2
2
- - Fix check for inexistent report file
3
- - Fix markdown message being printed without any issues reported
5
+ - Fix check for inexistent report file (@barbosa)
6
+ - Fix markdown message being printed without any issues reported (@barbosa)
4
7
 
5
8
  ## 0.0.1
6
- - Initial version
9
+ - Initial version (@barbosa)
@@ -1,3 +1,3 @@
1
1
  module AndroidLint
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "0.0.3".freeze
3
3
  end
@@ -25,7 +25,17 @@ module Danger
25
25
  class DangerAndroidLint < Plugin
26
26
 
27
27
  SEVERITY_LEVELS = ["Warning", "Error", "Fatal"]
28
- REPORT_FILE = "app/build/reports/lint/lint-result.xml"
28
+
29
+ # Location of lint report file
30
+ # If your Android lint task outputs to a different location, you can specify it here.
31
+ # Defaults to "app/build/reports/lint/lint-result.xml".
32
+ # @return [String]
33
+ attr_accessor :report_file
34
+ # A getter for `report_file`.
35
+ # @return [String]
36
+ def report_file
37
+ return @report_file || 'app/build/reports/lint/lint-result.xml'
38
+ end
29
39
 
30
40
  # Custom gradle task to run.
31
41
  # This is useful when your project has different flavors.
@@ -59,8 +69,8 @@ module Danger
59
69
 
60
70
  system "./gradlew #{gradle_task || 'lint'}"
61
71
 
62
- unless File.exists?(REPORT_FILE)
63
- fail("Lint report not found at `#{REPORT_FILE}`. "\
72
+ unless File.exists?(report_file)
73
+ fail("Lint report not found at `#{report_file}`. "\
64
74
  "Have you forgot to add `xmlReport true` to your `build.gradle` file?")
65
75
  end
66
76
 
@@ -80,7 +90,7 @@ module Danger
80
90
  private
81
91
 
82
92
  def read_issues_from_report
83
- file = File.open("app/build/reports/lint/lint-result.xml")
93
+ file = File.open(report_file)
84
94
 
85
95
  require 'oga'
86
96
  report = Oga.parse_xml(file)
@@ -21,6 +21,7 @@ module Danger
21
21
 
22
22
  it "Fails if severity is an unknown value" do
23
23
  allow(@android_lint).to receive(:`).with("ls gradlew").and_return("gradlew")
24
+ allow(File).to receive(:exists?).with(@android_lint.report_file()).and_return(true)
24
25
 
25
26
  @android_lint.severity = "Dummy"
26
27
  @android_lint.lint
@@ -30,21 +31,46 @@ module Danger
30
31
 
31
32
  it "Sets severity to 'Warning' if no severity param is provided" do
32
33
  allow(@android_lint).to receive(:`).with("ls gradlew").and_return("gradlew")
33
- allow(File).to receive(:exists?).with(Danger::DangerAndroidLint::REPORT_FILE).and_return(true)
34
+ allow(File).to receive(:exists?).with(@android_lint.report_file).and_return(true)
34
35
 
35
36
  fake_result = File.open("spec/fixtures/lint-result-with-everything.xml")
36
- allow(File).to receive(:open).with(Danger::DangerAndroidLint::REPORT_FILE).and_return(fake_result)
37
+ allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
37
38
 
38
39
  @android_lint.lint
39
40
  expect(@android_lint.severity).to eq("Warning")
40
41
  end
41
42
 
43
+ it "Sets the report file to a default location if no param is provided" do
44
+ allow(@android_lint).to receive(:`).with("ls gradlew").and_return("gradlew")
45
+ allow(File).to receive(:exists?).with(@android_lint.report_file).and_return(true)
46
+
47
+ fake_result = File.open("spec/fixtures/lint-result-with-everything.xml")
48
+ allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
49
+
50
+ @android_lint.lint
51
+ expect(@android_lint.report_file).to eq("app/build/reports/lint/lint-result.xml")
52
+ end
53
+
54
+ it "Sets the report_file to the user's preference in the Dangerfile'" do
55
+ allow(@android_lint).to receive(:`).with("ls gradlew").and_return("gradlew")
56
+
57
+ @android_lint.report_file = 'some/other/location/lint-result.xml'
58
+
59
+ fake_result = File.open("spec/fixtures/lint-result-with-everything.xml")
60
+ allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
61
+ allow(File).to receive(:exists?).with(@android_lint.report_file).and_return(true)
62
+
63
+ @android_lint.lint
64
+
65
+ expect(@android_lint.report_file).to eq('some/other/location/lint-result.xml')
66
+ end
67
+
42
68
  it "Fails if report file does not exist" do
43
69
  allow(@android_lint).to receive(:`).with("ls gradlew").and_return("gradlew")
44
- allow(File).to receive(:exists?).with(Danger::DangerAndroidLint::REPORT_FILE).and_return(false)
70
+ allow(File).to receive(:exists?).with(@android_lint.report_file).and_return(false)
45
71
 
46
72
  fake_result = File.open("spec/fixtures/lint-result-with-everything.xml")
47
- allow(File).to receive(:open).with(Danger::DangerAndroidLint::REPORT_FILE).and_return(fake_result)
73
+ allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
48
74
 
49
75
  @android_lint.lint
50
76
 
@@ -55,12 +81,12 @@ module Danger
55
81
  describe 'lint' do
56
82
  before do
57
83
  allow(@android_lint).to receive(:`).with("ls gradlew").and_return("gradlew")
58
- allow(File).to receive(:exists?).with(Danger::DangerAndroidLint::REPORT_FILE).and_return(false)
84
+ allow(File).to receive(:exists?).with(@android_lint.report_file).and_return(false)
59
85
  end
60
86
 
61
87
  it 'Prints markdown if issues were found' do
62
88
  fake_result = File.open("spec/fixtures/lint-result-with-everything.xml")
63
- allow(File).to receive(:open).with(Danger::DangerAndroidLint::REPORT_FILE).and_return(fake_result)
89
+ allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
64
90
 
65
91
  @android_lint.lint
66
92
 
@@ -79,7 +105,7 @@ module Danger
79
105
 
80
106
  it 'Doesn`t print anything if no errors were found' do
81
107
  fake_result = File.open("spec/fixtures/lint-result-empty.xml")
82
- allow(File).to receive(:open).with(Danger::DangerAndroidLint::REPORT_FILE).and_return(fake_result)
108
+ allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
83
109
 
84
110
  @android_lint.lint
85
111
 
@@ -89,7 +115,7 @@ module Danger
89
115
 
90
116
  it 'Doesn`t print anything if no errors were found' do
91
117
  fake_result = File.open("spec/fixtures/lint-result-without-fatal.xml")
92
- allow(File).to receive(:open).with(Danger::DangerAndroidLint::REPORT_FILE).and_return(fake_result)
118
+ allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
93
119
 
94
120
  @android_lint.severity = "Fatal"
95
121
  @android_lint.lint
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-android_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Barbosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-15 00:00:00.000000000 Z
11
+ date: 2017-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oga