KEMBAR78
Discourage "it" as function parameter · Issue #14322 · rubocop/rubocop · GitHub
Skip to content

Discourage "it" as function parameter #14322

@forthrin

Description

@forthrin

Is your feature request related to a problem? Please describe.

def foo1(it = 'bar')
  puts it
  'baz'.then { puts it }
end

foo1

def foo2(its = 'bar')
  puts its
  'baz'.then { |its| puts its }
end

foo2
bar
bar
bar
baz

Lint/ShadowingOuterLocalVariable doesn't warn when a function parameter named it takes precedence over an implicit it in a block.

Describe the solution you'd like

Warn about it (pun intended).

Describe alternatives you've considered

Rather, warn about using it as a function parameter, which seems like asking for trouble in the first place.

Additional context

I love it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions