headdesk 0.12.0 → 0.13.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
  SHA256:
3
- metadata.gz: 32bd2bbb779c1bf25077fcbe9680c62e66237ca200b0d37c8d38a637ee0a80a4
4
- data.tar.gz: ba38100146dbaab98d4c355548980ca9133e5ba4fa1bc192b1ac6c2cfd7ea27a
3
+ metadata.gz: 7556187a87dbdfa6c3f9cec106695a8043091cd0c3cf43cfeb8d1b59bae32f2c
4
+ data.tar.gz: f968c92aa363c253af156ecf84e46b7319015ff1356e6cd4fbb550bbf06c360f
5
5
  SHA512:
6
- metadata.gz: c8998523ae8fc26ed6717b871399b0810435efab9bf88d900af6b61746b9dc5f6563b04c4e299dc33e0204adee5c8788b8d7fdd2127297d9e5f94fc972aa0c74
7
- data.tar.gz: fbd63dd5c57e087e658bfb487abbd7c690ee6c8aa137dd773b92c0e35a68f0c3fae23c59b85d834dd3b7035469ebe9b4bc4f0fda0e356506792bd2fc47595090
6
+ metadata.gz: 9690e535090b5c68192ff6fb04898f6517d47891c1f2196f2d926b1a8c7cdfe34a2795b28412c26bac5d29a0845ea76bef030ed53551da3a092859b06b78710c
7
+ data.tar.gz: ed9291760f36a5390a1bb5b867e663dd238915e6c0e1bc6e6deee31e273aee2e861aaa184864b10f79a15b8cc936783b5be2511c1f58e155004395971efd16d6
data/.gitignore CHANGED
@@ -7,4 +7,6 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ coverage
11
+
10
12
  .DS_Store
@@ -25,6 +25,7 @@ GEM
25
25
  descendants_tracker (0.0.4)
26
26
  thread_safe (~> 0.3, >= 0.3.1)
27
27
  diff-lcs (1.3)
28
+ docile (1.3.1)
28
29
  equalizer (0.0.11)
29
30
  gem-release (2.0.1)
30
31
  gems (1.1.1)
@@ -73,6 +74,11 @@ GEM
73
74
  ruby-progressbar (~> 1.7)
74
75
  unicode-display_width (~> 1.4.0)
75
76
  ruby-progressbar (1.10.0)
77
+ simplecov (0.16.1)
78
+ docile (~> 1.1)
79
+ json (>= 1.8, < 3)
80
+ simplecov-html (~> 0.10.0)
81
+ simplecov-html (0.10.2)
76
82
  thor (0.20.3)
77
83
  thread_safe (0.3.6)
78
84
  unicode-display_width (1.4.1)
@@ -93,6 +99,7 @@ DEPENDENCIES
93
99
  reek (~> 5.0)
94
100
  rspec (~> 3.8)
95
101
  rubocop (~> 0, >= 0.49.0)
102
+ simplecov (~> 0, >= 0.16.0)
96
103
 
97
104
  BUNDLED WITH
98
105
  2.0.1
data/README.md CHANGED
@@ -21,7 +21,6 @@ This is output from the check that ensures that the version of the Facebook SDK
21
21
  * [facebook](docs/facebook.md)
22
22
  * [receiver](docs/receiver.md)
23
23
  * [teak/api21_icon](docs/teak/api21_icon.md)
24
- * [teak/caching](docs/teak/caching.md)
25
24
  * [teak/configuration](docs/teak/configuration.md)
26
25
 
27
26
  ## Installation
