Skip to content

Commit 2081a0e

Browse files
committedJun 6, 2022
chore: rubocopp-ed
1 parent 4f8c4a5 commit 2081a0e

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed
 

‎lib/apkstats/plugin.rb

+3-6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module Danger
6868
#
6969
class DangerApkstats < Plugin
7070
class Error < StandardError; end
71+
class MisconfigurationError < Error; end
7172

7273
# @deprecated this field have no effect
7374
COMMAND_TYPE_MAP = {
@@ -115,8 +116,6 @@ def apk_filepath=(value)
115116
# @return [String, NilClass] Your base apk filepath.
116117
attr_reader :apk_filepath
117118

118-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
119-
120119
# Get stats of two apk files and calculate diffs between them.
121120
#
122121
# @param [String, Pathname] other_apk_filepath your old apk
@@ -162,7 +161,7 @@ def summary
162161
def calculate_diff(other_apk_filepath:)
163162
ensure_apk_filepath!
164163

165-
base_apk_info = Apkstats::Entity::ApkInfo.new(command: apkanalyzer_command, apk_filepath: apk_filepath),
164+
base_apk_info = Apkstats::Entity::ApkInfo.new(command: apkanalyzer_command, apk_filepath: apk_filepath)
166165
other_apk_info = Apkstats::Entity::ApkInfo.new(command: apkanalyzer_command, apk_filepath: other_apk_filepath)
167166
diff_apk_info = Apkstats::Entity::ApkInfoDiff.new(base: base_apk_info, other: other_apk_info)
168167

@@ -173,8 +172,6 @@ def calculate_diff(other_apk_filepath:)
173172
}
174173
end
175174

176-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
177-
178175
# Show the file size of your apk file.
179176
#
180177
# @return [Fixnum] return positive value if exists, otherwise -1.
@@ -296,7 +293,7 @@ def on_error(err)
296293
end
297294

298295
def ensure_apk_filepath!
299-
raise "apk apk_filepath must be specified" if apk_filepath.nil? || !File.file?(apk_filepath)
296+
raise MisconfigurationError, "apk_filepath must be specified" if apk_filepath.nil? || !File.file?(apk_filepath)
300297
end
301298

302299
def process

‎lib/apkstats/reporter/apk_comparison.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
# frozen_string_literal: true
12

23
module Apkstats::Reporter
3-
44
# @!attribute [r] base_apk_info
55
# @return [Apkstats::Entity::ApkInfo]
66
# @!attribute [r] other_apk_info
77
# @return [Apkstats::Entity::ApkInfo]
88
# @!attribute [r] diff_apk_info
99
# @return [Apkstats::Entity::ApkInfoDiff]
1010
class ApkComparison
11-
1211
attr_reader :base_apk_info, :other_apk_info, :diff_apk_info
1312

1413
# @param base_apk_info [Apkstats::Entity::ApkInfo] an apk info
@@ -19,6 +18,8 @@ def initialize(base_apk_info:, other_apk_info:)
1918
@diff_apk_info = Apkstats::Entity::ApkInfoDiff.new(base: base_apk_info, other: other_apk_info)
2019
end
2120

21+
# rubocop:disable Metrics/AbcSize
22+
2223
# @return [String] markdown text
2324
def generate_markdown
2425
base = base_apk_info.to_h
@@ -72,6 +73,8 @@ def generate_markdown
7273
lines.flatten.join("\n") << "\n" # \n is required for the backward compatibility
7374
end
7475

76+
# rubocop:enable Metrics/AbcSize
77+
7578
def min_sdk_change(before_value:, after_value:)
7679
return [] if before_value.nil? || after_value.nil?
7780

@@ -124,7 +127,7 @@ def itemize_values_diff(name:, diff:)
124127
def itemize_with_label(label:, items:)
125128
return [] if items.empty?
126129

127-
"#{label} | #{items.map { |item| "- #{item}" }.join("<br>")}"
130+
"#{label} | #{items.map { |item| "- #{item}" }.join('<br>')}"
128131
end
129132
end
130-
end
133+
end

‎lib/apkstats/reporter/apk_summary.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
module Apkstats::Reporter
1+
# frozen_string_literal: true
22

3+
module Apkstats::Reporter
34
# @!attribute [r] apk_info
45
# @return [Apkstats::Entity::ApkInfo]
56
class ApkSummary
@@ -13,7 +14,7 @@ class ApkSummary
1314
target_sdk: "Target Sdk",
1415
method_reference_count: "Method Reference Count",
1516
dex_count: "Dex File Count"
16-
}
17+
}.freeze
1718

1819
attr_reader :apk_info
1920

@@ -55,4 +56,4 @@ def generate_markdown
5556
lines.join("\n")
5657
end
5758
end
58-
end
59+
end

‎spec/apkstats_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module Danger
2626
end
2727

2828
context "unless apk_filepath is specified" do
29-
it { expect(apkstats.compare_with(apk_other1, do_report: true)).to be_falsey }
29+
it { expect { apkstats.compare_with(apk_other1, do_report: true) }.to raise_error(Danger::DangerApkstats::MisconfigurationError) }
3030
end
3131

3232
context "otherwise" do

‎spec/reporter/apk_comparison_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
let(:apk_filepath) { fixture_path.join("app-base.apk") }
1111
let(:other_apk_filepath) { fixture_path.join("app-other1.apk") }
1212

13-
describe '#generate_markdown' do
14-
subject {
13+
describe "#generate_markdown" do
14+
subject do
1515
Apkstats::Reporter::ApkComparison.new(
1616
base_apk_info: base_apk_info,
1717
other_apk_info: other_apk_info
1818
).generate_markdown
19-
}
19+
end
2020

2121
it { is_expected.to eq(File.read(fixture_path.join("apk_comparison_of_base_and_other1.md"))) }
2222
end
23-
end
23+
end

‎spec/reporter/apk_summary_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
let(:apk_base_filepath) { fixture_path.join("app-base.apk") }
1010
let(:apk_other1_filepath) { fixture_path.join("app-other1.apk") }
1111

12-
describe '#generate_markdown' do
13-
subject {
12+
describe "#generate_markdown" do
13+
subject do
1414
Apkstats::Reporter::ApkSummary.new(
15-
apk_info: apk_info,
15+
apk_info: apk_info
1616
).generate_markdown
17-
}
17+
end
1818

1919
let(:apk_filepath) { apk_base_filepath }
2020

@@ -26,4 +26,4 @@
2626
it { is_expected.to eq(File.read(fixture_path.join("apk_summary_of_other1.md"))) }
2727
end
2828
end
29-
end
29+
end

0 commit comments

Comments
 (0)
Please sign in to comment.