Class Nitpick::Warnings::UselessBranch
In: lib/nitpick/warnings/useless_branch.rb
Parent: SimpleWarning

Methods

matches?   message   new  

Attributes

no_branch  [R] 
yes_branch  [R] 

Public Class methods

[Source]

# File lib/nitpick/warnings/useless_branch.rb, line 6
      def initialize(*args)
        @cond, @yes_branch, @no_branch = args
      end

Public Instance methods

[Source]

# File lib/nitpick/warnings/useless_branch.rb, line 10
      def matches?
        (yes_branch == s(:true) and no_branch == s(:false)) or
          (yes_branch == s(:false) and no_branch == s(:true))
      end

[Source]

# File lib/nitpick/warnings/useless_branch.rb, line 15
      def message
        "No need for an if. Just return '#{sexp_to_ruby(@cond)}' as a boolean."
      end

[Validate]