Search code examples
jruby

"Unable to parse rubocopy response" error in Intellij when loading a custom java program into jruby


A jruby project was created in Intellij and a small java module to build the "hello world" java program that will be invoked by the jruby module. After building the jrubyjava module we can see that the jruby_hello.rb is "happy" that both the jdk - from java.util.TreeSet and the custom classes from com.example.[CallMe, ISpeaker] are accessible to the jruby_hello.rb script:

enter image description here

However - when running the jruby code the following error occurs:

enter image description here

Here is the rubocop response:

Error:jruby.jar is /usr/local/opt/jruby/libexec/lib/jruby.jar {"metadata":{"rubocop_version":"0.79.0","ruby_engine":"jruby","ruby_version":"2.5.7","ruby_patchlevel":"0","ruby_platform":"java"},"files":[{"path":"jruby_hello.rb","offenses":[{"severity":"convention","message":"Missing magic comment # frozen_string_literal: true.","cop_name":"Style/FrozenStringLiteralComment","corrected":false,"correctable":true,"location":{"start_line":1,"start_column":1,"last_line":1,"last_column":1,"length":1,"line":1,"column":1}},{"severity":"convention","message":"Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"correctable":true,"location":{"start_line":1,"start_column":9,"last_line":1,"last_column":14,"length":6,"line":1,"column":9}},{"severity":"convention","message":"Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"correctable":true ...

enter image description here

We can notice that buried in the error output is

  "message":"Missing magic comment `# frozen_string_literal: true`."

What is needed for fixing this?


Solution

  • Adding that string at the top of the file seems to have resolved the issue

    # frozen_string_literal: true
    require "java"
    

    enter image description here