RubyMine Inspections modern Hash Syntax Fails

The following is valid but fails the inspections in multiple ways  wants to create methods out of the keys, complains about braces and commas...

myhash = {

          prod: {

              vision: 'http://visionjson.example.me',

              xlink: 'http://xlinkweb.example.com/prod'

          },

          rel: {

              vision: 'http://rel-visionjson.example.me',

              xlink: 'http://dev.xlinkweb.example.com/rel'

          },

          qa: {

              vision: 'http://qa-visionjson.example.me',

              xlink: 'http://dev.xlinkweb.example.com/qa'

          },

          pre: {

              vision: 'http://pre-visionjson.example.me',

              xlink: 'http://dev.xlinkweb.example.com/pre'

          },

          sbx: {

              vision: 'http://sbx-visionjson.example.me',

              xlink: 'http://dev.xlinkweb.example.com/sbx'

          }

      }

13 comments
Comment actions Permalink

Hi,

I'd double-check that the project uses correct ruby sdk (often the problem caused by ruby 1.8 sdk which is set for the project)

Hope this helps, Oleg.

0
Comment actions Permalink

I'm also experiencing this problem, I had choose Ruby 2.0 (with rbenv) as the Project SDK

PS: The project language level is java 6 but I think it isn't related since it's not a java but ruby project. Am I wrong?

0
Comment actions Permalink

Hi,

I believe you are using Idea + Ruby plugin.  Am I right?
If so what version of Idea/plugin are you using?
Also ruby sdk is set not to the project but to either JRuby facet or ruby module.
What kind of project and modules do you have?

Regards, Oleg.

0
Comment actions Permalink

It is a Java project with a single module. I have some ruby code there, with >1.9 syntax (like named captures and new hash style).

The IntelliJ IDEA version is the latest (14.0.3) and the plugin version is the latest too (7.0.0.2014.12.17).

PS: I've tried, using a Ruby project everything works fine.

0
Comment actions Permalink

Hi,

it is supposed to add JRuby facet to java module or have a separate ruby module.  
In both cases you will be able to set ruby sdk.

Regards, Oleg.

0
Comment actions Permalink

Using the jRuby facet should work too (with ruby 1.9 syntax)?

0
Comment actions Permalink

yes, you just need to set ruby sdk for the facet

Regards, Oleg.

0
Comment actions Permalink

RUbyMIne is still showing (Red) syntax error in the editor.  "Expecting ="  I think your parsing for the old "Hash Rocket" style Ruby 2.x allows what I posted originally.  I think also it is only complainin on nested hashes

myhash = {
     value1: "some data",
     nested: {
          value2: "SOme nested element"
     }
}

Regards

-dale

0
Comment actions Permalink

Oh also The new syntax is just like JS and JSON

0
Comment actions Permalink

could you please show your project's settings (especially settings for jruby facet.

Regards, Oleg.

0
Comment actions Permalink

Having same problem here.

"Wrong Hash" inspection is complaingin about

= f.select :locale, Ah::Locale.all, {}, { multiple: true, class: "selectpicker", "data-selected-text-format": "count" }

insisting on HashRocket syntax.

 

Using Ruby 2.2.3 SDK in the project.  

0
Comment actions Permalink

Just to clarify, complains about:

"data-selected-text-format": "count"

 

insists it should be 

"data-selected-text-format" => "count"

0

Please sign in to leave a comment.