-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
class Dog
def bark
puts "woof"
end
Gives me:
❯ 1 class Dog
Which is not correct. In this case ruby -wc
does know the lines are off
$ ruby -wc bad.rb
bad.rb:4: warning: mismatched indentations at 'end' with 'def' at 2
The reason this happens is the end is ambiguous, but just slightly. The algorithm thinks it's a mis-indentation and that the class
is really missing the value. I would say that the output, isn't very good as it should capture the matching end
in the "context" expansion at bare minimum.
To see just how much of an edge case this is:
Removing the puts
line produces the correct results:
1 class Dog
❯ 2 def bark
3 end
Also adding a method after it produces the correct results:
1 class Dog
❯ 2 def bark
4 def blerg
5 end
6 end
Investigating
Running with DEBUG=1
this is an unexpected first step. I think that's a bug:
1 class Dog
2
3 def bark
4 puts "foo"
❯ 5
6 end
It might be better without it
Moving forwards
- Fix the output in the case where the
class Dog
is being shown to be removed - Investigate the strange first step above, then make plans to further remediate.
Metadata
Metadata
Assignees
Labels
No labels