danger-android_lint 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a23cf2639550cda7bae6d9c49eec3f24564da9ef
4
- data.tar.gz: 8aae8686cd7d2ab3c1bc344716cdbe67c9bcf2bb
3
+ metadata.gz: 6fb3bbc5b97d33a9495f3c3811b6a3dbe6932dcc
4
+ data.tar.gz: 2c2d08a45644d86fbd60364fc80ec2bbfbe8eac9
5
5
  SHA512:
6
- metadata.gz: bff880a4f7ec5dcc46337d794bbf4439878984d51d477c0d55253a8fa61c63538e6a84d43fcfcbc4e976cbec79e71a232615131d2476dbe04b7f4500289cd127
7
- data.tar.gz: 83aadd5d46813762ad94ca152757c1a4156989c780d48622f6f23fc163671ff0abd6c477d43fe72e1fe723042d865c0bec8bf5b26d50d1e6cb8222194fc09fdf
6
+ metadata.gz: 6fb633fd0c8c48391c4097103e0779ca0d8eff4d6bfcb6824c9400f1a0911c00c5b06d4c122fefcb6eb59745e7155411d5f77f5844ef17103835a61a9465f94c
7
+ data.tar.gz: 4a10c53f60ebb6db842c88e08c3121bd42c95811f0c639578c73dbc12e7e32cab1763ba24e3b007ffc23d6651038c206af76ddeb9d07c140dbd2bf8faf23faea
@@ -0,0 +1 @@
1
+ 2.3.5
@@ -1,5 +1,10 @@
1
+ # 0.0.8
2
+ - Fix security issues ([@barbosa](https://github.com/barbosa))
3
+ - Expose report message ([@adamstrange])(https://github.com/adamstrange))
4
+ - Skip gradle task ([@mathroule])(https://github.com/mathroule))
5
+
1
6
  # 0.0.7
2
- - Bump ffi version due to security reasons ([@barbosa](https://github.com/barbosa))
7
+ - Fix security issues ([@barbosa](https://github.com/barbosa))
3
8
 
4
9
  # 0.0.6
5
10
  - Bump yarn and rubocop versions due to security issues ([@barbosa](https://github.com/barbosa))
data/Gemfile CHANGED
@@ -2,4 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in danger-android_lint.gemspec
4
4
  gemspec
5
- gem "ffi", ">= 1.9.24"
@@ -8,11 +8,11 @@ PATH
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.5.2)
12
- public_suffix (>= 2.0.2, < 4.0)
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
13
  ansi (1.5.0)
14
14
  ast (2.4.0)
15
- claide (1.0.2)
15
+ claide (1.0.3)
16
16
  claide-plugins (0.9.2)
17
17
  cork
18
18
  nap
@@ -21,13 +21,13 @@ GEM
21
21
  colored2 (3.1.2)
22
22
  cork (0.3.0)
23
23
  colored2 (~> 3.1)
24
- danger (6.0.3)
24
+ danger (6.1.0)
25
25
  claide (~> 1.0)
26
26
  claide-plugins (>= 0.9.2)
27
27
  colored2 (~> 3.1)
28
28
  cork (~> 0.1)
29
29
  faraday (~> 0.9)
30
- faraday-http-cache (~> 1.0)
30
+ faraday-http-cache (~> 2.0)
31
31
  git (~> 1.5)
32
32
  kramdown (~> 2.0)
33
33
  kramdown-parser-gfm (~> 1.0)
@@ -37,14 +37,14 @@ GEM
37
37
  danger-plugin-api (1.0.0)
38
38
  danger (> 2.0)
39
39
  diff-lcs (1.3)
40
- faraday (0.15.4)
40
+ faraday (0.17.1)
41
41
  multipart-post (>= 1.2, < 3)
42
- faraday-http-cache (1.3.1)
42
+ faraday-http-cache (2.0.0)
43
43
  faraday (~> 0.8)
44
- ffi (1.10.0)
44
+ ffi (1.11.3)
45
45
  formatador (0.2.5)
46
46
  git (1.5.0)
47
- guard (2.15.0)
47
+ guard (2.16.1)
48
48
  formatador (>= 0.2.4)
49
49
  listen (>= 2.7, < 4.0)
50
50
  lumberjack (>= 1.0.12, < 2.0)
@@ -59,53 +59,53 @@ GEM
59
59
  guard-compat (~> 1.1)
60
60
  rspec (>= 2.99.0, < 4.0)
61
61
  kramdown (2.1.0)
62
- kramdown-parser-gfm (1.0.1)
62
+ kramdown-parser-gfm (1.1.0)
63
63
  kramdown (~> 2.0)
64
64
  listen (3.0.7)
65
65
  rb-fsevent (>= 0.9.3)
66
66
  rb-inotify (>= 0.9.7)
67
67
  lumberjack (1.0.13)
68
68
  method_source (0.9.2)
69
- multipart-post (2.0.0)
69
+ multipart-post (2.1.1)
70
70
  nap (1.1.0)
71
71
  nenv (0.3.0)
72
72
  no_proxy_fix (0.1.2)
73
- notiffany (0.1.1)
73
+ notiffany (0.1.3)
74
74
  nenv (~> 0.1)
75
75
  shellany (~> 0.0)
76
76
  octokit (4.14.0)
77
77
  sawyer (~> 0.8.0, >= 0.5.3)
78
- oga (2.15)
78
+ oga (3.0)
79
79
  ast
80
80
  ruby-ll (~> 2.1)
81
81
  open4 (1.3.4)
82
- parallel (1.17.0)
83
- parser (2.6.2.1)
82
+ parallel (1.19.1)
83
+ parser (2.6.5.0)
84
84
  ast (~> 2.4.0)
85
85
  powerpack (0.1.2)
86
86
  pry (0.12.2)
87
87
  coderay (~> 1.1.0)
88
88
  method_source (~> 0.9.0)
89
- public_suffix (3.0.3)
89
+ public_suffix (4.0.1)
90
90
  rainbow (2.2.2)
91
91
  rake
92
92
  rake (10.5.0)
93
93
  rb-fsevent (0.10.3)
94
- rb-inotify (0.10.0)
94
+ rb-inotify (0.10.1)
95
95
  ffi (~> 1.0)
96
- rspec (3.8.0)
97
- rspec-core (~> 3.8.0)
98
- rspec-expectations (~> 3.8.0)
99
- rspec-mocks (~> 3.8.0)
100
- rspec-core (3.8.0)
101
- rspec-support (~> 3.8.0)
102
- rspec-expectations (3.8.2)
96
+ rspec (3.9.0)
97
+ rspec-core (~> 3.9.0)
98
+ rspec-expectations (~> 3.9.0)
99
+ rspec-mocks (~> 3.9.0)
100
+ rspec-core (3.9.0)
101
+ rspec-support (~> 3.9.0)
102
+ rspec-expectations (3.9.0)
103
103
  diff-lcs (>= 1.2.0, < 2.0)
104
- rspec-support (~> 3.8.0)
105
- rspec-mocks (3.8.0)
104
+ rspec-support (~> 3.9.0)
105
+ rspec-mocks (3.9.0)
106
106
  diff-lcs (>= 1.2.0, < 2.0)
107
- rspec-support (~> 3.8.0)
108
- rspec-support (3.8.0)
107
+ rspec-support (~> 3.9.0)
108
+ rspec-support (3.9.0)
109
109
  rubocop (0.49.1)
110
110
  parallel (~> 1.10)
111
111
  parser (>= 2.3.3.1, < 3.0)
@@ -116,24 +116,23 @@ GEM
116
116
  ruby-ll (2.1.2)
117
117
  ansi
118
118
  ast
119
- ruby-progressbar (1.10.0)
120
- sawyer (0.8.1)
121
- addressable (>= 2.3.5, < 2.6)
122
- faraday (~> 0.8, < 1.0)
119
+ ruby-progressbar (1.10.1)
120
+ sawyer (0.8.2)
121
+ addressable (>= 2.3.5)
122
+ faraday (> 0.8, < 2.0)
123
123
  shellany (0.0.1)
124
124
  terminal-table (1.8.0)
125
125
  unicode-display_width (~> 1.1, >= 1.1.1)
126
- thor (0.20.3)
127
- unicode-display_width (1.5.0)
128
- yard (0.9.19)
126
+ thor (1.0.1)
127
+ unicode-display_width (1.6.0)
128
+ yard (0.9.20)
129
129
 
130
130
  PLATFORMS
131
131
  ruby
132
132
 
133
133
  DEPENDENCIES
134
- bundler (~> 2.0)
134
+ bundler (~> 1.3)
135
135
  danger-android_lint!
136
- ffi (>= 1.9.24)
137
136
  guard (~> 2.14)
138
137
  guard-rspec (~> 4.7)
139
138
  listen (= 3.0.7)
@@ -144,4 +143,4 @@ DEPENDENCIES
144
143
  yard (~> 0.9.11)
145
144
 
146
145
  BUNDLED WITH
147
- 2.0.1
146
+ 1.17.3
data/README.md CHANGED
@@ -49,7 +49,9 @@ android_lint.gradle_task = "lintMyFlavorDebug"
49
49
  android_lint.lint
50
50
  ```
51
51
 
52
- If you want to skip gradle task, setting the `skip_gradle_task` parameter to `true`.
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`.
53
55
 
54
56
  ```rb
55
57
  android_lint.skip_gradle_task = true
@@ -23,7 +23,7 @@ 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', '~> 2.0'
26
+ spec.add_development_dependency 'bundler', '~> 1.3'
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
28
28
 
29
29
  # Testing support
@@ -1,3 +1,3 @@
1
1
  module AndroidLint
2
- VERSION = "0.0.7".freeze
2
+ VERSION = "0.0.8".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,13 +74,16 @@ 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
 
57
- # Skip gradle task
58
- attr_accessor :skip_gradle_task
59
-
60
87
  # Calls lint task of your gradle project.
61
88
  # It fails if `gradlew` cannot be found inside current directory.
62
89
  # It fails if `severity` level is not a valid option.
@@ -64,9 +91,8 @@ module Danger
64
91
  # @return [void]
65
92
  #
66
93
  def lint(inline_mode: false)
67
- if !skip_gradle_task && !gradlew_exists?
68
- fail("Could not find `gradlew` inside current directory")
69
- return
94
+ unless skip_gradle_task
95
+ return fail("Could not find `gradlew` inside current directory") unless gradlew_exists?
70
96
  end
71
97
 
72
98
  unless SEVERITY_LEVELS.include?(severity)
@@ -74,7 +100,9 @@ module Danger
74
100
  return
75
101
  end
76
102
 
77
- system "./gradlew #{gradle_task || 'lint'}" unless skip_gradle_task
103
+ unless skip_gradle_task
104
+ system "./gradlew #{gradle_task}"
105
+ end
78
106
 
79
107
  unless File.exists?(report_file)
80
108
  fail("Lint report not found at `#{report_file}`. "\
@@ -84,6 +112,8 @@ module Danger
84
112
  issues = read_issues_from_report
85
113
  filtered_issues = filter_issues_by_severity(issues)
86
114
 
115
+ message = ""
116
+
87
117
  if inline_mode
88
118
  # Report with inline comment
89
119
  send_inline_comment(filtered_issues)
@@ -91,12 +121,8 @@ module Danger
91
121
  message = message_for_issues(filtered_issues)
92
122
  markdown("### AndroidLint found issues\n\n" + message) unless message.to_s.empty?
93
123
  end
94
- end
95
-
96
- # A getter for `severity`, returning "Warning" if value is nil.
97
- # @return [String]
98
- def severity
99
- @severity || SEVERITY_LEVELS.first
124
+
125
+ message
100
126
  end
101
127
 
102
128
  private
@@ -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
@@ -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>
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Barbosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-09 00:00:00.000000000 Z
11
+ date: 2019-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oga
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.0'
47
+ version: '1.3'
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: '2.0'
54
+ version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -173,6 +173,7 @@ extra_rdoc_files: []
173
173
  files:
174
174
  - ".github/CODEOWNERS"
175
175
  - ".gitignore"
176
+ - ".ruby-version"
176
177
  - CHANGELOG.md
177
178
  - Gemfile
178
179
  - Gemfile.lock
@@ -188,6 +189,7 @@ files:
188
189
  - spec/android_lint_spec.rb
189
190
  - spec/fixtures/lint-result-empty.xml
190
191
  - spec/fixtures/lint-result-with-everything.xml
192
+ - spec/fixtures/lint-result-with-special-chars.xml
191
193
  - spec/fixtures/lint-result-without-fatal.xml
192
194
  - spec/spec_helper.rb
193
195
  homepage: https://github.com/loadsmart/danger-android_lint
@@ -210,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
212
  version: '0'
211
213
  requirements: []
212
214
  rubyforge_project:
213
- rubygems_version: 2.5.2.3
215
+ rubygems_version: 2.5.2.1
214
216
  signing_key:
215
217
  specification_version: 4
216
218
  summary: Lint files of a gradle based Android project. This is done using the Android's
@@ -219,5 +221,6 @@ test_files:
219
221
  - spec/android_lint_spec.rb
220
222
  - spec/fixtures/lint-result-empty.xml
221
223
  - spec/fixtures/lint-result-with-everything.xml
224
+ - spec/fixtures/lint-result-with-special-chars.xml
222
225
  - spec/fixtures/lint-result-without-fatal.xml
223
226
  - spec/spec_helper.rb