Sha256: 32cc68dddd64327e422b3db9db4267cf2c3351cd727bf5ea44134de8e1ccd8ff
Contents?: true
Size: 1.7 KB
Versions: 8
Compression:
Stored size: 1.7 KB
Contents
# frozen_string_literal: true module Headdesk module Checks # # Check the version of the Facebook SDK # # Facebook deprecates SDKs 2 years after they are released. # class FacebookSDK include Check::APK check_name 'facebook' describe 'Facebook SDK version' def call skip_check unless: -> { apk.class?('com/facebook/FacebookSdk') } facebook_sdk = apk.find_class('com/facebook/FacebookSdk') # TODO: Parse https://developers.facebook.com/docs/android/change-log-4x # and fail if > 2 years old, warn if < 3 months remaining get_sdk_version = facebook_sdk.method('getSdkVersion').code describe 'com.facebook.FacebookSdk contains getSdkVersion method' fail_check if: -> { !get_sdk_version } facebook_sdks = YAML.load_file(Headdesk::FACEBOOK_SDK_VERSIONS_YAML) major, minor, patch = get_sdk_version.match(/const-string v0, "(\d+)\.(\d+)\.(\d+)"/).captures.map(&:to_i) sdk_in_use = (facebook_sdks.select do |sdk| sdk[:major] == major && sdk[:minor] == minor && sdk[:patch] == patch end).first begin describe "Found Facebook SDK version #{sdk_in_use[:version]}" fail_check if: -> { !sdk_in_use } rescue NoMethodError => _e describe "Facebook SDK version #{major}.#{minor}.#{patch} not found, run 'bundle exec bin/facebook_sdk_versions'" fail_check end export facebook_sdk: sdk_in_use describe "Facebook SDK was released in the last 2 years (using #{sdk_in_use[:version]}, released #{sdk_in_use[:date]})" fail_check if: -> { sdk_in_use[:date] < (Date.today - (365 * 2)) } end end end end
Version data entries
8 entries across 8 versions & 1 rubygems