From 2fa394398e7f410182ca6f5e362fb13f1083cb83 Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Wed, 18 Apr 2018 16:33:03 -0500 Subject: [PATCH] HBASE-20463 Ruby 1.8 syntax fixes. branches-1 specific addendum to HBASE-20276 --- hbase-shell/src/main/ruby/hbase/table.rb | 13 +++++++++---- hbase-shell/src/main/ruby/shell/commands/get_splits.rb | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index 3e3fb8e734..4109006236 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -718,14 +718,19 @@ EOF #---------------------------------------------------------------------------------------------- # Get the split points for the table + # Disable multiline block chain because we need it to stay under width + # in ruby 1.8. + # rubocop:disable Style/MultilineBlockChain def _get_splits_internal() - locator = @table.getRegionLocator() - locator.getAllRegionLocations() - .map { |i| Bytes.toStringBinary(i.getRegionInfo().getStartKey) } - .delete_if { |k| k == "" } + locator = @table.getRegionLocator + locator.getAllRegionLocations.map do |i| + Bytes.toStringBinary(i.getRegionInfo.getStartKey) + end.delete_if { |k| k == '' } ensure locator.close() end end + # rubocop:enable Style/MultilineBlockChain + # rubocop:enable Metrics/ClassLength end diff --git a/hbase-shell/src/main/ruby/shell/commands/get_splits.rb b/hbase-shell/src/main/ruby/shell/commands/get_splits.rb index 26be15f176..c09042731d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_splits.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_splits.rb @@ -36,12 +36,14 @@ EOF get_splits(table(table)) end + # Disable format string because it doesn't work in ruby 1.8 + # rubocop:disable Style/FormatStringToken def get_splits(table) splits = table._get_splits_internal() - puts(format('Total number of splits = %d', - numsplits: (splits.size + 1))) + puts(format('Total number of splits = %d', (splits.size + 1))) splits end + # rubocop:enable Style/FormatStringToken end end end -- 2.16.1