RubyMine Code inspection doesn't find references to model fields for hundreds of warnings

I get countless warnings when I run code inspection because objects and references created by the Page Object and Fig Newton gems are not recognized.

16 comments
Official comment

Hi,

  1. On the "unnecessary return statement" -- could you please attach an example? We have been fixing this recently so it is interesting to see what does not work.
  2. On the "variable may not be initialized" -- this one is tricky. At the moment we don't have means for IDE to understand that the method always fails. While this is a good and interesting improvement for RubyMine, I want to mention that, for example, in Java such code leads to a compilation error. The reason is that there is often no guarantee that `fail_text` method will fail so it's better to always report such places as errors. So, I would say that _maybe_ changing the code there somehow (for example, returning that `fail_text`) is a good fix.
  3. On the resolution error -- the problem is that the methods/properties you're trying to send are generated dynamically by `PageObject` and RubyMine does not understand that. While this is another good request (to introduce symbolic type system) and we will be probably doing this in a year or so, this is difficult and fragile.
    I can suggest you to look at our side-project https://github.com/JetBrains/ruby-type-inference which tries to overcome such situations. By running your code with special tracer you add your custom defs into your own database to be used by RubyMine later. We have not released it yet, but we are close to our first EAP of this plugin.

Thank you for your insights.

Valentin.

Could you please share more details? what kind of application is it? do you use Bundler and are all gems installed to the project? Please attach idea.log (Help | Show Log in...) and the screenshot of inspection tooltip?

0

Hi,

We have a Test Automation Framework that uses Cucumber, Watir and PageObjects.

We use Bundler and all gems are up to date.

I cannot upload the log file, it says only image files.

Here is the snapshot requested:

0

@Jkoelewyn,

sorry for the delay. Would it be possible to provide a project sample for reproduce? In addition, have you tried the last RubyMine 2017.3 EAP?

0

I just upgraded to 2017.3 EAP and ran the inspection.  I still get the same result/

What exactly do you want in a project sample? I would have to create something without proprietary info in it...

0

But I guess for this purpose just a single page object class file would be good enough?

0

I will also note that after the upgrade I can no longer delete (exclude) segments of the code inspection

1

One more, we have several situations where a variable is set in a conditional (if/else or case) where the final segment (the else) is a Fail condition (ie test stops).  We then get a warning that our variable can be uninitialized.  Which is not really true.

For example:

if @browser.p(text: identifier).exist? # identifier == policy number
data.policy_number = identifier
policy_dashboard_name = @browser.p(text: identifier).parent.parent.h4(class: ['h3-title', 'space-above-none', 'dash_port_title']).text
@browser.p(text: identifier).click
elsif @browser.h4(text: identifier).exist? # identifier == policy name
data.policy_number = @browser.h4(text: identifier).parent.p(class: 'account-number dash_port_account').text
policy_dashboard_name = identifier
@browser.h4(text: identifier).click
else
AppHelpers.fail_text "Portfolio with '#{identifier}' NOT found"
end


policy_dashboard_name gets flagged when used later in the method.


0

Also, the logic on Unnecessary return statements is not right

0

It'd be great if you could provide a working project sample so that I can reproduce the problem (you can send me it to rubymine-support@jetbrains.com)

0

I will scrub a sample for you.  Does it need to run?  Or just show the issues when inspected?

0

It should be a working project sample. 

0

I sent a paired down project with plenty of examples.

To send any more we would have to get NDAs all over the place.

0

I see no tickets from your user in our system, could you please send again at least a test message to rubymine-support@jetbrains.com

0

Please sign in to leave a comment.