Skip to content

Commit

Permalink
Update Ruby and dependencies, apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremycole committed Nov 1, 2024
1 parent 5e726c2 commit a700d22
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 58 deletions.
9 changes: 8 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# TODO: Enable rubocop-rspec only along with all the fixes it demands.
# require: rubocop-rspec

AllCops:
TargetRubyVersion: 2.6
NewCops: enable
Gemspec/DevelopmentDependencies:
Enabled: false
Gemspec/RequireMFA:
Enabled: false
Lint/AmbiguousOperator:
Enabled: false
Lint/FormatParameterMismatch:
Enabled: false
Layout/LineLength:
Max: 120
Metrics/BlockLength:
Expand Down Expand Up @@ -38,4 +45,4 @@ Metrics/PerceivedComplexity:
Style/SymbolArray:
MinSize: 1
Style/EmptyCaseCondition:
Enabled: false
Enabled: false
67 changes: 41 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,58 +1,73 @@
PATH
remote: .
specs:
innodb_ruby (0.12.0)
innodb_ruby (0.13.0)
bigdecimal (~> 3.1.8)
bindata (>= 1.4.5, < 3.0)
digest-crc (~> 0.4, >= 0.4.1)
getoptlong (~> 0.2.1)
histogram (~> 0.2)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
bindata (2.4.10)
diff-lcs (1.5.0)
digest-crc (0.6.4)
bigdecimal (3.1.8)
bindata (2.5.0)
diff-lcs (1.5.1)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
getoptlong (0.2.1)
gnuplot (2.6.2)
histogram (0.2.4.1)
json (2.6.2)
parallel (1.22.1)
parser (3.1.2.1)
json (2.7.5)
language_server-protocol (3.17.0.3)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
racc (1.8.1)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.5.0)
rexml (3.2.5)
rake (13.2.1)
regexp_parser (2.9.2)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
rspec-expectations (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.0)
rspec-mocks (3.11.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.35.0)
rspec-support (3.11.1)
rubocop (1.67.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.1.2.1)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
rubocop-rspec (2.12.1)
rubocop (~> 1.31)
ruby-progressbar (1.11.0)
unicode-display_width (2.2.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.33.0)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.26.1)
rubocop (~> 1.61)
rubocop-rspec (2.31.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.29.1)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
unicode-display_width (2.6.0)

PLATFORMS
ruby
Expand All @@ -65,4 +80,4 @@ DEPENDENCIES
rubocop-rspec (~> 2.4)

BUNDLED WITH
2.1.4
2.5.22
2 changes: 1 addition & 1 deletion bin/innodb_log
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def usage(exit_code, message = nil)
print "Error: #{message}\n" unless message.nil?

# rubocop:disable Layout/HeredocIndentation
print <<'END_OF_USAGE'
print <<END_OF_USAGE
Usage: innodb_log [-d] [-l <lsn>] -f <log file> <mode>
Expand Down
10 changes: 5 additions & 5 deletions bin/innodb_space
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def space_index_pages_free_plot(space, start_page)
image_file = "#{image_name}_free.png"

# Aim for one horizontal pixel per extent, but min 1k and max 10k width.
image_width = [10_000, [1_000, space.pages / space.pages_per_extent].max].min
(space.pages / space.pages_per_extent).clamp(1_000, 10_000)

Gnuplot.open do |gp|
Gnuplot::Plot.new(gp) do |plot|
Expand Down Expand Up @@ -475,7 +475,7 @@ end

# rubocop:disable Metrics/BlockNesting
def space_extents_illustrate_page_status(space, entry, count_by_identifier, identifiers)
entry.each_page_status.each_with_object("".dup) do |(page_number, page_status), bitmap|
entry.each_page_status.with_object("".dup) do |(page_number, page_status), bitmap|
if page_number >= space.pages
bitmap << " "
next
Expand Down Expand Up @@ -576,8 +576,8 @@ def space_lsn_age_illustrate(space)
next if page.lsn.zero?