@@ -0,0 +1,43 @@
1
+ # firebase_messaging_event
2
+ Ensures that there is only one `<service>` with `<intent-filter` for `com.google.firebase.MESSAGING_EVENT` declared in the `AndroidManifest.xml`
3
+
4
+ ## Will Fail If
5
+ * More than one `<service>` has an `<intent-filter>` for `com.google.firebase.MESSAGING_EVENT` without specifying an `android:priority`
6
+
7
+ ## Exports
8
+ The services which have an `<intent-filter>` for `com.google.firebase.MESSAGING_EVENT` present in `AndroidManifest.xml`
9
+
10
+ ### Example
11
+ ```json
12
+ {
13
+ "filters":[
14
+ {
15
+ "name":"com.google.firebase.messaging.FirebaseMessagingService",
16
+ "priority":-500
17
+ },
18
+ {
19
+ "name":"com.leanplum.LeanplumPushFirebaseMessagingService",
20
+ "priority":0
21
+ },
22
+ {
23
+ "name":"io.teak.sdk.push.FCMPushProvider",
24
+ "priority":0
25
+ }
26
+ ]
27
+ }
28
+ ```
29
+
30
+ ## Reason
31
+ If multiple listeners for `com.google.firebase.MESSAGING_EVENT` exist, only the highest priority `<service>` will receive the message. This can cause unexpected behavior.
32
+
33
+ ## Resolution
34
+ Remove the `<service>` blocks which have `<intent-filter>` for `com.google.firebase.MESSAGING_EVENT`, or add `android:priority` to the `<intent-filter>` to manually specify which `<service>` will process the message.
35
+
36
+ For example, this gets inserted by Firebase automatically, and sets its priority to `-500`:
37
+ ```xml
38
+ <service android:exported="false" android:name="com.google.firebase.messaging.FirebaseMessagingService">
39
+ <intent-filter android:priority="-500">
40
+ <action android:name="com.google.firebase.MESSAGING_EVENT"/>
41
+ </intent-filter>
42
+ </service>
43
+ ```
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = 'https://github.com/GoCarrot/headdesk'
16
16
  spec.license = 'MIT'
17
17
 
18
- spec.post_install_message = 'For breaking change announcements...'
18
+ # spec.post_install_message = 'For breaking change announcements...'
19
19
 
20
20
  # Specify which files should be added to the gem when it is released.
21
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'reek', '~> 5.0'
33
33
  spec.add_development_dependency 'rspec', '~> 3.8'
34
34
  spec.add_development_dependency 'rubocop', '~> 0', '>= 0.49.0'
35
+ spec.add_development_dependency 'simplecov', '~> 0', '>= 0.16.0'
35
36
 
36
37
  spec.add_dependency 'awesome_print', '~> 1.8'
37
38
  spec.add_dependency 'gems', '~> 1.1'
@@ -9,7 +9,7 @@ module Headdesk
9
9
  class ApkTool
10
10
  def self.apktool_jar
11
11
  File.join(File.dirname(__FILE__), '..', '..',
12
- "ext/apktool_#{APKTOOL_VERSION}.jar")
12
+ "ext/apktool_#{APKTOOL_VERSION}.jar")
13
13
  end
14
14
 
15
15
  #
@@ -53,7 +53,7 @@ module Headdesk
53
53
  status: @status
54
54
  }
55
55
  @report[:name] = self.class.check_name if self.class.respond_to?(:check_name)
56
- @report[:doc] = "https://github.com/GoCarrot/headdesk/blob/#{Headdesk::VERSION}/docs/#{self.class.doc}" if self.class.respond_to?(:check_name)
56
+ @report[:doc] = "https://github.com/GoCarrot/headdesk/blob/v#{Headdesk::VERSION}/docs/#{self.class.doc}" if self.class.respond_to?(:check_name)
57
57
  end
58
58
 
59
59
  def describe(desc = nil)
@@ -16,18 +16,21 @@ module Headdesk
16
16
  include Check::APK
17
17
 
18
18
  check_name 'activity_alias'
19
- describe "<activity-alias> is used to preserve app shortcuts"
19
+ describe '<activity-alias> is used to preserve app shortcuts'
20
20
  def call
21
21
  describe 'AndroidManifest.xml contains one or more <activity-alias>'
22
22
  skip_check if: apk.android_manifest.xpath('application/activity-alias').empty?
23
23
 
24
24
  aliases = []
25
25
  apk.android_manifest.xpath('application/activity-alias').each do |activity_alias|
