From e9bdee0ec3826cbb76e7ef5e072c37d7796ed71d Mon Sep 17 00:00:00 2001 From: KOTP Date: Tue, 19 Mar 2024 01:16:16 -0400 Subject: [PATCH 1/3] Alignment, redundant self, space around operators [no important files changed] --- .../practice/complex-numbers/.meta/example.rb | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/exercises/practice/complex-numbers/.meta/example.rb b/exercises/practice/complex-numbers/.meta/example.rb index dd337f127c..6f5eb3dbd4 100644 --- a/exercises/practice/complex-numbers/.meta/example.rb +++ b/exercises/practice/complex-numbers/.meta/example.rb @@ -1,4 +1,5 @@ class ComplexNumber + attr_reader :real, :imaginary def initialize(real, imaginary = 0) @@ -7,39 +8,39 @@ def initialize(real, imaginary = 0) end def ==(other) - (self - other).abs < 1e-15 + (self - other).abs < 1e-15 end def +(other) - self.class.new(@real + other.real, @imaginary + other.imaginary) + self.class.new(real + other.real, imaginary + other.imaginary) end def -(other) - self.class.new(@real - other.real, @imaginary - other.imaginary) + self.class.new(real - other.real, imaginary - other.imaginary) end def *(other) - self.class.new(@real * other.real - @imaginary * other.imaginary, - @real * other.imaginary + @imaginary * other.real) + self.class.new(real * other.real - imaginary * other.imaginary, + real * other.imaginary + imaginary * other.real) end def /(other) - self*other.inv + self * other.inv end def abs - Math.sqrt((self*self.conjugate).real) + Math.sqrt((self * conjugate).real) end def conjugate - self.class.new(@real, -@imaginary) + self.class.new(real, -imaginary) end def inv - self.class.new(@real / abs**2, -@imaginary / abs**2) + self.class.new(real / abs**2, -imaginary / abs**2) end def exp - self.class.new(Math.exp(@real)) * self.class.new(Math.cos(@imaginary), Math.sin(@imaginary)) + self.class.new(Math.exp(real)) * self.class.new(Math.cos(imaginary), Math.sin(imaginary)) end end From 6902c2f6d999b934fa2ae6e17b93114f344c8e9d Mon Sep 17 00:00:00 2001 From: KOTP Date: Wed, 20 Mar 2024 15:51:05 -0400 Subject: [PATCH 2/3] Update rubocop and minitest versions --- Gemfile | 2 +- Gemfile.lock | 49 ++++++++++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Gemfile b/Gemfile index fa2d4a9f88..5ad1f72a6a 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem 'minitest' gem 'rake' gem 'mocha', require: false -gem 'rubocop', '~> 1.50.0', require: false +gem 'rubocop', '~> 1.62.1', require: false gem 'rubocop-minitest', require: false gem 'rubocop-rake', require: false gem 'simplecov', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 5f073c4c77..0910d3d751 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,52 +3,59 @@ GEM specs: ast (2.4.2) docile (1.4.0) - json (2.6.3) - minitest (5.14.4) - mocha (1.13.0) - parallel (1.23.0) - parser (3.2.2.1) + json (2.7.1) + language_server-protocol (3.17.0.3) + minitest (5.22.3) + mocha (2.1.0) + ruby2_keywords (>= 0.0.5) + parallel (1.24.0) + parser (3.3.0.5) ast (~> 2.4.1) + racc + racc (1.7.3) rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.8.0) - rexml (3.2.5) - rubocop (1.50.2) + rake (13.1.0) + regexp_parser (2.9.0) + rexml (3.2.6) + rubocop (1.62.1) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + 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.28.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.28.0) - parser (>= 3.2.1.0) - rubocop-minitest (0.15.0) - rubocop (>= 0.90, < 2.0) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) + rubocop-minitest (0.35.0) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) ruby-progressbar (1.13.0) - simplecov (0.21.2) + ruby2_keywords (0.0.5) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) - unicode-display_width (2.4.2) + simplecov_json_formatter (0.1.4) + unicode-display_width (2.5.0) PLATFORMS - ruby + x86_64-linux DEPENDENCIES minitest mocha rake - rubocop (~> 1.50.0) + rubocop (~> 1.62.1) rubocop-minitest rubocop-rake simplecov BUNDLED WITH - 2.2.22 + 2.4.10 From f73fae4b59dcf05c60fadcbb7a225205374a5bb1 Mon Sep 17 00:00:00 2001 From: KOTP Date: Wed, 20 Mar 2024 15:51:30 -0400 Subject: [PATCH 3/3] Newer assertions for type checks --- exercises/concept/amusement-park/attendee_test.rb | 2 +- .../boutique_inventory_test.rb | 4 ++-- exercises/practice/clock/clock_test.rb | 4 ++-- .../practice/simple-linked-list/simple_linked_list_test.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/concept/amusement-park/attendee_test.rb b/exercises/concept/amusement-park/attendee_test.rb index d6232d2070..61d411d558 100644 --- a/exercises/concept/amusement-park/attendee_test.rb +++ b/exercises/concept/amusement-park/attendee_test.rb @@ -4,7 +4,7 @@ class AttendeeTest < Minitest::Test def test_new_instance height = 100 - assert_equal Attendee, Attendee.new(height).class + assert_instance_of Attendee, Attendee.new(height) end def test_new_instance_height diff --git a/exercises/concept/boutique-inventory-improvements/boutique_inventory_test.rb b/exercises/concept/boutique-inventory-improvements/boutique_inventory_test.rb index a049ef7870..dca9d2a78c 100644 --- a/exercises/concept/boutique-inventory-improvements/boutique_inventory_test.rb +++ b/exercises/concept/boutique-inventory-improvements/boutique_inventory_test.rb @@ -48,7 +48,7 @@ def test_items_is_an_array_of_ostruct coat = { price: 65.00, name: "Coat", quantity_by_size: { m: 1, l: 2 } } handkerchief = { price: 19.99, name: "Handkerchief", quantity_by_size: { s: 3, m: 2 } } items = [shoes, coat, handkerchief] - assert_equal Array, BoutiqueInventory.new(items).items.class - assert_equal OpenStruct, BoutiqueInventory.new(items).items.first.class + assert_instance_of Array, BoutiqueInventory.new(items).items + assert_instance_of OpenStruct, BoutiqueInventory.new(items).items.first end end diff --git a/exercises/practice/clock/clock_test.rb b/exercises/practice/clock/clock_test.rb index 9659d6e46d..92bbff02d5 100644 --- a/exercises/practice/clock/clock_test.rb +++ b/exercises/practice/clock/clock_test.rb @@ -209,14 +209,14 @@ def test_clocks_a_minute_apart skip clock1 = Clock.new(hour: 15, minute: 36) clock2 = Clock.new(hour: 15, minute: 37) - refute clock1 == clock2 + refute_equal clock1, clock2 end def test_clocks_an_hour_apart skip clock1 = Clock.new(hour: 14, minute: 37) clock2 = Clock.new(hour: 15, minute: 37) - refute clock1 == clock2 + refute_equal clock1, clock2 end def test_clocks_with_hour_overflow diff --git a/exercises/practice/simple-linked-list/simple_linked_list_test.rb b/exercises/practice/simple-linked-list/simple_linked_list_test.rb index 301b787084..eb07b74895 100644 --- a/exercises/practice/simple-linked-list/simple_linked_list_test.rb +++ b/exercises/practice/simple-linked-list/simple_linked_list_test.rb @@ -92,7 +92,7 @@ def test_list_created_from_array_still_made_up_of_elements skip array = [1, 2, 3] list = SimpleLinkedList.new(array) - assert_equal Element, list.pop.class + assert_instance_of Element, list.pop end def test_list_from_array_still_acts_as_lifo