page_lsn[page_number] = page.lsn
lsn_min = page.lsn < lsn_min ? page.lsn : lsn_min
lsn_max = page.lsn > lsn_max ? page.lsn : lsn_max
lsn_min = [page.lsn, lsn_min].min
lsn_max = [page.lsn, lsn_max].max
end
lsn_delta = lsn_max - lsn_min

Expand Down Expand Up @@ -1249,7 +1249,7 @@ def usage(exit_code, message = nil)
end

# rubocop:disable Layout/HeredocIndentation
print <<'END_OF_USAGE'
print <<END_OF_USAGE
Usage: innodb_space <options> <mode>
Expand Down
8 changes: 5 additions & 3 deletions innodb_ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ Gem::Specification.new do |s|

s.required_ruby_version = ">= 2.6"

s.add_runtime_dependency("bindata", ">= 1.4.5", "< 3.0")
s.add_runtime_dependency("digest-crc", "~> 0.4", ">= 0.4.1")
s.add_runtime_dependency("histogram", "~> 0.2")
s.add_dependency("bigdecimal", "~> 3.1.8")
s.add_dependency("bindata", ">= 1.4.5", "< 3.0")
s.add_dependency("digest-crc", "~> 0.4", ">= 0.4.1")
s.add_dependency("getoptlong", "~> 0.2.1")
s.add_dependency("histogram", "~> 0.2")

s.add_development_dependency("gnuplot", "~> 2.6.0")
s.add_development_dependency("rspec", "~> 3.11.0")
Expand Down
1 change: 0 additions & 1 deletion lib/innodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def self.debug=(value)
end
end

require "pp"
require "digest/crc32c"
require "innodb/util/buffer_cursor"
require "innodb/util/read_bits_at_offset"
Expand Down
4 changes: 2 additions & 2 deletions lib/innodb/data_dictionary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def data_dictionary_table?(table_name)
end

def data_dictionary_index?(table_name, index_name)
return unless data_dictionary_table?(table_name)
return false unless data_dictionary_table?(table_name)

DATA_DICTIONARY_RECORD_DESCRIBERS[table_name.to_sym].include?(index_name.to_sym)
end
Expand Down Expand Up @@ -307,7 +307,7 @@ def each_data_dictionary_index
return enum_for(:each_data_dictionary_index) unless block_given?

data_dictionary_indexes.each do |table_name, indexes|
indexes.each do |index_name, _root_page_number|
indexes.each_key do |index_name|
yield table_name, index_name,
data_dictionary_index(table_name, index_name)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def parse_type_definition(type_string)
base_type = matches[1].upcase.to_sym
return [base_type, []] unless matches[3]

[base_type, matches[3].sub(/ /, "").split(/,/).map(&:to_i)]
[base_type, matches[3].sub(/ /, "").split(",").map(&:to_i)]
end
end
end
2 changes: 1 addition & 1 deletion lib/innodb/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def torn?

# Is the page in the doublewrite buffer?
def in_doublewrite_buffer?
space&.system_space? && space&.doublewrite_page?(offset)
space&.system_space? && space.doublewrite_page?(offset)
end

# Is the space ID stored in the header different from that of the space
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/page/blob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def next_blob_page
def each_region(&block)
return enum_for(:each_region) unless block_given?

super(&block)
super

