Class: Rubocop::Cop::Style::Documentation

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/style/documentation.rb

Overview

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes or other other modules.

Constant Summary collapse

MSG =
'Missing top-level %s documentation comment.'

Instance Attribute Summary

Attributes inherited from Cop

#autocorrect, #corrections, #debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, all, #autocorrect_action, cop_name, cop_type, #do_autocorrect, #ignore_node, inherited, #initialize, lint?, #name, rails?, style?

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#investigate(processed_source) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rubocop/cop/style/documentation.rb', line 13

def investigate(processed_source)
  ast = processed_source.ast
  return unless ast

  ast_with_comments = Parser::Source::Comment.associate(
    ast,
    processed_source.comments
  )

  check_classes(ast, ast_with_comments)
  check_modules(ast, ast_with_comments)
end