Class: DevDoc::Test::Lints::EnqueueDisableNamingChecker
- Inherits:
-
Object
- Object
- DevDoc::Test::Lints::EnqueueDisableNamingChecker
- Defined in:
- lib/dev_doc/test/lints/enqueue_disable_naming.rb
Overview
Framework-agnostic check: finds every inline disable of
DevDoc/Rails/NoPerformLaterInModel under app/models/ and returns
offender descriptions for directives whose enclosing method name does
not signal the enqueue (notify_* / send_* / deliver_*).
Wrapped by the Minitest module EnqueueDisableNaming below — see that
module for the rationale.
Constant Summary collapse
- DIRECTIVE =
%r{rubocop:(?:disable|todo)[^#]*DevDoc/Rails/NoPerformLaterInModel}- DEF_PATTERN =
Handles the inline-visibility form (
private def foo) too — without it, a disable inside such a method would false-positive as "no enclosing method". /\A(\s*)(?:private\s+|protected\s+|public\s+)?def\s+(?:self\.)?([a-zA-Z_][a-zA-Z0-9_]*[!?=]?)/- DEFAULT_NAME_PATTERN =
Bare
notify/send/deliver(with optional !/?) count too — the prefix convention is about the verb being first, not about requiring a suffix. /\A(?:notify|send|deliver)(?:_|[!?]?\z)/
Instance Method Summary collapse
-
#initialize(project_root, name_pattern: DEFAULT_NAME_PATTERN) ⇒ EnqueueDisableNamingChecker
constructor
A new instance of EnqueueDisableNamingChecker.
-
#offenders ⇒ Object
Returns an Array
of offender descriptions, or []when every disable sits inside a conforming method.
Constructor Details
#initialize(project_root, name_pattern: DEFAULT_NAME_PATTERN) ⇒ EnqueueDisableNamingChecker
Returns a new instance of EnqueueDisableNamingChecker.
25 26 27 28 |
# File 'lib/dev_doc/test/lints/enqueue_disable_naming.rb', line 25 def initialize(project_root, name_pattern: DEFAULT_NAME_PATTERN) @project_root = Pathname(project_root) @name_pattern = name_pattern end |
Instance Method Details
#offenders ⇒ Object
Returns an Array[] when
every disable sits inside a conforming method.
32 33 34 35 36 |
# File 'lib/dev_doc/test/lints/enqueue_disable_naming.rb', line 32 def offenders Dir.glob(@project_root.join('app/models/**/*.rb')).flat_map do |path| file_offenders(path) end end |