Class: Nitpick::Warnings::IdenticalBranch

Inherits:
SimpleWarning show all
Defined in:
lib/nitpick/warnings/identical_branch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SimpleWarning

#==, discover

Constructor Details

#initialize(*args) ⇒ IdenticalBranch

Returns a new instance of IdenticalBranch.



5
6
7
# File 'lib/nitpick/warnings/identical_branch.rb', line 5

def initialize(*args)
  @cond, @yes_branch, @no_branch = args
end

Instance Attribute Details

#no_branchObject (readonly)

Returns the value of attribute no_branch.



4
5
6
# File 'lib/nitpick/warnings/identical_branch.rb', line 4

def no_branch
  @no_branch
end

#yes_branchObject (readonly)

Returns the value of attribute yes_branch.



4
5
6
# File 'lib/nitpick/warnings/identical_branch.rb', line 4

def yes_branch
  @yes_branch
end

Instance Method Details

#matches?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/nitpick/warnings/identical_branch.rb', line 9

def matches?
  yes_branch == no_branch
end

#messageObject



13
14
15
# File 'lib/nitpick/warnings/identical_branch.rb', line 13

def message
  "The branches of 'if (#{sexp_to_ruby(@cond)})' are identical."
end