Skip to content

Files

Latest commit

 

History

History
46 lines (36 loc) · 485 Bytes

Style-RedundantAssignment.md

File metadata and controls

46 lines (36 loc) · 485 Bytes

Pattern: Redundant assignment before returning

Issue: -

Description

Checks for redundant assignment before returning.

Examples

# bad
def test
  x = foo
  x
end

# bad
def test
  if x
    z = foo
    z
  elsif y
    z = bar
    z
  end
end

# good
def test
  foo
end

# good
def test
  if x
    foo
  elsif y
    bar
  end
end

Further Reading