Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment style does not allow common linter-enforced style #73

Open
myronmarston opened this issue Jul 1, 2024 · 0 comments
Open

Comment style does not allow common linter-enforced style #73

myronmarston opened this issue Jul 1, 2024 · 0 comments

Comments

@myronmarston
Copy link

I'm quite interested in using this once it becomes stable and is merged into RBS/steep proper. I haven't tried it yet, but one concern I had was about the end-of-line comment syntax:

some_expression #: [RBS type]

My concern is that this syntax does not appear to pass the comment style enforced by common Ruby linters like standardrb. Standard enables Layout/LeadingCommentSpace which would consider that a lint violation, requiring it to instead be written as:

some_expression # : [RBS type]

Can rbs-inline support both? I was curious if it already does and it looks like it doesn't. I applied this patch locally:

diff --git a/test/rbs/inline/writer_test.rb b/test/rbs/inline/writer_test.rb
index ae12f5a..cdcc3cd 100644
--- a/test/rbs/inline/writer_test.rb
+++ b/test/rbs/inline/writer_test.rb
@@ -130,7 +130,7 @@ class RBS::Inline::WriterTest < Minitest::Test
         end
 
         def hoge x,
-          y #: Integer
+          y # : Integer
         end
       end
     RUBY
@@ -465,7 +465,7 @@ class RBS::Inline::WriterTest < Minitest::Test
     output = translate(<<~RUBY)
       VERSION = "hogehoge"
 
-      SIZE = [123] #: Array[Integer]
+      SIZE = [123] # : Array[Integer]
 
       NAMES = __dir__
 
@@ -511,7 +511,7 @@ class RBS::Inline::WriterTest < Minitest::Test
       module Foo
         # @rbs @foo: String -- This is something
 
-        def foo #: void
+        def foo # : void
         end
 
         # @rbs self.@foo: Integer -- Something another
@@ -731,7 +731,7 @@ class RBS::Inline::WriterTest < Minitest::Test
       module M
         # @rbs module ClassMethods[A] : BasicObject
         class_methods do
-          def foo #: Integer
+          def foo # : Integer
             123
           end
         end

When I ran the tests I got failures:

Run options: --seed 64264

# Running:

..........................................................F.............F.....F....F.........

Finished in 0.065510s, 1419.6306 runs/s, 5190.0473 assertions/s.

  1) Failure:
RBS::Inline::WriterTest#test_constant_decl [test/rbs/inline/writer_test.rb:476]:
--- expected
+++ actual
@@ -1,6 +1,6 @@
 "VERSION: ::String

-SIZE: Array[Integer]
+SIZE: ::Array

 NAMES: untyped
 "


  2) Failure:
RBS::Inline::WriterTest#test_ivar [test/rbs/inline/writer_test.rb:521]:
--- expected
+++ actual
@@ -2,7 +2,7 @@
   # This is something
   @foo: String

-  def foo: () -> void
+  def foo: () -> untyped

   # Something another
   self.@foo: Integer


  3) Failure:
RBS::Inline::WriterTest#test_block__module_decl [test/rbs/inline/writer_test.rb:741]:
--- expected
+++ actual
@@ -1,7 +1,7 @@
 "module M
   # @rbs module ClassMethods[A] : BasicObject
   module ClassMethods[A] : BasicObject
-    def foo: () -> Integer
+    def foo: () -> untyped
   end
 end
 "


  4) Failure:
RBS::Inline::WriterTest#test_method_type__return_assertion [test/rbs/inline/writer_test.rb:138]:
--- expected
+++ actual
@@ -3,6 +3,6 @@

   def foo: (untyped x, untyped y) -> void

-  def hoge: (untyped x, untyped y) -> Integer
+  def hoge: (untyped x, untyped y) -> untyped
 end
 "


93 runs, 340 assertions, 4 failures, 0 errors, 0 skips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant