Class: Ducalis::RestOnlyCop
- Inherits:
-
RuboCop::Cop::Cop
- Object
- RuboCop::Cop::Cop
- Ducalis::RestOnlyCop
- Includes:
- RuboCop::Cop::DefNode, TypeResolving
- Defined in:
- lib/ducalis/cops/rest_only_cop.rb
Constant Summary collapse
- OFFENSE =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip | It's better for controllers to stay adherent to REST: | http://jeromedalbert.com/how-dhh-organizes-his-rails-controllers/. MESSAGE
- DETAILS =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip | [About RESTful architecture](<https://confreaks.tv/videos/railsconf2017-in-relentless-pursuit-of-rest>) MESSAGE
- WHITELIST =
%i[index show new edit create update destroy].freeze
Constants included from TypeResolving
TypeResolving::CONTROLLER_SUFFIXES, TypeResolving::MODELS_CLASS_NAMES, TypeResolving::SERVICES_PATH, TypeResolving::WORKERS_SUFFIXES
Instance Method Summary collapse
- #on_def(node) ⇒ Object (also: #on_defs)
Methods included from TypeResolving
Instance Method Details
#on_def(node) ⇒ Object Also known as: on_defs
22 23 24 25 26 27 28 29 30 |
# File 'lib/ducalis/cops/rest_only_cop.rb', line 22 def on_def(node) return unless in_controller? return if non_public?(node) method_name, = *node return if WHITELIST.include?(method_name) add_offense(node, :expression, OFFENSE) end |