RubyMine code inspection gives incorrect "Missing 1 argument(s)"

I have an array 'foo' that's returned by a method call.

RM code inspection thinks that 'foo.select' is a call into Kernel, not into Array, and gives an error: Missing 1 argument(s).

Is there a way to avoid this, other than suppressing that check?

 

3 comments

Hello,

sorry for the delay. I didn't manage to reproduce the problem so could you please provide a code sample showing it.

0
sftp.dir.glob(directory, "*.#{file_extension}")
.select { |f| Time.at(f.attributes.mtime) > 1.minutes.ago }
.map { |f| sftp.download!("#{directory}/#{f.name}") }
0

I had a similar issue (which led me here), though with a different method.

In my case it was in spec files, where I'd do `create(:foo)`.  This resolves to FactoryBot.create, but it was flagged with the same error - wrong number of parameters - and when I control-B'd on it to go to the definition it took me into the 'templates' directory of Rails, to the template that would generate a Rails controller.  It's not even a Ruby file (filename extension was RB but syntax was not valid Ruby), it's a template used for generating controllers.

I discovered I could fix this by marking the offending template file - a file I will never care about - as "plain text".  (Project view, right-click filename, "Mark as Plain Text").  This caused it to disappear from the index.

RubyMine doesn't know where the real `create` method comes from, but at least it's not linking it to something completely bogus now.

 

1

Please sign in to leave a comment.