Module: RuboCop::Cop::NoAutobumpHelper Private
- Includes:
- HelperFunctions
- Included in:
- Cask::NoAutobump, FormulaAudit::NoAutobump
- Defined in:
- rubocops/shared/no_autobump_helper.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
This cop audits no_autobump!
reason.
Constant Summary collapse
- PUNCTUATION_MARKS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
%w[. ! ?].freeze
- DISALLOWED_NO_AUTOBUMP_REASONS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
%w[extract_plist latest_version].freeze
Instance Method Summary collapse
Methods included from HelperFunctions
#block_method_called_in_block?, #block_size, #check_precedence, #class_name, #component_precedes?, #end_column, #expression_negated?, #find_all_blocks, #find_block, #find_blocks, #find_const, #find_every_func_call_by_name, #find_every_method_call_by_name, #find_instance_call, #find_instance_method_call, #find_method_calls_by_name, #find_method_def, #find_method_with_args, #find_node_method_by_name, #find_strings, #format_component, #line_number, #line_start_column, #method_called?, #method_called_ever?, #method_name, #node_equals?, #offending_node, #parameters, #parameters_passed?, #problem, #regex_match_group, #size, #source_buffer, #start_column, #string_content
Instance Method Details
#audit_no_autobump(_type, reason_node) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'rubocops/shared/no_autobump_helper.rb', line 16 def audit_no_autobump(_type, reason_node) @offensive_node = T.let(reason_node, T.nilable(RuboCop::AST::Node)) reason_string = string_content(reason_node) if reason_node.sym_type? && DISALLOWED_NO_AUTOBUMP_REASONS.include?(reason_string) problem "`:#{reason_string}` reason should not be used" end return if reason_node.sym_type? if reason_string.start_with?("it ") problem "Do not start the reason with `it`" do |corrector| corrector.replace(T.must(@offensive_node).source_range, "\"#{reason_string[3..]}\"") end end return unless PUNCTUATION_MARKS.include?(reason_string[-1]) problem "Do not end the reason with a punctuation mark" do |corrector| corrector.replace(T.must(@offensive_node).source_range, "\"#{reason_string.chop}\"") end end |