26
- describe "AndroidManifest.xml contains <activity> '#{activity_alias.attributes['targetActivity']}'"
27
- fail_check if: apk.android_manifest.xpath("application/activity[@android:name='#{activity_alias.attributes['targetActivity']}']").empty?
26
+ old_activity = activity_alias.attributes['name']
27
+ new_activity = activity_alias.attributes['targetActivity']
28
28
 
29
- describe "<activity-alias> '#{activity_alias.attributes['name']}' -> '#{activity_alias.attributes['targetActivity']}' has '<intent-filter>'"
30
- fail_check if: activity_alias.xpath("intent-filter").empty?
29
+ describe "AndroidManifest.xml contains <activity> '#{new_activity}'"
30
+ fail_check if: apk.android_manifest.xpath("application/activity[@android:name='#{new_activity}']").empty?
31
+
32
+ describe "<activity-alias> '#{old_activity}' -> '#{new_activity}' has '<intent-filter>'"
33
+ fail_check if: activity_alias.xpath('intent-filter').empty?
31
34
 
32
35
  describe "<intent-filter> contains '<action android:name=\"android.intent.action.MAIN\" />'"
33
36
  fail_check if: activity_alias.xpath("intent-filter/action[@android:name='android.intent.action.MAIN']").empty?
@@ -36,8 +39,8 @@ module Headdesk
36
39
  fail_check if: activity_alias.xpath("intent-filter/category[@android:name='android.intent.category.LAUNCHER']").empty?
37
40
 
38
41
  aliases << {
39
- name: activity_alias.attributes['name'],
40
- targetActivity: activity_alias.attributes['targetActivity']
42
+ name: old_activity,
43
+ targetActivity: new_activity
41
44
  }
42
45
  end
43
46
  export aliases: aliases
@@ -29,8 +29,13 @@ module Headdesk
29
29
  sdk[:major] == major && sdk[:minor] == minor && sdk[:patch] == patch
30
30
  end).first
31
31
 
32
- describe "Found Facebook SDK version #{sdk_in_use[:version]}"
33
- fail_check if: -> { !sdk_in_use }
32
+ begin
33
+ describe "Found Facebook SDK version #{sdk_in_use[:version]}"
34
+ fail_check if: -> { !sdk_in_use }
35
+ rescue NoMethodError => _e
36
+ describe "Facebook SDK version #{major}.#{minor}.#{patch} not found, run 'bundle exec bin/facebook_sdk_versions'"
37
+ fail_check
38
+ end
34
39
 
35
40
  export facebook_sdk: sdk_in_use
36
41
 
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Headdesk
4
+ module Checks
5
+ #
6
+ # An <activity-alias> is most commonly used to change the class of the MAIN
7
+ # activity, while preserving shortcuts.
8
+ #
9
+ # com.google.firebase.MESSAGING_EVENT
10
+ #
11
+ class FirebaseMessagingEvent
12
+ include Check::APK
13
+
14
+ check_name 'firebase_messaging_event'
15
+ describe '<intent-filter> for \'com.google.firebase.MESSAGING_EVENT\''
16
+ def call
17
+ intent_filters = apk.android_manifest.xpath("application/service/intent-filter/action[@android:name='com.google.firebase.MESSAGING_EVENT']")
18
+ describe 'AndroidManifest.xml contains one or more <service> with <intent-filter> for \'com.google.firebase.MESSAGING_EVENT\''
19
+ skip_check if: intent_filters.empty?
20
+
21
+ filters = []
22
+ intent_filters.each do |filter|
23
+ filters << {
24
+ name: filter.parent.parent.attributes['name'].to_s,
25
+ priority: filter.parent.attributes['priority'].to_s.to_i
26
+ }
27
+ end
28
+ export filters: filters
29
+
30
+ max_priority = filters.max_by { |elem| elem[:priority].to_i }[:priority]
31
+ describe 'AndroidManifest.xml contains only one <service> with highest \'android:priority\' <intent-filter>'
32
+ fail_check if: filters.select { |elem| elem[:priority] == max_priority }.size > 1
33
+ end
34
+ end
35
+ end
36
+ end
@@ -31,21 +31,22 @@ module Headdesk
31
31
  #
32
32
  module InstanceMethods
33
33
  def preconditions?
