Sha256: f10104f2020ed10429e59a6dd834092850e04853a800b5280ce63725881a6b17

Contents?: true

Size: 867 Bytes

Versions: 8

Compression:

Stored size: 867 Bytes

Contents

require 'simplabs/excellent/checks/base'

module Simplabs

  module Excellent

    module Checks

      # This check reports +case+ statements that don't have an +else+ clause that would be executed when no case matches. If the tested value will never
      # adopt any other values than the ones tested for in the cases, this should be expressed in the code by e.g. throwing an exception in the +else+
      # clause.
      #
      # ==== Applies to
      #
      # * +case+ statements
      class CaseMissingElseCheck < Base

        def initialize #:nodoc:
          super
          @interesting_nodes = [:case]
          @interesting_files = [/\.rb$/, /\.erb$/]
        end

        def evaluate(context) #:nodoc:
          add_warning(context, 'Case statement is missing else clause.') unless context.has_else_clause?
        end

      end

    end

  end

end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
simplabs-excellent-1.4.0 lib/simplabs/excellent/checks/case_missing_else_check.rb
simplabs-excellent-1.4.1 lib/simplabs/excellent/checks/case_missing_else_check.rb
simplabs-excellent-1.4.2 lib/simplabs/excellent/checks/case_missing_else_check.rb
simplabs-excellent-1.5.0 lib/simplabs/excellent/checks/case_missing_else_check.rb
simplabs-excellent-1.5.1 lib/simplabs/excellent/checks/case_missing_else_check.rb
simplabs-excellent-1.5.2 lib/simplabs/excellent/checks/case_missing_else_check.rb
simplabs-excellent-1.5.3 lib/simplabs/excellent/checks/case_missing_else_check.rb
excellent-1.5.4 lib/simplabs/excellent/checks/case_missing_else_check.rb