diff options
author | schneems <richard.schneeman+foo@gmail.com> | 2022-11-25 16:26:43 -0600 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-11-28 20:55:41 +0900 |
commit | f64ba0fadd97adbd7cb8171fc8aa010b829a7185 (patch) | |
tree | bbec9f541b81939dbdbe1da7575fc2a6adb0c121 /lib | |
parent | 4d51a0b495262073a8c1c0c9d7f276c4e6260688 (diff) | |
download | ruby-f64ba0fadd97adbd7cb8171fc8aa010b829a7185.tar.gz |
[ruby/syntax_suggest] Do not output "Syntax OK" when there's an error
Due to a problem with ripper we do not recognize `break` as invalid code. It's confusing that "Syntax OK" is output in that case.
When there's no syntax error, the algorithm should not say anything. The exception is in the CLI and that's for compatibility with `ruby -wc`
```
$ cat /tmp/break.rb
break
⛄️ 3.1.2 🚀 /Users/rschneeman/Documents/projects/syntax_suggest (schneems/no-syntax-not-okay-break)
$ ruby -wc /tmp/break.rb
Syntax OK
```
> Note that this is invalid, running this code will raise a Syntax error.
```
$ exe/syntax_suggest /tmp/break.rb
Syntax OK
```
Close https://github.com/ruby/syntax_suggest/pull/157
https://github.com/ruby/syntax_suggest/commit/d7bd8f03a2
Diffstat (limited to 'lib')
-rw-r--r-- | lib/syntax_suggest/cli.rb | 1 | ||||
-rw-r--r-- | lib/syntax_suggest/display_invalid_blocks.rb | 1 |
2 files changed, 1 insertions, 1 deletions
diff --git a/lib/syntax_suggest/cli.rb b/lib/syntax_suggest/cli.rb index b89fa5d013..9bc4fe6cd4 100644 --- a/lib/syntax_suggest/cli.rb +++ b/lib/syntax_suggest/cli.rb @@ -65,6 +65,7 @@ module SyntaxSuggest ) if display.document_ok? + @io.puts "Syntax OK" @exit_obj.exit(0) else @exit_obj.exit(1) diff --git a/lib/syntax_suggest/display_invalid_blocks.rb b/lib/syntax_suggest/display_invalid_blocks.rb index bc1143f4b0..32ec0021a3 100644 --- a/lib/syntax_suggest/display_invalid_blocks.rb +++ b/lib/syntax_suggest/display_invalid_blocks.rb @@ -23,7 +23,6 @@ module SyntaxSuggest def call if document_ok? - @io.puts "Syntax OK" return self end |