Class: RuboCop::Cop::Packs::DocumentedPublicApis
- Inherits:
-
Style::DocumentationMethod
- Object
- Style::DocumentationMethod
- RuboCop::Cop::Packs::DocumentedPublicApis
- Extended by:
- T::Sig
- Defined in:
- lib/rubocop/cop/packs/documented_public_apis.rb
Overview
This cop helps ensure that each pack has a documented public API The following examples assume this basic setup.
Instance Method Summary collapse
Instance Method Details
#check(node) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rubocop/cop/packs/documented_public_apis.rb', line 51 def check(node) # This cop only applies for ruby files in `app/public` return if !processed_source.file_path.include?('app/public') return if non_public?(node) && !require_for_non_public_methods? left_sibling = node.left_sibling if left_sibling == :private_class_method if node_is_sorbet_signature?(node.parent.left_sibling) return if documentation_comment?(node.parent.left_sibling) elsif documentation_comment?(node.parent) return end elsif node_is_sorbet_signature?(left_sibling) return if documentation_comment?(node.left_sibling) elsif documentation_comment?(node) return end add_offense(node) end |
#node_is_sorbet_signature?(node) ⇒ Boolean
74 75 76 77 |
# File 'lib/rubocop/cop/packs/documented_public_apis.rb', line 74 def node_is_sorbet_signature?(node) # Is there a better way to check if a node is a sorbet signature? Probably! !!(node && (node.source.include?('sig do') || node.source.include?('sig {'))) end |
#support_autocorrect? ⇒ Boolean
46 47 48 |
# File 'lib/rubocop/cop/packs/documented_public_apis.rb', line 46 def support_autocorrect? false end |