Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rubocop/cop/lint/module_disclosure_date_present.rb
Views: 11784
# frozen_string_literal: true12module RuboCop3module Cop4module Lint5class ModuleDisclosureDatePresent < Base6extend AutoCorrector7include Alignment89MSG = 'Module is missing the required DisclosureDate information'1011def_node_matcher :find_update_info_node, <<~PATTERN12(def :initialize _args (begin (super $(send nil? {:update_info :merge_info} (lvar :info) (hash ...))) ...))13PATTERN1415def_node_matcher :find_nested_update_info_node, <<~PATTERN16(def :initialize _args (super $(send nil? {:update_info :merge_info} (lvar :info) (hash ...)) ...))17PATTERN1819def on_def(node)20return if node.source =~ /Generic Payload Handler/2122update_info_node = find_update_info_node(node) || find_nested_update_info_node(node)23return if update_info_node.nil?2425hash = update_info_node.arguments.find { |argument| hash_arg?(argument) }26disclosure_date_present = false27last_key = nil28hash.each_pair do |key, _value|29if key.value == 'DisclosureDate'30disclosure_date_present = true31end32last_key = key33end3435unless disclosure_date_present36add_offense(last_key || hash)37end38end3940private4142def hash_arg?(node)43node.type == :hash44end45end46end47end48end495051