danger-android_lint 0.0.4 → 0.0.9

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
- SHA1:
3
- metadata.gz: bc51ff27951c956c5534a2adc9219db6ef8b23ea
4
- data.tar.gz: 162c31a66338d95c2d184864ad9cbbb02377668c
2
+ SHA256:
3
+ metadata.gz: 9ada934a0418e182a4f33db8040b2ac2686b51062d9298bcafeec2641333c794
4
+ data.tar.gz: f083ac782badad37b3013f29326723662c6e30fa87d1f553e9049edb0d4308b0
5
5
  SHA512:
6
- metadata.gz: e34ff70dab0f608b3bfd09aa5f3ec7e3a83812fa95f3597bbb88c67d6e3854991caf156f61ec652f7415509082731665c1bc8060dc912e98761e06f0a1728b6b
7
- data.tar.gz: 53601dfb052fed83d66a369edfc6843759d47c9786f9bd477a65f84fb1208815f9c1a8cc66067b8de597755dfa3fb47848cff8f75ea08848737822f8d6e34374
6
+ metadata.gz: 9ad11c214c69b8705766e879b6bd37c436b9ab5f5c812a5f0defedcbdd14c8d1cc012f16b16461a1426eedbd5659bd6c89aa85c4b3dcb2162984831e369ddaaa
7
+ data.tar.gz: cca847253edd672cd61da0142cabdb6fb768315cf5fa44a824b0471f9f335df47700452f0b8deabe5a4fee80cec109bbfe4f8d193b695f56f8e30bedcd259460
@@ -0,0 +1,13 @@
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@1.0
4
+
5
+ jobs:
6
+ build:
7
+ docker:
8
+ - image: circleci/ruby:2.7
9
+ steps:
10
+ - checkout
11
+ - run: gem install bundler:2.2.10
12
+ - run: bundle install
13
+ - run: bundle exec rake spec
@@ -0,0 +1 @@
1
+ * @barbosa
data/.gitignore CHANGED
@@ -4,3 +4,5 @@ pkg
4
4
  .idea/
5
5
  .yardoc/
6
6
  *.gem
