rubychan / coderay

Fast and easy syntax highlighting for selected languages, written in Ruby.
http://coderay.rubychan.de/
Other
845 stars 115 forks source link

Make the code in scanner/groovy.rb robust. #228

Open junaruga opened 5 years ago

junaruga commented 5 years ago

Fix small issues for lib/coderay/scanners/groovy.rb.

inline_block_paren_depth is initialized as nil. But the code inline_block_paren_depth += 1, inline_block_paren_depth -= 1, inline_block_paren_depth == 0 has a possibility to raise unintended NoMethodError. It looks good to initialize inline_block_paren_depth is initialized as 0 or add checks before the codes.

  1. string_delimiter can be nil as a possibility. Adding checks looks better.
junaruga commented 5 years ago

This report is by a static code analysis tool in our company (Maybe Coverity Scan).

korny commented 5 years ago

Mmh. I don’t think there’s really a bug here, since I never got an error with the current version even with thorough testing (see the scanner test suite). While I agree with the first change, the second one would slow down the scanner. I don’t think we need such checks unless someone can actually produce an error here :)

junaruga commented 5 years ago

Sure, @korny . I respect your decision. It's up to you.