Module: RuboCop::Cop::DevDoc::Auth::AdjacentJustification

Included in:
LoginOnlyPolicyJustification, UnscopedFindJustification, Migration::AvoidNonNull
Defined in:
lib/rubocop/cop/dev_doc/auth/adjacent_justification.rb

Overview

The adjacent-justification contract shared by the "flag and make the developer state the mechanism" cops (the auth family, and DevDoc/Migration/AvoidNonNull's column-kind markers): an offense is silenced by a comment containing the cop's marker either on the flagged node's own line (trailing) or in the contiguous comment block ending on the line directly above it. Adjacency is the point — a marker elsewhere in the file justifies nothing. Host cops provide justification_marker, or pass an explicit marker: per call. A String marker matches by substring (suits multi-word phrases); a Regexp marker matches by match? against the downcased comment text (use \b anchors for single-word markers, where substring matching would let "enumeration" satisfy an enum marker).

With standalone_only: true the upward walk only crosses comment-ONLY lines. Use this when the checked node is a class/module declaration: there the "trailing comment on a preceding code line" rule would let a marker trailing the PREVIOUS class's end silence the next class.