7
+ .bundle/
8
+ vendor/
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ # 0.0.9
2
+ - Add `filtering_lines` parameter, to show lint issues only on modified lines ([@ShivamPokhriyal](https://github.com/ShivamPokhriyal))
3
+
4
+ # 0.0.8
5
+ - Fix security issues ([@barbosa](https://github.com/barbosa))
6
+ - Expose report message ([@adamstrange])(https://github.com/adamstrange))
7
+ - Skip gradle task ([@mathroule])(https://github.com/mathroule))
8
+
9
+ # 0.0.7
10
+ - Fix security issues ([@barbosa](https://github.com/barbosa))
11
+
12
+ # 0.0.6
13
+ - Bump yarn and rubocop versions due to security issues ([@barbosa](https://github.com/barbosa))
14
+
15
+ # 0.0.5
16
+ - Fix count number for issues ([@jettbow](https://github.com/jettbow))
17
+ - Add option for skipping gradle task ([@litmon](https://github.com/litmon))
18
+
1
19
  # 0.0.4
2
20
  - Add `filtering` parameter, default to false, to run lint only on modified files ([@leonhartX](https://github.com/leonhartX))
3
21
  - Add support for GitHub's inline comments ([@leonhartX](https://github.com/leonhartX))
data/Gemfile.lock CHANGED
@@ -1,51 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-android_lint (0.0.1)
4
+ danger-android_lint (0.0.9)
5
5
  danger-plugin-api (~> 1.0)
6
6
  oga
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.5.0)
12
- public_suffix (~> 2.0, >= 2.0.2)
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
13
  ansi (1.5.0)
14
- ast (2.3.0)
15
- claide (1.0.1)
14
+ ast (2.4.2)
15
+ claide (1.0.3)
16
16
  claide-plugins (0.9.2)
17
17
  cork
18
18
  nap
19
19
  open4 (~> 1.3)
20
- coderay (1.1.1)
21
- colored (1.2)
22
- cork (0.2.0)
23
- colored (~> 1.2)
24
- danger (4.0.1)
20
+ coderay (1.1.3)
21
+ colored2 (3.1.2)
22
+ cork (0.3.0)
23
+ colored2 (~> 3.1)
24
+ danger (8.2.3)
25
25
  claide (~> 1.0)
26
26
  claide-plugins (>= 0.9.2)
27
- colored (~> 1.2)
27
+ colored2 (~> 3.1)
28
28
  cork (~> 0.1)
29
- faraday (~> 0.9)
30
- faraday-http-cache (~> 1.0)
31
- git (~> 1)
32
- kramdown (~> 1.5)
33
- octokit (~> 4.2)
34
- terminal-table (~> 1)
29
+ faraday (>= 0.9.0, < 2.0)
30
+ faraday-http-cache (~> 2.0)
31
+ git (~> 1.7)
32
+ kramdown (~> 2.3)
33
+ kramdown-parser-gfm (~> 1.0)
34
+ no_proxy_fix
35
+ octokit (~> 4.7)
36
+ terminal-table (>= 1, < 4)
35
37
  danger-plugin-api (1.0.0)
36
38
  danger (> 2.0)
37
- diff-lcs (1.2.5)
38
- faraday (0.10.0)
39
+ diff-lcs (1.4.4)
40
+ faraday (1.4.2)
41
+ faraday-em_http (~> 1.0)
42
+ faraday-em_synchrony (~> 1.0)
43
+ faraday-excon (~> 1.1)
44
+ faraday-net_http (~> 1.0)
45
+ faraday-net_http_persistent (~> 1.1)
39
46
  multipart-post (>= 1.2, < 3)
40
- faraday-http-cache (1.3.1)
41
- faraday (~> 0.8)
42
- ffi (1.9.14)
43
- formatador (0.2.5)
44
- git (1.3.0)
45
- guard (2.14.0)
47
+ ruby2_keywords (>= 0.0.4)
48
+ faraday-em_http (1.0.0)
49
+ faraday-em_synchrony (1.0.0)
50
+ faraday-excon (1.1.0)
51
+ faraday-http-cache (2.2.0)
52
+ faraday (>= 0.8)
53
+ faraday-net_http (1.0.1)
54
+ faraday-net_http_persistent (1.1.0)
55
+ ffi (1.15.3)
56
+ formatador (0.3.0)
57
+ git (1.8.1)
58
+ rchardet (~> 1.8)
59
+ guard (2.17.0)
46
60
  formatador (>= 0.2.4)
47
61
  listen (>= 2.7, < 4.0)
48
- lumberjack (~> 1.0)
62
+ lumberjack (>= 1.0.12, < 2.0)
49
63
  nenv (~> 0.1)
50
64
  notiffany (~> 0.0)
51
65
  pry (>= 0.9.12)
@@ -56,52 +70,61 @@ GEM
56
70
  guard (~> 2.1)
57
71
  guard-compat (~> 1.1)
58
72
  rspec (>= 2.99.0, < 4.0)
59
- kramdown (1.13.0)
73
+ kramdown (2.3.1)
74
+ rexml
75
+ kramdown-parser-gfm (1.1.0)
76
+ kramdown (~> 2.0)
60
77
  listen (3.0.7)
61
78
  rb-fsevent (>= 0.9.3)
62
79
  rb-inotify (>= 0.9.7)
63
- lumberjack (1.0.10)
64
- method_source (0.8.2)
65
- multipart-post (2.0.0)
80
+ lumberjack (1.2.8)
81
+ method_source (1.0.0)
82
+ multipart-post (2.1.1)
66
83
  nap (1.1.0)
67
84
  nenv (0.3.0)
68
- notiffany (0.1.1)
85
+ no_proxy_fix (0.1.2)
86
+ notiffany (0.1.3)
69
87
  nenv (~> 0.1)
70
88
  shellany (~> 0.0)
71
- octokit (4.6.2)
89
+ octokit (4.21.0)
90
+ faraday (>= 0.9)
72
91
  sawyer (~> 0.8.0, >= 0.5.3)
73
- oga (2.7)
92
+ oga (3.3)
74
93
  ast
75
94
  ruby-ll (~> 2.1)
76
95
  open4 (1.3.4)
77
- parser (2.3.1.4)
78
- ast (~> 2.2)
79
- powerpack (0.1.1)
80
- pry (0.10.4)
81
- coderay (~> 1.1.0)
82
- method_source (~> 0.8.1)
83
- slop (~> 3.4)
84
- public_suffix (2.0.4)
85
- rainbow (2.1.0)
86
- rake (10.5.0)
87
- rb-fsevent (0.9.8)
88
- rb-inotify (0.9.7)
89
- ffi (>= 0.5.0)
90
- rspec (3.5.0)
91
- rspec-core (~> 3.5.0)
92
- rspec-expectations (~> 3.5.0)
93
- rspec-mocks (~> 3.5.0)
94
- rspec-core (3.5.4)
95
- rspec-support (~> 3.5.0)
96
- rspec-expectations (3.5.0)
96
+ parallel (1.20.1)
97
+ parser (2.7.2.0)
98
+ ast (~> 2.4.1)
99
+ powerpack (0.1.3)
100
+ pry (0.14.1)
101
+ coderay (~> 1.1)
102
+ method_source (~> 1.0)
103
+ public_suffix (4.0.6)
104
+ rainbow (2.2.2)
105
+ rake
106
+ rake (13.0.3)
107
+ rb-fsevent (0.11.0)
108
+ rb-inotify (0.10.1)
109
+ ffi (~> 1.0)
110
+ rchardet (1.8.0)
111
+ rexml (3.2.5)
112
+ rspec (3.10.0)
113
+ rspec-core (~> 3.10.0)
114
+ rspec-expectations (~> 3.10.0)
115
+ rspec-mocks (~> 3.10.0)
116
+ rspec-core (3.10.1)
117
+ rspec-support (~> 3.10.0)
118
+ rspec-expectations (3.10.1)
97
119
  diff-lcs (>= 1.2.0, < 2.0)
98
- rspec-support (~> 3.5.0)
99
- rspec-mocks (3.5.0)
120
+ rspec-support (~> 3.10.0)
121
+ rspec-mocks (3.10.2)
100
122
  diff-lcs (>= 1.2.0, < 2.0)
101
- rspec-support (~> 3.5.0)
102
- rspec-support (3.5.0)
103
- rubocop (0.45.0)
104
- parser (>= 2.3.1.1, < 3.0)
123
+ rspec-support (~> 3.10.0)
124
+ rspec-support (3.10.2)
125
+ rubocop (0.49.1)
126
+ parallel (~> 1.10)
127
+ parser (>= 2.3.3.1, < 3.0)
105
128
  powerpack (~> 0.1)
106
129
  rainbow (>= 1.99.1, < 3.0)
107
130
  ruby-progressbar (~> 1.7)
@@ -109,32 +132,32 @@ GEM
109
132
  ruby-ll (2.1.2)
110
133
  ansi
111
134
  ast
112
- ruby-progressbar (1.8.1)
113
- sawyer (0.8.1)
114
- addressable (>= 2.3.5, < 2.6)
115
- faraday (~> 0.8, < 1.0)
135
+ ruby-progressbar (1.11.0)
136
+ ruby2_keywords (0.0.4)
137
+ sawyer (0.8.2)
138
+ addressable (>= 2.3.5)
139
+ faraday (> 0.8, < 2.0)
116
140
  shellany (0.0.1)
117
- slop (3.6.0)
118
- terminal-table (1.7.3)
119
- unicode-display_width (~> 1.1.1)
120
- thor (0.19.1)
121
- unicode-display_width (1.1.1)
122
- yard (0.9.5)
141
+ terminal-table (3.0.1)
142
+ unicode-display_width (>= 1.1.1, < 3)
143
+ thor (1.1.0)
144
+ unicode-display_width (1.7.0)
145
+ yard (0.9.26)
123
146
 
124
147
  PLATFORMS
125
- ruby
148
+ universal-darwin-20
126
149
 
127
150
  DEPENDENCIES
128
- bundler (~> 1.3)
151
+ bundler (>= 2.2.10)
129
152
  danger-android_lint!
130
153
  guard (~> 2.14)
131
154
  guard-rspec (~> 4.7)
132
155
  listen (= 3.0.7)
133
156
  pry
134
- rake (~> 10.0)
157
+ rake (~> 13.0)
135
158
  rspec (~> 3.4)
136
- rubocop (~> 0.41)
137
- yard (~> 0.8)
159
+ rubocop (~> 0.49.0)
160
+ yard (~> 0.9.11)
138
161
 
139
162
  BUNDLED WITH
140
- 1.12.5
163
+ 2.2.10
data/README.md CHANGED
@@ -49,6 +49,24 @@ android_lint.gradle_task = "lintMyFlavorDebug"
49
49
  android_lint.lint
50
50
  ```
51
51
 
52
+ #### Skip gradle task execution
53
+
54
+ If you want to skip the gradle task execution. You can achieve that by simply changing the value of `skip_gradle_task`. Default is `false`.
55
+
56
+ ```rb
57
+ android_lint.skip_gradle_task = true
58
+ android_lint.lint
59
+ ```
60
+
61
+ #### Changing report's file path
62
+
63
+ If you're using a path to output your report file other than the default one, you can specify it by setting a new value to `report_file`:
64
+
65
+ ```rb
66
+ android_lint.report_file = "your/report/file.xml"
67
+ android_lint.lint
68
+ ```
69
+
52
70
  #### Changing report's severity level
53
71
 
54
72
  If you want to filter lint issues based on their severity level, you can do that by setting a value to `severity`. Bear in mind that you are filtering issues by the severity level you've set **and up**. Possible values are `Warning`, `Error` and `Fatal`. Default is `Warning` (which is everything).
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ task default: :specs
8
8
 
9
9
  task :spec do
10
10
  Rake::Task['specs'].invoke
11
- Rake::Task['rubocop'].invoke
11
+ # Rake::Task['rubocop'].invoke
12
12
  Rake::Task['spec_docs'].invoke
13
13
  end
14
14
 
data/atlantis.yaml ADDED
@@ -0,0 +1,5 @@
1
+ version: 3
2
+ projects:
3
+ - dir: .
4
+ autoplan:
5
+ enabled: false
@@ -23,15 +23,15 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
24
24
 
25
25
  # General ruby development
26
- spec.add_development_dependency 'bundler', '~> 1.3'
27
- spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'bundler', '>= 2.2.10'
27
+ spec.add_development_dependency 'rake', '~> 13.0'
28
28
 
29
29
  # Testing support
30
30
  spec.add_development_dependency 'rspec', '~> 3.4'
31
31
 
32
32
  # Linting code and docs
33
- spec.add_development_dependency "rubocop", "~> 0.41"
34
- spec.add_development_dependency "yard", "~> 0.8"
33
+ spec.add_development_dependency "rubocop", "~> 0.49.0"
34
+ spec.add_development_dependency "yard", "~> 0.9.11"
35
35
 
36
36
  # Makes testing easy via `bundle exec guard`
37
37
  spec.add_development_dependency 'guard', '~> 2.14'
@@ -1,3 +1,3 @@
1
1
  module AndroidLint
2
- VERSION = "0.0.4".freeze
2
+ VERSION = "0.0.9".freeze
3
3
  end
@@ -13,6 +13,11 @@ module Danger
13
13
  # android_lint.gradle_task = "lintMyFlavorDebug"
14
14
  # android_lint.lint
15
15
  #
16
+ # @example Running AndroidLint without running a Gradle task
17
+ #
18
+ # android_lint.skip_gradle_task = true
19
+ # android_lint.lint
20
+ #
16
21
  # @example Running AndroidLint for a specific severity level and up
17
22
  #
18
23
  # # options are ["Warning", "Error", "Fatal"]
@@ -31,6 +36,7 @@ module Danger
31
36
  # Defaults to "app/build/reports/lint/lint-result.xml".
32
37
  # @return [String]
33
38
  attr_accessor :report_file
39
+
34
40
  # A getter for `report_file`.
35
41
  # @return [String]
36
42
  def report_file
@@ -43,6 +49,24 @@ module Danger
43
49
  # @return [String]
44
50
  attr_accessor :gradle_task
45
51
 
52
+ # A getter for `gradle_task`, returning "lint" if value is nil.
53
+ # @return [String]
54
+ def gradle_task
55
+ @gradle_task ||= "lint"
56
+ end
57
+
58
+ # Skip Gradle task.
59
+ # This is useful when Gradle task has been already executed.
60
+ # Defaults to `false`.
61
+ # @return [Bool]
62
+ attr_writer :skip_gradle_task
63
+
64
+ # A getter for `skip_gradle_task`, returning `false` if value is nil.
65
+ # @return [Boolean]
66
+ def skip_gradle_task
67
+ @skip_gradle_task ||= false
68
+ end
69
+
46
70
  # Defines the severity level of the execution.
47
71
  # Selected levels are the chosen one and up.
48
72
  # Possible values are "Warning", "Error" or "Fatal".
@@ -50,10 +74,19 @@ module Danger
50
74
  # @return [String]
51
75
  attr_writer :severity
52
76
 
77
+ # A getter for `severity`, returning "Warning" if value is nil.
78
+ # @return [String]
79
+ def severity
80
+ @severity || SEVERITY_LEVELS.first
81
+ end
82
+
53
83
  # Enable filtering
54
84
  # Only show messages within changed files.
55
85
  attr_accessor :filtering
56
86
 
87
+ # Only shows messages for the modified lines.
88
+ attr_accessor :filtering_lines
89
+
57
90
  # Calls lint task of your gradle project.
58
91
  # It fails if `gradlew` cannot be found inside current directory.
59
92
  # It fails if `severity` level is not a valid option.
@@ -61,9 +94,8 @@ module Danger
61
94
  # @return [void]
62
95
  #
63
96
  def lint(inline_mode: false)
64
- unless gradlew_exists?
65
- fail("Could not find `gradlew` inside current directory")
66
- return
97
+ unless skip_gradle_task
98
+ return fail("Could not find `gradlew` inside current directory") unless gradlew_exists?
67
99
  end
68
100
 
69
101
  unless SEVERITY_LEVELS.include?(severity)
@@ -71,7 +103,9 @@ module Danger
71
103
  return
72
104
  end
73
105
 
74
- system "./gradlew #{gradle_task || 'lint'}"
106
+ unless skip_gradle_task
107
+ system "./gradlew #{gradle_task}"
108
+ end
75
109
 
76
110
  unless File.exists?(report_file)
77
111
  fail("Lint report not found at `#{report_file}`. "\
@@ -81,19 +115,17 @@ module Danger
81
115
  issues = read_issues_from_report
82
116
  filtered_issues = filter_issues_by_severity(issues)
83
117
 
118
+ message = ""
119
+
84
120
  if inline_mode
85
121
  # Report with inline comment
86
122
  send_inline_comment(filtered_issues)
87
123
  else
88
124
  message = message_for_issues(filtered_issues)
89
- markdown(message) unless filtered_issues.empty?
125
+ markdown("### AndroidLint found issues\n\n" + message) unless message.to_s.empty?
90
126
  end
91
- end
92
127
 
93
- # A getter for `severity`, returning "Warning" if value is nil.
94
- # @return [String]
95
- def severity
96
- @severity || SEVERITY_LEVELS.first
128
+ message
97
129
  end
98
130
 
99
131
  private
@@ -118,7 +150,7 @@ module Danger
118
150
  end
119
151
 
120
152
  def message_for_issues(issues)
121
- message = "### AndroidLint found issues\n\n"
153
+ message = ""
122
154
 
123
155
  SEVERITY_LEVELS.reverse.each do |level|
124
156
  filtered = issues.select{|issue| issue.get("severity") == level}
@@ -131,10 +163,8 @@ module Danger
131
163
  def parse_results(results, heading)
132
164
  target_files = (git.modified_files - git.deleted_files) + git.added_files
133
165
  dir = "#{Dir.pwd}/"
134
- message = "#### #{heading} (#{results.count})\n\n"
135
-
136
- message << "| File | Line | Reason |\n"
137
- message << "| ---- | ---- | ------ |\n"
166
+ count = 0;
167
+ message = ""
138
168
 
139
169
  results.each do |r|
140
170
  location = r.xpath('location').first
@@ -142,9 +172,15 @@ module Danger
142
172
  next unless !filtering || (target_files.include? filename)
143
173
  line = location.get('line') || 'N/A'
144
174
  reason = r.get('message')
145
-
175
+ count = count + 1
146
176
  message << "`#{filename}` | #{line} | #{reason} \n"
147
177
  end
178
+ if count != 0
179
+ header = "#### #{heading} (#{count})\n\n"
180
+ header << "| File | Line | Reason |\n"
181
+ header << "| ---- | ---- | ------ |\n"
182
+ message = header + message
183
+ end
148
184
 
149
185
  message
150
186
  end
@@ -162,13 +198,42 @@ module Danger
162
198
  filtered.each do |r|
163
199
  location = r.xpath('location').first
164
200
  filename = location.get('file').gsub(dir, "")
165
- next unless !filtering || (target_files.include? filename)
201
+ next unless (!filtering && !filtering_lines) || (target_files.include? filename)
166
202
  line = (location.get('line') || "0").to_i
203
+ if filtering_lines
204
+ added_lines = parseDiff(git.diff[filename].patch)
205
+ next unless added_lines.include? line
206
+ end
167
207
  send(level === "Warning" ? "warn" : "fail", r.get('message'), file: filename, line: line)
168
208
  end
169
209
  end
170
210
  end
171
211
 
212
+ # parses git diff of a file and retuns an array of added line numbers.
213
+ def parseDiff(diff)
214
+ current_line_number = nil
215
+ added_lines = []
216
+ diff_lines = diff.strip.split("\n")
217
+ diff_lines.each_with_index do |line, index|
218
+ if m = /\+(\d+)(?:,\d+)? @@/.match(line)
219
+ # (e.g. @@ -32,10 +32,7 @@)
220
+ current_line_number = Integer(m[1])
221
+ else
222
+ if !current_line_number.nil?
223
+ if line.start_with?('+')
224
+ # added line
225
+ added_lines.push current_line_number
226
+ current_line_number += 1
227
+ elsif !line.start_with?('-')
228
+ # unmodified line
229
+ current_line_number += 1
230
+ end
231
+ end
232
+ end
233
+ end
234
+ added_lines
235
+ end
236
+
172
237
  def gradlew_exists?
173
238
  `ls gradlew`.strip.empty? == false
174
239
  end
@@ -25,6 +25,26 @@ module Danger
25
25
  expect(@android_lint.status_report[:errors]).to eq(["Could not find `gradlew` inside current directory"])
26
26
  end
27
27
 
28
+ it "Set custom Gradle task" do
29
+ custom_task = "lintRelease"
30
+ @android_lint.gradle_task = custom_task
31
+ expect(@android_lint.gradle_task).to eq(custom_task)
32
+ end
33
+
34
+ it "Check default Gradle task" do
35
+ expect(@android_lint.gradle_task).to eq("lint")
36
+ end
37
+
38
+ it "Skip Gradle task" do
39
+ skip_gradle_task = true
40
+ @android_lint.skip_gradle_task = skip_gradle_task
41
+ expect(@android_lint.skip_gradle_task).to eq(skip_gradle_task)
42
+ end
43
+
44
+ it "Check default skip Gradle task" do
45
+ expect(@android_lint.skip_gradle_task).to eq(false)
46
+ end
47
+
28
48
  it "Fails if severity is an unknown value" do
29
49
  allow(@android_lint).to receive(:`).with("ls gradlew").and_return("gradlew")
30
50
  allow(File).to receive(:exists?).with(@android_lint.report_file()).and_return(true)
@@ -49,7 +69,7 @@ module Danger
49
69
  it "Sets the report file to a default location if no param is provided" do
50
70
  allow(@android_lint).to receive(:`).with("ls gradlew").and_return("gradlew")
51
71
  allow(File).to receive(:exists?).with(@android_lint.report_file).and_return(true)
52
-
72
+
53
73
  fake_result = File.open("spec/fixtures/lint-result-with-everything.xml")
54
74
  allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
55
75
 
@@ -65,7 +85,7 @@ module Danger
65
85
  fake_result = File.open("spec/fixtures/lint-result-with-everything.xml")
66
86
  allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
67
87
  allow(File).to receive(:exists?).with(@android_lint.report_file).and_return(true)
68
-
88
+
69
89
  @android_lint.lint
70
90
 
71
91
  expect(@android_lint.report_file).to eq('some/other/location/lint-result.xml')
@@ -91,6 +111,19 @@ module Danger
91
111
  end
92
112
 
93
113
  it 'Prints markdown if issues were found' do
114
+ fake_result = File.open("spec/fixtures/lint-result-with-special-chars.xml")
115
+ allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
116
+
117
+ @android_lint.lint
118
+
119
+ markdown = @android_lint.status_report[:markdowns].first.message
120
+ expect(markdown).to include("AndroidLint found issues")
121
+
122
+ expect(markdown).to include("Warning (1)")
123
+ expect(markdown).to include("`app/src/main/res/values/strings.xml` | 105 | The resource `R.string.authentication_invalid_auth_token_type` appears to be unused")
124
+ end
125
+
126
+ it 'Prints markdown if issues were found even if there is a special char' do
94
127
  fake_result = File.open("spec/fixtures/lint-result-with-everything.xml")
95
128
  allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
96
129
 
@@ -101,12 +134,6 @@ module Danger
101
134
 
102
135
  expect(markdown).to include("Fatal (1)")
103
136
  expect(markdown).to include("`/Users/gustavo/Developer/app-android/app/src/main/java/com/loadsmart/common/views/AvatarView.java` | 60 | Implicitly using the default locale is a common source of bugs: Use `toUpperCase(Locale)` instead")
104
-
105
- expect(markdown).to include("Error (1)")
106
- expect(markdown).to include("`/Users/gustavo/Developer/app-android/app/src/main/java/com/loadsmart/analytics/Events.java` | 21 | Implicitly using the default locale is a common source of bugs: Use `String.format(Locale, ...)` instead")
107
-
108
- expect(markdown).to include("Warning (1)")
109
- expect(markdown).to include("`/Users/gustavo/Developer/app-android/app/src/main/java/com/loadsmart/analytics/Events.java` | 24 | Implicitly using the default locale is a common source of bugs: Use `String.format(Locale, ...)` instead")
110
137
  end
111
138
 
112
139
  it 'Doesn`t print anything if no errors were found' do
@@ -161,8 +188,50 @@ module Danger
161
188
  expect(warn).not_to include("Implicitly using the default locale is a common source of bugs: Use `String.format(Locale, ...)` instead")
162
189
  end
163
190
 
164
- end
191
+ describe "for a modified file" do
192
+ before do
193
+ allow(Dir).to receive(:pwd).and_return("/Users/shivampokhriyal/Documents/projects/Commcare/commcare-android")
194
+
195
+ allow(@android_lint.git).to receive(:modified_files).and_return([
196
+ "app/build.gradle",
197
+ ])
198
+
199
+ fake_patch = File.read("spec/fixtures/pr-diff.diff")
200
+ diff = [OpenStruct.new(type: "modified", path: "app/build.gradle")]
201
+ allow(@android_lint.git).to receive(:diff).and_return(diff)
202
+ diff_for_file = OpenStruct.new(insertions: 3)
203
+ allow(diff).to receive(:[]).with("app/build.gradle").and_return(diff_for_file)
204
+ allow(diff_for_file).to receive(:patch).and_return(fake_patch)
165
205
 
206
+ fake_result = File.open("spec/fixtures/lint-result-for-pr.xml")
207
+ allow(File).to receive(:open).with(@android_lint.report_file).and_return(fake_result)
208
+ end
209
+
210
+ it 'with filtering_lines, only show issues in modified lines' do
211
+ @android_lint.filtering_lines = true
212
+ @android_lint.lint inline_mode: true
213
+
214
+ error = @android_lint.status_report[:errors]
215
+ expect(error).to include("fake message three")
216
+
217
+ expect(error).not_to include("fake message one")
218
+ expect(error).not_to include("fake message two")
219
+ expect(error).not_to include("fake message in unmodified file")
220
+ end
221
+
222
+ it 'with filtering, show all issues in modified files' do
223
+ @android_lint.filtering = true
224
+ @android_lint.lint inline_mode: true
225
+
226
+ error = @android_lint.status_report[:errors]
227
+ expect(error).to include("fake message one")
228
+ expect(error).to include("fake message two")
229
+ expect(error).to include("fake message three")
230
+
231
+ expect(error).not_to include("fake message in unmodified file")
232
+ end
233
+ end
234
+ end
166
235
  end
167
236
  end
168
237
  end
@@ -0,0 +1,62 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <issues format="5" by="lint 4.0.0">
3
+ <issue
4
+ id="DuplicatePlatformClasses"
5
+ severity="Error"
6
+ message="fake message one"
7
+ category="Correctness"
8
+ priority="8"
9
+ summary="Duplicate Platform Classes"
10
+ explanation="There are a number of libraries that duplicate not just functionality of the Android platform but using the exact same class names as the ones provided in Android -- for example the apache http classes. This can lead to unexpected crashes.&#xA;&#xA;To solve this, you need to either find a newer version of the library which no longer has this problem, or to repackage the library (and all of its dependencies) using something like the `jarjar` tool, or finally, rewriting the code to use different APIs (for example, for http code, consider using `HttpUrlConnection` or a library like `okhttp`).">
11
+ <location
12
+ file="/Users/shivampokhriyal/Documents/projects/Commcare/commcare-android/app/build.gradle"/>
13
+ </issue>
14
+
15
+ <issue
16
+ id="DuplicatePlatformClasses"
17
+ severity="Error"
18
+ message="fake message two"
19
+ category="Correctness"
20
+ priority="8"
21
+ summary="Duplicate Platform Classes"
22
+ explanation="There are a number of libraries that duplicate not just functionality of the Android platform but using the exact same class names as the ones provided in Android -- for example the apache http classes. This can lead to unexpected crashes.&#xA;&#xA;To solve this, you need to either find a newer version of the library which no longer has this problem, or to repackage the library (and all of its dependencies) using something like the `jarjar` tool, or finally, rewriting the code to use different APIs (for example, for http code, consider using `HttpUrlConnection` or a library like `okhttp`)."
23
+ errorLine1=" testImplementation &apos;org.json:json:20140107&apos;"
24
+ errorLine2=" ~~~~~~~~~~~~~">
25
+ <location
26
+ file="/Users/shivampokhriyal/Documents/projects/Commcare/commcare-android/app/build.gradle"
27
+ line="52"
28
+ column="25"/>
29
+ </issue>
30
+
31
+ <issue
32
+ id="FakeId"
33
+ severity="Error"
34
+ message="fake message three"
35
+ category="Correctness"
36
+ priority="8"
37
+ summary="Fake summary"
38
+ explanation="Fake explanation."
39
+ errorLine1="// debugImplementation because LeakCanary should only run in debug builds."
40
+ errorLine2=" ~~~~~~~~~~~~~">
41
+ <location
42
+ file="/Users/shivampokhriyal/Documents/projects/Commcare/commcare-android/app/build.gradle"
43
+ line="36"
44
+ column="10"/>
45
+ </issue>
46
+
47
+ <issue
48
+ id="2"
49
+ severity="Error"
50
+ message="fake message in unmodified file"
51
+ category="Correctness"
52
+ priority="8"
53
+ summary="Fake summary"
54
+ explanation="Fake explanation."
55
+ errorLine1="// debugImplementation because LeakCanary should only run in debug builds."
56
+ errorLine2=" ~~~~~~~~~~~~~">
57
+ <location
58
+ file="/Users/shivampokhriyal/Documents/projects/Commcare/commcare-android/app/AndroidManifest.xml"
59
+ line="36"
60
+ column="10"/>
61
+ </issue>
62
+ </issues>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <issues format="4" by="lint 25.2.2">
3
+ <issue
4
+ id="UnusedResources"
5
+ severity="Warning"
6
+ message="The resource `R.string.authentication_invalid_auth_token_type` appears to be unused"
7
+ category="Performance"
8
+ priority="3"
9
+ summary="Unused resources"
10
+ explanation="Unused resources make applications larger and slow down builds."
11
+ errorLine1=" &lt;string name=&quot;authentication_invalid_auth_token_type&quot;>Autenticação inválida.&lt;/string>"
12
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
13
+ quickfix="studio">
14
+ <location
15
+ file="app/src/main/res/values/strings.xml"
16
+ line="105"
17
+ column="13"/>
18
+ </issue>
19
+ </issues>
@@ -0,0 +1,14 @@
1
+ diff --git a/app/build.gradle b/app/build.gradle
2
+ index 6dcc647b8..a1365bd75 100644
3
+ --- a/app/build.gradle
4
+ +++ b/app/build.gradle
5
+ @@ -33,6 +33,9 @@ configurations {
6
+ }
7
+
8
+ dependencies {
9
+ + // debugImplementation because LeakCanary should only run in debug builds.
10
+ + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
11
+ +
12
+ testImplementation 'junit:junit:4.12'
13
+ testImplementation('org.robolectric:robolectric:4.3.1') {
14
+ exclude(group: 'org.bouncycastle', module: 'bcprov-jdk15on')
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-android_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Barbosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-01 00:00:00.000000000 Z
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oga
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: danger-plugin-api
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: 2.2.10
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
54
+ version: 2.2.10
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '13.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '13.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '3.4'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.4'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.41'
89
+ version: 0.49.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.41'
96
+ version: 0.49.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: yard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.8'
103
+ version: 0.9.11
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.8'
110
+ version: 0.9.11
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: guard
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '2.14'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '2.14'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: guard-rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '4.7'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '4.7'
139
139
  - !ruby/object:Gem::Dependency
@@ -154,14 +154,14 @@ dependencies:
154
154
  name: pry
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  description: A Danger plugin for Android Lint
@@ -171,7 +171,10 @@ executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
- - .gitignore
174
+ - ".circleci/config.yml"
175
+ - ".github/CODEOWNERS"
176
+ - ".gitignore"
177
+ - ".ruby-version"
175
178
  - CHANGELOG.md
176
179
  - Gemfile
177
180
  - Gemfile.lock
@@ -179,6 +182,7 @@ files:
179
182
  - LICENSE.txt
180
183
  - README.md
181
184
  - Rakefile
185
+ - atlantis.yaml
182
186
  - danger-android_lint.gemspec
183
187
  - lib/android_lint/gem_version.rb
184
188
  - lib/android_lint/plugin.rb
@@ -186,8 +190,11 @@ files:
186
190
  - lib/danger_plugin.rb
187
191
  - spec/android_lint_spec.rb
188
192
  - spec/fixtures/lint-result-empty.xml
193
+ - spec/fixtures/lint-result-for-pr.xml
189
194
  - spec/fixtures/lint-result-with-everything.xml
195
+ - spec/fixtures/lint-result-with-special-chars.xml
190
196
  - spec/fixtures/lint-result-without-fatal.xml
197
+ - spec/fixtures/pr-diff.diff
191
198
  - spec/spec_helper.rb
192
199
  homepage: https://github.com/loadsmart/danger-android_lint
193
200
  licenses:
@@ -199,17 +206,16 @@ require_paths:
199
206
  - lib
200
207
  required_ruby_version: !ruby/object:Gem::Requirement
201
208
  requirements:
202
- - - '>='
209
+ - - ">="
203
210
  - !ruby/object:Gem::Version
204
211
  version: '0'
205
212
  required_rubygems_version: !ruby/object:Gem::Requirement
206
213
  requirements:
207
- - - '>='
214
+ - - ">="
208
215
  - !ruby/object:Gem::Version
209
216
  version: '0'
210
217
  requirements: []
211
- rubyforge_project:
212
- rubygems_version: 2.0.3
218
+ rubygems_version: 3.0.3
213
219
  signing_key:
214
220
  specification_version: 4
215
221
  summary: Lint files of a gradle based Android project. This is done using the Android's
@@ -217,7 +223,9 @@ summary: Lint files of a gradle based Android project. This is done using the An
217
223
  test_files:
218
224
  - spec/android_lint_spec.rb
219
225
  - spec/fixtures/lint-result-empty.xml
226
+ - spec/fixtures/lint-result-for-pr.xml
220
227
  - spec/fixtures/lint-result-with-everything.xml
228
+ - spec/fixtures/lint-result-with-special-chars.xml
221
229
  - spec/fixtures/lint-result-without-fatal.xml
230
+ - spec/fixtures/pr-diff.diff
222
231
  - spec/spec_helper.rb
223
- has_rdoc: