RubyMine inspection doesn't see model fields and flags hundreds of warnings

Howdy,

Using RubyMine 7, but this problem has happened since I started using RubyMine (back at RubyMine 3).

In short, I get dozens to hundreds of inspection warnings in my code because of missing fields/columns in my models.  Thing is, the fields do exist and the code works fine.  But RubyMine can't "see" the valid fields.

So  two initial questions:

1) How does RubyMine know what fields a model has?  Does it read the annotation headers or does it instantiate a model instance to reflect the know fields?

2) How do I let RubyMine know what fields my model has?  Ideally in some automated way so I'm not manually maintaining a field list.

I did notice in RubyMine 7 a few things:

a) Some (not all) simple string fields in a model are found and the inspection doesn't complain about them.
b) Fields that are other data types including numeric/BigDecimal and integer are almost always flagged as unknown (that could be a red herring, but I really don't know)
c) Sometimes boolean fields are flagged as unknown as well, but sometimes they are not
d) RubyMine 7 has the plus os updating the warning to include the model it's looking at.  Sometimes, it shows the correct model and sometimes it shows a parent model

As an example.  This is an excerpt from a model, truncated for clarity:

----- models/finance/po_tran.rb

 
# == Schema Information
#
# Table name: f_po_trans
#
#  id                  :integer          not null, primary key
#  fiscal_year_id      :integer          not null
#  po_group_id         :integer          not null
#  po_num              :string(255)      not null
#  po_num_raw          :integer

# ... other fields

 
class Finance::PoTran < ::AuditedRecord
  include Finance
::Utilities
  include Finance
::BudgetCheck

  
has_paper_trail
--------------


Inspection doesn't complain about the 'po_num' field (a string), but it does complain about the po_num_raw field?

We are using strong parameters, so while there are validates refs for some fields, there are no attr_accesible or other such methods in the models anymore.

It's driving me a bit crazy because I really want to see the green 'all-ok' indicator for my code, but right now, nothing I write will ever be problem free because of this.

Gerry

6 comments
Comment actions Permalink

Hi,

in most cases RubyMine check your migrations to create list of existing fields.
If we fail to detect some fields please file a ticket (https://youtrack.jetbrains.com/issues/RUBY) with a simple test project which demonstrates the problem attached to it.

Regards, Oleg.

0
Comment actions Permalink

It parses all the migrations?  Or just schema.rb?  

Because I have well over 100 migrations where fields are added, removed, renamed, etc.  It would take a LOT of horsepower to parse them all and figure out what is the actual true state of the migrations.  Also, quite a few migrations have embeded SQL code to do trickier things (including defining database functions and such).

As for filing a test case, I could send you all my current migrations zipped up, but I have absolutely no idea how to unwind 3+ years of migrations and DB development into something simple when I do not have any idea why some fields are recognized and some aren't.  I feel I'd need a lot more concrete details on how the list of known model fields is created before I could even make a stab at it.

Gerry

0
Comment actions Permalink

Hi,

your questions make be doubt if my answers were completely correct :(
Let me double check the code and either me or engineer responsible for the area will describe what information we need to reproduce the problem.

Regards, Oleg.

0
Comment actions Permalink

Hello, Gerry,

could you please provide the project and screenshots to idenify the problem? If your project is private you can create a new issue in our tracker and attach it there securely.
Thank you!

0
Comment actions Permalink

Howdy,

I have created a new issue and attached a scaled down version of the project, along with specific notes on where to look for an example.

The issue is private to me and the 'ruby-developers' group (if that isn't the right one, please let me know and I'll alter it).

You can find it and the attachment at

https://youtrack.jetbrains.com/issue/RUBY-15985

Thanks!!

Gerry

0
Comment actions Permalink

This is still an issue.

All usage of the PageObject gem and FigNewton gem have this problem.

0

Please sign in to leave a comment.