From 678191e197c283f3fd36af1c51fc2ab5a926df12 Mon Sep 17 00:00:00 2001 From: Kouta Imanaka Date: Wed, 15 Aug 2018 20:26:55 +0900 Subject: [PATCH] Remove redundant cast --- lib/apkstats/command/apk_analyzer.rb | 5 +---- lib/apkstats/plugin.rb | 4 ++-- spec/command/apk_analyzer_spec.rb | 8 ++++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/apkstats/command/apk_analyzer.rb b/lib/apkstats/command/apk_analyzer.rb index 4c4f2a0..f88601d 100644 --- a/lib/apkstats/command/apk_analyzer.rb +++ b/lib/apkstats/command/apk_analyzer.rb @@ -42,13 +42,10 @@ def method_reference_count(apk_filepath) .values .map(&:to_i) .inject(:+) - .to_s end def dex_count(apk_filepath) - ApkAnalyzer.parse_reference_to_map(run_command("dex", "references", apk_filepath)) - .size - .to_s + ApkAnalyzer.parse_reference_to_map(run_command("dex", "references", apk_filepath)).size end def self.parse_permissions(command_output) diff --git a/lib/apkstats/plugin.rb b/lib/apkstats/plugin.rb index b290917..a9f1dac 100644 --- a/lib/apkstats/plugin.rb +++ b/lib/apkstats/plugin.rb @@ -249,7 +249,7 @@ def target_sdk(_opts = {}) # @return [Fixnum] return positive value if exists, otherwise -1. def method_reference_count(_opts = {}) result = run_command(__method__) - result ? result.to_i : -1 + result || -1 end # Show the number of dex of your apk file. @@ -257,7 +257,7 @@ def method_reference_count(_opts = {}) # @return [Fixnum] return positive value if exists, otherwise -1. def dex_count(_opts = {}) result = run_command(__method__) - result ? result.to_i : -1 + result || -1 end private diff --git a/spec/command/apk_analyzer_spec.rb b/spec/command/apk_analyzer_spec.rb index 5e55dcd..9f1e66b 100644 --- a/spec/command/apk_analyzer_spec.rb +++ b/spec/command/apk_analyzer_spec.rb @@ -58,13 +58,13 @@ module Apkstats::Command end it "method_reference_count should return reference count" do - expect(command.method_reference_count(apk_base)).to eq(15_720.to_s) - expect(command.method_reference_count(apk_method64k)).to eq(124_304.to_s) + expect(command.method_reference_count(apk_base)).to eq(15_720) + expect(command.method_reference_count(apk_method64k)).to eq(124_304) end it "dex_count should return dex count" do - expect(command.dex_count(apk_base)).to eq(1.to_s) - expect(command.dex_count(apk_method64k)).to eq(2.to_s) + expect(command.dex_count(apk_base)).to eq(1) + expect(command.dex_count(apk_method64k)).to eq(2) end end