Class: Rubocop::Cop::Team
- Inherits:
-
Object
- Object
- Rubocop::Cop::Team
- Defined in:
- lib/rubocop/cop/team.rb
Overview
FIXME
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#updated_source_file ⇒ Object
(also: #updated_source_file?)
readonly
Returns the value of attribute updated_source_file.
Instance Method Summary collapse
- #autocorrect? ⇒ Boolean
- #cops ⇒ Object
- #debug? ⇒ Boolean
-
#initialize(cop_classes, config, options = nil) ⇒ Team
constructor
A new instance of Team.
- #inspect_file(processed_source) ⇒ Object
Constructor Details
#initialize(cop_classes, config, options = nil) ⇒ Team
Returns a new instance of Team.
11 12 13 14 15 16 |
# File 'lib/rubocop/cop/team.rb', line 11 def initialize(cop_classes, config, = nil) @cop_classes = cop_classes @config = config @options = || { auto_correct: false, debug: false } @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/rubocop/cop/team.rb', line 7 def errors @errors end |
#updated_source_file ⇒ Object (readonly) Also known as: updated_source_file?
Returns the value of attribute updated_source_file.
7 8 9 |
# File 'lib/rubocop/cop/team.rb', line 7 def updated_source_file @updated_source_file end |
Instance Method Details
#autocorrect? ⇒ Boolean
18 19 20 |
# File 'lib/rubocop/cop/team.rb', line 18 def autocorrect? @options[:auto_correct] end |
#cops ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/rubocop/cop/team.rb', line 43 def cops @cops ||= begin @cop_classes.each_with_object([]) do |cop_class, instances| if cop_enabled?(cop_class) instances << cop_class.new(@config, @options) end end end end |
#debug? ⇒ Boolean
22 23 24 |
# File 'lib/rubocop/cop/team.rb', line 22 def debug? @options[:debug] end |
#inspect_file(processed_source) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/team.rb', line 26 def inspect_file(processed_source) # If we got any syntax errors, return only the syntax offenses. # Parser may return nil for AST even though there are no syntax errors. # e.g. sources which contain only comments unless processed_source.valid_syntax? diagnostics = processed_source.diagnostics return Lint::Syntax.offenses_from_diagnostics(diagnostics) end commissioner = Commissioner.new(cops) offenses = commissioner.investigate(processed_source) process_commissioner_errors( processed_source.file_path, commissioner.errors) autocorrect(processed_source.buffer, cops) offenses end |