34
- apk.class?('io.teak.sdk.Teak')
34
+ begin
35
+ major, minor, revision = apk.find_class('io.teak.sdk.Teak')
36
+ .field('SDKVersion')
37
+ .value
38
+ .to_version
39
+ @teak_sdk = OpenStruct.new(
40
+ version: "#{major}.#{minor}.#{revision}",
41
+ major: major, minor: minor, revision: revision
42
+ )
43
+ rescue NoMethodError => _e
44
+ return false
45
+ end
46
+ true
35
47
  end
36
48
 
37
49
  def teak_sdk
38
- return @teak_sdk if @teak_sdk
39
-
40
- major, minor, revision = apk.find_class('io.teak.sdk.Teak')
41
- .field('SDKVersion')
42
- .value
43
- .to_version
44
- @teak_sdk = OpenStruct.new(
45
- version: "#{major}.#{minor}.#{revision}",
46
- major: major, minor: minor, revision: revision
47
- )
48
-
49
50
  @teak_sdk
50
51
  end
51
52
  end
@@ -12,6 +12,7 @@ module Headdesk
12
12
  #
13
13
  class CLI < Thor
14
14
  no_commands do
15
+ # :reek:UtilityFunction
15
16
  def print_update_message(stream = STDERR)
16
17
  stream.puts "Latest version is #{Headdesk::Versions.latest_version}, please run 'bundle update headdesk'".red
17
18
  end
@@ -9,6 +9,7 @@ module Headdesk
9
9
  #
10
10
  # Find out which JAR/AAR is bringing in symbols
11
11
  #
12
+ # :reek:NilCheck, :reek:NestedIterators
12
13
  module Blame
13
14
  include Headdesk::CliCommand
14
15
 
@@ -56,7 +57,7 @@ module Headdesk
56
57
  all_matches.each do |package, symbols|
57
58
  STDOUT.puts '📦 ' + package
58
59
  symbols.each do |match|
59
- STDOUT.puts " ↳ #{match[0]}#{match[1].green}#{match[2].chomp('.') if match[2]}"
60
+ STDOUT.puts " ↳ #{match[0]}#{match[1].green}#{match[2]&.chomp('.')}"
60
61
  end
61
62
  end
62
63
 
@@ -72,7 +73,7 @@ module Headdesk
72
73
  .each(&:strip!)
73
74
  .map { |line| matcher.match(line) }
74
75
  .compact
75
- .map { |match| match.captures.map { |capture| capture.tr('/', '.') if capture } }
76
+ .map { |match| match.captures.map { |capture| capture&.tr('/', '.') } }
76
77
  end
77
78
  end
78
79
  end
@@ -55,8 +55,8 @@ module Headdesk
55
55
  CLI.command_help(Thor::Base.shell.new, 'unpack')
56
56
  exit 1
57
57
  rescue StandardError => rb_err
58
- STDERR.puts err.message.red
59
- STDERR.puts err.backtrace.ai
58
+ STDERR.puts rb_err.message.red
59
+ STDERR.puts rb_err.backtrace.ai
60
60
  exit 1
61
61
  end
62
62
  end
@@ -1,4 +1,19 @@
1
1
  ---
2
+ - :major: 4
3
+ :minor: 41
4
+ :patch: 0
5
+ :version: 4.41.0
6
+ :date: 2019-03-08
7
+ - :major: 4
8
+ :minor: 40
9
+ :patch: 0
10
+ :version: 4.40.0
11
+ :date: 2019-01-22
12
+ - :major: 4
13
+ :minor: 39
14
+ :patch: 0
15
+ :version: 4.39.0
16
+ :date: 2018-12-05
2
17
  - :major: 4
3
18
  :minor: 38
4
19
  :patch: 1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Headdesk
4
- VERSION = '0.12.0'
4
+ VERSION = '0.13.0'
5
5
  APKTOOL_VERSION = '2.3.4'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: headdesk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Wilson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-08 00:00:00.000000000 Z
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,6 +100,26 @@ dependencies:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: 0.49.0
103
+ - !ruby/object:Gem::Dependency
104
+ name: simplecov
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 0.16.0
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 0.16.0
103
123
  - !ruby/object:Gem::Dependency
