From 2a1e1b5bd354075d21d82ee262be5772172e39c2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 06:30:03 +0000 Subject: [PATCH 1/4] Initial plan From ae875df6e234ec4418afd570f9b569275a2eb1ae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 06:35:55 +0000 Subject: [PATCH 2/4] Remove RBS inline comments from test files Co-authored-by: simaaaji <221018698+simaaaji@users.noreply.github.com> --- test/integration/dev_server/test_hot_reloading.rb | 2 -- test/integration/dev_server/test_serving.rb | 10 ---------- test/integration/site_generator/test_generation.rb | 2 -- test/lib/hotpages/support/test_cache.rb | 4 ---- test/lib/hotpages/test_config.rb | 2 -- test/test_helper.rb | 10 ---------- 6 files changed, 30 deletions(-) diff --git a/test/integration/dev_server/test_hot_reloading.rb b/test/integration/dev_server/test_hot_reloading.rb index d1b388c..2be399e 100644 --- a/test/integration/dev_server/test_hot_reloading.rb +++ b/test/integration/dev_server/test_hot_reloading.rb @@ -3,7 +3,6 @@ class TestHotReloading < Minitest::Test @@setup_done = false - #: () -> Integer def setup return if @@setup_done @@ -29,7 +28,6 @@ def setup end end - #: () -> nil def test_sse_broadcasting client_socket = TCPSocket.new("localhost", @@port) diff --git a/test/integration/dev_server/test_serving.rb b/test/integration/dev_server/test_serving.rb index 24d9412..ebbe1e0 100644 --- a/test/integration/dev_server/test_serving.rb +++ b/test/integration/dev_server/test_serving.rb @@ -4,7 +4,6 @@ class TestServing < Minitest::Test @@setup_done = false - #: () -> Integer? def setup return if @@setup_done @@ -36,7 +35,6 @@ def setup end end - #: () -> Array[untyped] def test_serves_all_pages Dir.glob(Hotpages.site.dist_path.join("**/*")).each do |file| next if File.directory?(file) @@ -49,14 +47,12 @@ def test_serves_all_pages end end - #: () -> bool def test_serves_404_page_for_non_existent_page uri = URI("http://localhost:#{@@port}/not-exist") res = Net::HTTP.get_response(uri) assert_equal "404", res.code, "Failed to serve /not-exist" end - #: () -> bool def test_serves_without_file_extension uri = URI("http://localhost:#{@@port}/posts/1/bar/index") res = Net::HTTP.get_response(uri) @@ -64,7 +60,6 @@ def test_serves_without_file_extension assert_page_content "posts/1/bar/index.html", res.body end - #: () -> bool def test_serves_index_without_filename uri = URI("http://localhost:#{@@port}/posts/1/bar/") res = Net::HTTP.get_response(uri) @@ -72,14 +67,12 @@ def test_serves_index_without_filename assert_page_content "posts/1/bar/index.html", res.body end - #: () -> bool def test_not_serves_txt_without_file_extension uri = URI("http://localhost:#{@@port}/robot") res = Net::HTTP.get_response(uri) assert_equal "404", res.code, "Should not serve /robot.txt without extension" end - #: () -> bool def test_not_serves_ignored_path uri = URI("http://localhost:#{@@port}/products/_page") res = Net::HTTP.get_response(uri) @@ -90,14 +83,12 @@ def test_not_serves_ignored_path assert_equal "404", res.code, "Should not serve /products/_product" end - #: () -> bool def test_not_serves_directory_without_trailing_slash uri = URI("http://localhost:#{@@port}/posts/1/bar") res = Net::HTTP.get_response(uri) assert_equal "404", res.code, "Should not serve /posts/1/bar without trailing slash" end - #: () -> bool def test_serves_non_html uri = URI("http://localhost:#{@@port}/sitemap.xml") res = Net::HTTP.get_response(uri) @@ -107,7 +98,6 @@ def test_serves_non_html private - #: (String, String) -> bool def assert_page_content(expected_path, actual_content) actual_content = actual_content.force_encoding("UTF-8").encode("UTF-8") expected_content = File.read(Hotpages.site.dist_path.join(expected_path.delete_prefix("/"))) diff --git a/test/integration/site_generator/test_generation.rb b/test/integration/site_generator/test_generation.rb index 31b72c1..08d73c8 100644 --- a/test/integration/site_generator/test_generation.rb +++ b/test/integration/site_generator/test_generation.rb @@ -2,7 +2,6 @@ require "digest" class TestGeneration < Minitest::Test - #: () -> Integer def setup pid = fork do Hotpages.extensions += [ @@ -16,7 +15,6 @@ def setup Process.wait(pid) end - #: () -> Array[untyped] def test_site_generation expected_dist = File.join(__dir__, "../../dist/expected") actual_dist = Hotpages.site.dist_path.to_s diff --git a/test/lib/hotpages/support/test_cache.rb b/test/lib/hotpages/support/test_cache.rb index d6a3f90..3a0f1ab 100644 --- a/test/lib/hotpages/support/test_cache.rb +++ b/test/lib/hotpages/support/test_cache.rb @@ -6,7 +6,6 @@ class TestCache < Minitest::Test Entry = Hotpages::Support::Cache::Entry Store = Hotpages::Support::Cache::Store - #: () -> bool def test_entry_content_of_with_newer_version entry = Entry.new(version: 2, content: "cached content") @@ -14,14 +13,12 @@ def test_entry_content_of_with_newer_version assert_equal "cached content", entry.content_of(2) end - #: () -> bool def test_entry_content_of_with_older_version entry = Entry.new(version: 1, content: "cached content") assert_nil entry.content_of(2) end - #: () -> bool def test_entry_content_of_with_nil_version entry = Entry.new(version: nil, content: "cached content") @@ -31,7 +28,6 @@ def test_entry_content_of_with_nil_version assert_equal "cached content", entry.content_of(0) end - #: () -> bool def test_store_fetch store = Store.new key = "test cache key" diff --git a/test/lib/hotpages/test_config.rb b/test/lib/hotpages/test_config.rb index f115e97..8eb0150 100644 --- a/test/lib/hotpages/test_config.rb +++ b/test/lib/hotpages/test_config.rb @@ -3,7 +3,6 @@ class TestConfig < Minitest::Test Config = Hotpages::Config - #: () -> Hotpages::Config def setup @defaults = { foo: "foo", @@ -15,7 +14,6 @@ def setup @config = Hotpages::Config.new(@defaults) end - #: () -> bool def test_singleton_methods assert_respond_to @config, :foo assert_equal "foo", @config.foo diff --git a/test/test_helper.rb b/test/test_helper.rb index 028568c..b17176b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,11 +2,6 @@ $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "hotpages" -require "rbs" -require "rbs/trace" - -trace = RBS::Trace.new -trace.enable # Fix the last modified date of the page to prevent failures # during tests due to changes in CI, etc. @@ -29,8 +24,3 @@ class TestSite < Hotpages::Site Minitest.after_run do Hotpages.teardown end - -Minitest.after_run do - trace.disable - trace.save_comments -end From a5c3317ea75a6bbbd681685da3951efad077c091 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 06:36:30 +0000 Subject: [PATCH 3/4] Add sorbet and sorbet-runtime gems for type checking Co-authored-by: simaaaji <221018698+simaaaji@users.noreply.github.com> --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index d1a8076..f325dcd 100644 --- a/Gemfile +++ b/Gemfile @@ -11,4 +11,6 @@ gem "kramdown", "~> 2.5" gem "minitest", "~> 5.16" gem "rbs-inline", require: false +gem "sorbet", require: false +gem "sorbet-runtime" gem "rubocop-rails-omakase" From 60752f5f3276eb20713f0f392ab22cecaf94b1eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 06:38:39 +0000 Subject: [PATCH 4/4] Configure Sorbet for type checking with RBS inline Co-authored-by: simaaaji <221018698+simaaaji@users.noreply.github.com> --- TYPE_CHECKING.md | 36 ++++++++++++++++++++++++++++++++++++ sorbet/config | 4 ++++ 2 files changed, 40 insertions(+) create mode 100644 TYPE_CHECKING.md create mode 100644 sorbet/config diff --git a/TYPE_CHECKING.md b/TYPE_CHECKING.md new file mode 100644 index 0000000..1184c48 --- /dev/null +++ b/TYPE_CHECKING.md @@ -0,0 +1,36 @@ +# Type Checking with RBS Inline and Sorbet + +This project uses a combination of RBS inline annotations and Sorbet for type checking. + +## RBS Inline + +Type annotations in the `lib/` directory use RBS inline format with `#:` comments. + +To generate RBS files from inline annotations: +```bash +bundle exec rbs-inline lib --output sig/generated +``` + +## Sorbet + +The Sorbet gem is available for additional type checking capabilities. + +### Setup + +Initialize Sorbet (if not already done): +```bash +bundle exec srb init +``` + +### Type Checking + +Run Sorbet type checker: +```bash +bundle exec srb tc +``` + +## Workflow + +1. Write code with RBS inline annotations in `lib/` files +2. Generate RBS files: `bundle exec rbs-inline lib --output sig/generated` +3. Run type checking as needed with Sorbet diff --git a/sorbet/config b/sorbet/config new file mode 100644 index 0000000..6266ba7 --- /dev/null +++ b/sorbet/config @@ -0,0 +1,4 @@ +--dir +. +--ignore=/test/ +--ignore=/sig/