yield Region.new(
offset: pos_blob_header,
Expand Down
4 changes: 2 additions & 2 deletions lib/innodb/page/fsp_hdr_xdes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def sdi_header
def each_region(&block)
return enum_for(:each_region) unless block_given?

super(&block)
super

yield Region.new(
offset: pos_fsp_header,
Expand All @@ -233,7 +233,7 @@ def each_region(&block)
yield Region.new(
offset: xdes.offset,
length: size_xdes_entry,
name: "xdes_#{state}".to_sym,
name: :"xdes_#{state}",
info: "Extent Descriptor (#{state})"
)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/page/ibuf_bitmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def ibuf_bitmap
def each_region(&block)
return enum_for(:each_region) unless block_given?

super(&block)
super

yield Region.new(
offset: pos_ibuf_bitmap,
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/page/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def each_child_page
def each_region(&block)
return enum_for(:each_region) unless block_given?

super(&block)
super

yield Region.new(
offset: pos_index_header,
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/page/inode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def each_allocated_inode
def each_region(&block)
return enum_for(:each_region) unless block_given?

super(&block)
super

yield Region.new(
offset: pos_list_entry,
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/page/sys_data_dictionary_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def data_dictionary_header
def each_region(&block)
return enum_for(:each_region) unless block_given?

super(&block)
super

yield Region.new(
offset: pos_data_dictionary_header,
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/page/sys_ibuf_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def ibuf_header
def each_region(&block)
return enum_for(:each_region) unless block_given?

super(&block)
super

yield Region.new(
offset: pos_ibuf_header,
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/page/sys_rseg_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def each_undo_segment
def each_region(&block)
return enum_for(:each_region) unless block_given?

super(&block)
super

yield Region.new(
offset: pos_rseg_header,
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/page/trx_sys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def trx_sys
def each_region(&block)
return enum_for(:each_region) unless block_given?

super(&block)
super

yield Region.new(
offset: pos_trx_sys_header,
Expand Down
4 changes: 2 additions & 2 deletions lib/innodb/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def trx_sys
def rseg_page?(page_number)
return false unless trx_sys

!trx_sys.rsegs.select { |rseg| rseg.space_id.zero? && rseg.page_number == page_number }.empty?
trx_sys.rsegs.any? { |rseg| rseg.space_id.zero? && rseg.page_number == page_number }
end

# Return the page number for the space's SYS data dictionary header.
Expand Down Expand Up @@ -358,7 +358,7 @@ def each_inode_list
def each_inode(&block)
return enum_for(:each_inode) unless block_given?

each_inode_list.each do |_name, list|
each_inode_list.each_value do |list|
list.each do |page|
page.each_allocated_inode(&block)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/undo_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def row
end

def row_string
row&.reject(&:nil?)&.map { |r| r && format("%s=%s", r[:name], r[:value].inspect) }&.join(", ")
row&.compact&.map { |r| r && format("%s=%s", r[:name], r[:value].inspect) }&.join(", ")
end

def string
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/util/buffer_cursor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def trace(arg = true) # rubocop:disable Style/OptionalBooleanParameter
# position, raw byte buffer, and array of names.
def print_trace(_cursor, position, bytes, name)
slice_size = 16
bytes.each_slice(slice_size).each_with_index do |slice_bytes, slice_count|
bytes.each_slice(slice_size).with_index do |slice_bytes, slice_count|
@trace_io.puts "%06i %s %-32s %s" % [
position + (slice_count * slice_size),
direction == :backward ? "←" : "→",
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/util/hex_format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def self.format_printable(data)
end

def self.format_hex(data)
data.chars.each_slice(LINE_SIZE).each_with_index do |bytes, i|
data.chars.each_slice(LINE_SIZE).with_index do |bytes, i|
yield format("%08i %-#{GROUP_FORMAT_LENGTH}s |%-#{LINE_SIZE}s|",
(i * LINE_SIZE), format_groups(bytes, GROUP_SIZE), format_printable(bytes))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/innodb/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Innodb
VERSION = "0.12.0"
VERSION = "0.13.0"
end
2 changes: 1 addition & 1 deletion lib/innodb/xdes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def page_status(page_number)
def each_page_status
return enum_for(:each_page_status) unless block_given?

bitmap.each_byte.each_with_index do |byte, byte_index|
bitmap.each_byte.with_index do |byte, byte_index|
(0..3).each do |page_offset|
page_number = start_page + (byte_index * 4) + page_offset
page_bits = ((byte >> (page_offset * BITS_PER_PAGE)) & BITMAP_BV_ALL)
Expand Down

0 comments on commit a700d22

Please sign in to comment.