104
124
  name: awesome_print
105
125
  requirement: !ruby/object:Gem::Requirement
@@ -195,9 +215,9 @@ files:
195
215
  - docs/activity_alias.md
196
216
  - docs/api26.md
197
217
  - docs/facebook.md
218
+ - docs/firebase_messaging_event.md
198
219
  - docs/receiver.md
199
220
  - docs/teak/api21_icon.md
200
- - docs/teak/caching.md
201
221
  - docs/teak/configuration.md
202
222
  - exe/headdesk
203
223
  - ext/apktool_2.3.4.jar
@@ -214,10 +234,10 @@ files:
214
234
  - lib/headdesk/checks/activity_alias.rb
215
235
  - lib/headdesk/checks/api26.rb
216
236
  - lib/headdesk/checks/facebook.rb
237
+ - lib/headdesk/checks/firebase_messaging_event.rb
217
238
  - lib/headdesk/checks/receiver.rb
218
239
  - lib/headdesk/checks/teak.rb
219
240
  - lib/headdesk/checks/teak/api21_icon.rb
220
- - lib/headdesk/checks/teak/caching.rb
221
241
  - lib/headdesk/checks/teak/teak.rb
222
242
  - lib/headdesk/cli.rb
223
243
  - lib/headdesk/cli_commands/analyze.rb
@@ -234,7 +254,7 @@ homepage: https://github.com/GoCarrot/headdesk
234
254
  licenses:
235
255
  - MIT
236
256
  metadata: {}
237
- post_install_message: For breaking change announcements...
257
+ post_install_message:
238
258
  rdoc_options: []
239
259
  require_paths:
240
260
  - lib
@@ -250,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
270
  version: '0'
251
271
  requirements: []
252
272
  rubyforge_project:
253
- rubygems_version: 2.7.8
273
+ rubygems_version: 2.7.9
254
274
  signing_key:
255
275
  specification_version: 4
256
276
  summary: headdesk helps identify and solve common issues in mobile development by
@@ -1,24 +0,0 @@
1
- # teak/caching
2
- Ensures that the APK contains a notification icon for both Android 5+ (API 21+) as well as pre-Android 5, and that these are different icons.
3
-
4
- ## Will Skip If
5
- * The Teak SDK is not present.
6
- * The version of the Teak SDK is greater or equal to 2.0.0.
7
-
8
- ## Will Fail If
9
- * `io_teak_enable_caching` is not specified.
10
- * `io_teak_enable_caching` is not set to `true`.
11
-
12
- ## Exports
13
- None.
14
-
15
- ## Reason
16
- The Teak SDK uses [Android HTTP Caching](https://developer.android.com/training/efficient-downloads/redundant_redundant#ResponseCache) to prevent downloading redundant Notification assets.
17
-
18
- The `io_teak_enable_caching` setting allows you to disable this behavior, however it should be enabled unless your app, or an SDK that you use, makes uncommon assumptions.
19
-
20
- ## Resolution
21
- Upgrade to the Teak 2.0 SDK, or add this to your Android resources XML:
22
- ```xml
23
- <bool name="io_teak_enable_caching">true</bool>
24
- ```
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Headdesk
4
- module Checks
5
- module Teak
6
- #
7
- # Check to make sure that an APK, which uses Teak, has caching enabled.
8
- #
9
- class Caching
10
- include Checks::Teak::APK
11
-
12
- check_name 'caching'
13
- describe 'Check for io_teak_enable_caching'
14
- def call
15
- describe 'Teak SDK version is lower than 2.0.0'
16
- major, = apk.find_class('io.teak.sdk.Teak')
17
- .field('SDKVersion')
18
- .value
19
- .to_version
20
- skip_check if: major.to_i >= 2
21
-
22
- describe "APK enables caching of Teak notification content (via 'io_teak_enable_caching')"
23
- fail_check unless: apk.resources
24
- .values
25
- .bool
26
- .io_teak_enable_caching
27
- end
28
- end
29
- end
30
- end
31
- end