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

Answered

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?

 

2
9 comments
Avatar
Permanently deleted user

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.

 

3
Avatar
Permanently deleted user

I have the same issue when using RSpec + FactoryBot + ActiveAdmin.

Method `create` from factory bot shows 'Missing 1 argument' error because it thinks that this method comes from ActiveAdmin.

Is there a way to specify the library to specific method?

3

Hello,

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

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

0

@TZ, is it on the latest 2019.3 RC? I didn't manage to reproduce it there.

0

I had a similar issue because I had an incorrect typehint in my class.

Original code:

but should've used

# @param users [Array<GetUsersSynced::SyncUser>]
0

Hi, it looks to me like this is still happening in 2022.1.3. 

Looks like the issue is also tracked here:

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

0

Alexander Farley Thank you for the update. Yes, the issue is still actual for 2022.1.3, you can vote for it at https://youtrack.jetbrains.com/issue/RUBY-26727

0

Please sign in to leave a comment.