RubyMine #820 Feedback - Syntax Highlighting and Inspections

Dear RubyMine Developers.

I've been using RubyMine #820 for a week now (moved from Netbeans) and I am just starting to get used to the new keybings.I continue to be impressed with the product .

I do, however, have a suggestion regarding Ruby syntaxt highlighting and the Ruby "Unresolved Ruby Reference" inspection. I've attached a screenshot to illustrate my suggestion; the top half of the screenshot shows a Netbeans capture whilst the bottom halt of the screen shot shows the RubyMine equivalent.

Appologies in advance if I have misunderstood the "Unresolved Ruby Reference" inspection.

1. Is there anyway to configure the "Unresolved Ruby Reference" inspection to ignore all instance variables/methods? Notice in the RubyMine that topic.user, topic.locked and so on are marked as unresolved. Ideally, I would want this inspection to only highlight local unresolved variables or have an option that limit inspections to a method's scope only. I appreciate that due to Ruby's dynamic nature, it might not be possible to infer the type of a variable in the give example. Would be better to not highlight variables/methods in this situation? Otherwise, is there an alternative method by which only local unresolved variables are highlighted?

2. Note the return topic, post line in both the screenshots. both topic and post should be highlighted by the "Unresolved Reference" inpsection as the return references these two variables outside the Transaction block and as such they will both be undefined in that scope.

3. Unused variable highlight. Is there a way to highlight unused variables inside a method (for either a method parameter or local method? I note that there is a "Unsued symbol" but I don't think that's what I'm looking for.

Thanks for your time and a great product!



Attachment(s):
var_comp.jpg
4 comments
Comment actions Permalink

Hello Nazar,

I do, however, have a suggestion regarding Ruby syntaxt highlighting and the Ruby "Unresolved Ruby Reference" inspection. I've attached a screenshot to illustrate my suggestion; the top half of the screenshot shows a Netbeans capture whilst the bottom halt of the screen shot shows the RubyMine equivalent.


Appologies in advance if I have misunderstood the "Unresolved Ruby Reference" inspection.


1. Is there anyway to configure the "Unresolved Ruby Reference" inspection to ignore all instance variables/methods? Notice in the RubyMine that topic.user, topic.locked and so on are marked as unresolved. Ideally, I would want this inspection to only highlight local unresolved variables or have an option that limit inspections to a method's scope only. I appreciate that due to Ruby's dynamic nature, it might not be possible to infer the type of a variable in the give example. Would be better to not highlight variables/methods in this situation? Otherwise, is there an alternative method by which only local unresolved variables are highlighted?

Is there any chance to have a look at full method code? In screenshot attached I can see only the beggining. About rescticting scope of unresolved ruby reference: it's a point to discuss. Maybe we'll add this in future (maybe 1.5 version).

2. Note the return topic, post line in both the screenshots. both topic and post should be highlighted by the "Unresolved Reference" inpsection as the return references these two variables outside the Transaction block and as such they will both be undefined in that scope.

These 2 local variables can really be undefined in some cases. It's another inspection: Scope inspection. Maybe we should assume that every block call is guranteed to be executed.

3. Unused variable highlight. Is there a way to highlight unused variables inside a method (for either a method parameter or local method? I note that there is a "Unsued symbol" but I don't think that's what I'm looking for.

We already have an issue: http://www.jetbrains.net/jira/browse/RUBY-1841
Feel free to vote and track progress of it.

Regards,
Oleg

0
Comment actions Permalink

Hello Oleg.

Thank you for taking the time to reply to my post.

Is there any chance to have a look at full method code? In screenshot attached I can see only the beggining. About rescticting scope of unresolved ruby reference: it's a point to discuss. Maybe we'll add this in future (maybe 1.5 version).

  def self.create_topic_and_post_from_params(params, forum, user, ip)
    Topic.transaction do
      topic       = forum.topics.build(params)
      topic.user  = current_user
      if current_user.admin?
        topic.locked   = params[:locked]
        topic.sticky   = params[:sticky]
      end
      topic.save!
      #next create the first post in the topic
      post = topic.posts.build(params)
      post.user = user
      post.poster_ip = ip
      post.save!
      #
      return topic, post
    end
  end

Above is a class method for model Topic (app/models/topic.rb). I've bolded the instance variables that RubyMine highlights with the "Unresolved Ruby Reference" inspection. Pointing the mouse over poster_id (for instance) shows a hint with: Cannot find 'poster_id = ' more....

Topic defines posts as:

  has_many :posts, :order => 'posts.created_at', :dependent => :destroy do
    def last
      @last_post ||= find(:first, :order => 'posts.created_at desc')
    end
  end


Forum model defines :topics as:

  has_many :topics, :order => 'sticky desc, replied_at desc', :dependent => :destroy do
    def first
      @first_topic ||= find(:first)
    end
  end


topic.locked and topic.sticky are both mapped to database fields as is post.poster_id.

HTH.

These 2 local variables can really be undefined in some cases. It's another inspection: Scope inspection. Maybe we should assume that every block call is guranteed to be executed.


Perfect! The Ruby Scope inspection does indeed pick this up. My color settings were not setup to highlight this (I need to give my eyes a break )

We already have an issue: http://www.jetbrains.net/jira/browse/RUBY-1841
Feel free to vote and track progress of it.


Voted.

Again, thanks for your reply and help.

Cheers.

0
Comment actions Permalink

Hi again Oleg.

Just a quick followup to say the the "Unresolved Ruby Reference" is behaving strangley in my routes.rb file. Please see attachement.



Attachment(s):
routes.jpeg
0
Comment actions Permalink

Hi Nazar,

You can disable "Warn about implicit text matched resolve results" option in settings of Unresolved reference inspection. In this case if method call wasn't found by type inference algorithm but method with the same name exists in context (required scripts, Ruby SDK, attached gems), the call wont be highlighted with warning. Obviously the option will decrease smartness of RubyMine's Unresolved ref inspection but also decrease amount of false positives.

0

Please sign in to leave a comment.