summaryrefslogtreecommitdiff
path: root/cops/to_pdf_no_debug.rb
blob: 01f60402fba1cca8110af0bfbb76be0313fdb215 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      class ToPDFNoDebug < Base
        def_node_matcher :to_pdf_with_debug?, <<~'END'
          (send nil? :to_pdf <(dstr ...) (hash ... (pair (sym :debug) (true)))>)
        END

        MSG = 'debug flag not permitted'
        RESTRICT_ON_SEND = [:to_pdf]

        def on_send node
          return unless to_pdf_with_debug? node
          add_offense node
        end
      end
    end
  end
end