Sha256: 749145647cd5c2fb6814c8c0403eb650aeeecfde4807b98bff45e0c2247458ec
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Lint # This cop checks for *rescue* blocks with no body. # # @example # # # bad # def some_method # do_something # rescue # end # # # bad # begin # do_something # rescue # end # # # good # def some_method # do_something # rescue # handle_exception # end # # # good # begin # do_something # rescue # handle_exception # end # # @example AllowComments: true (default) # # # good # def some_method # do_something # rescue # # do nothing # end # # # good # begin # do_something # rescue # # do nothing # end # # @example AllowComments: false # # # bad # def some_method # do_something # rescue # # do nothing # end # # # bad # begin # do_something # rescue # # do nothing # end class SuppressedException < Cop MSG = 'Do not suppress exceptions.' def on_resbody(node) return if node.body return if cop_config['AllowComments'] && comment_lines?(node) add_offense(node) end private def comment_lines?(node) processed_source[line_range(node)].any? { |line| comment_line?(line) } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.82.0 | lib/rubocop/cop/lint/suppressed_exception.rb |
rubocop-0.81.0 | lib/rubocop/cop/lint/suppressed_exception.rb |