Class: RuboCop::Lsp::StdinRunner Private
| Relationships & Source Files | |
| Namespace Children | |
|
Exceptions:
| |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
::RuboCop::Runner
|
|
|
Instance Chain:
self,
::RuboCop::Runner
|
|
| Inherits: |
RuboCop::Runner
|
| Defined in: | lib/rubocop/lsp/stdin_runner.rb |
Overview
Constant Summary
-
DEFAULT_RUBOCOP_OPTIONS =
# File 'lib/rubocop/lsp/stdin_runner.rb', line 22{ stderr: true, force_exclusion: true, formatters: ['RuboCop::Formatter::BaseFormatter'], todo_file: nil, todo_ignore_files: [] }.freeze
::RuboCop::Runner - Inherited
Class Method Summary
- .new(config_store) ⇒ StdinRunner constructor Internal use only
::RuboCop::Runner - Inherited
Instance Attribute Summary
- #config_for_working_directory readonly Internal use only
- #offenses readonly Internal use only
- #processed_source readonly Internal use only
::RuboCop::Runner - Inherited
| #aborting=, #aborting?, #errors, #warnings, #cached_run?, #except_redundant_cop_disable_directive?, | |
| #in_memory_corrections_possible? | Custom ruby extractors may derive their fragments from the file on disk rather than from the passed processed source, so corrections can only be kept in memory when the default extractor is used. |
| #parallel_supported_by_options? |
|
| #project_index_disables_parallel?, #project_index_enabled? | |
Instance Method Summary
- #formatted_source Internal use only
-
#reset_project_index
Internal use only
Drop the cached project index so the next run rebuilds it.
- #run(path, contents, options, prism_result: nil) Internal use only
-
#build_project_index(target_files)
private
Internal use only
The project index is built from files on disk, not from the in-memory buffer, so it does not change while the user is typing.
- #do_inspection_loop(file, source = nil) private Internal use only
- #file_finished(_file, offenses) private Internal use only
::RuboCop::Runner - Inherited
| #diffs | The |
| #run, #add_redundant_disables, #assemble_team, #build_project_index, #bundled_gem_files, #cached_result, | |
| #check_for_infinite_loop | Check whether a run created source identical to a previous run, which means that we definitely have an infinite loop. |
| #check_for_redundant_disables?, | |
| #collect_problems | Keeps the errors and warnings a file causes apart from the rest of the run’s. |
| #considered_failure?, #default_config, #do_inspection_loop, #extract_ruby_sources, #file_finished, #file_iterator, #file_offense_cache, #file_offenses, | |
| #file_problems | Formatters get the messages without the colors added for the terminal. |
| #file_started, | |
| #finalize_corrections | Write the file once, even when the loop was left through an exception (e.g. an infinite correction loop), like the per-iteration writes used to be. |
| #find_target_files, #finished_report, | |
| #forget_mobilized_cops | Lets a runner that is reused from run to run pick up a different |
| #formatter_set, | |
| #get_processed_source | rubocop:disable-next Metrics/MethodLength. |
| #initial_processed_source |
|
| #inspect_and_correct, #inspect_file, #inspect_files, #inspect_iteration, #iterate_until_no_changes, #list_files, #mark_as_safe_by_config?, #minimum_severity_to_fail, #mobilize_cop_badge?, #mobilize_team, #mobilized_cop_classes, #offense_displayed?, | |
| #offense_limit | Files are reported in order, so which offenses survive the limit does not depend on how the run was parallelized. |
| #offenses_to_report, | |
| #only_changed | The project index is deliberately built from the unfiltered file list: cross-file offenses must not depend on which files happen to have changed. |
| #parallel_file_iterator, #plain_messages, #process_file, #process_remaining_report_queue, #process_report_queue_entry, | |
| #project_index_files | The index always covers the whole project, not just the files being inspected: cross-file offenses must not depend on which files a particular run happens to include, or single-file runs (editors, CI sharding) would see different offenses than full runs. |
| #qualify_option_cop_names, | |
| #record_diff |
|
| #redundant_cop_disable_directive, #run_in_parallel?, #save_in_cache, #serial_file_iterator, | |
| #standby_team | A Cop::Team instance is stateful and may change when inspecting. |
| #style_guide_cops_only?, #supports_safe_autocorrect?, #team_for_redundant_disables, #warn_about_elided_offenses | |
Constructor Details
.new(config_store) ⇒ StdinRunner
# File 'lib/rubocop/lsp/stdin_runner.rb', line 30
def initialize(config_store) @options = {} @offenses = [] @warnings = [] @errors = [] @config_for_working_directory = config_store.for_pwd super(@options, config_store) end
Instance Attribute Details
#config_for_working_directory (readonly)
[ GitHub ]# File 'lib/rubocop/lsp/stdin_runner.rb', line 20
attr_reader :offenses, :config_for_working_directory, :processed_source
#offenses (readonly)
[ GitHub ]# File 'lib/rubocop/lsp/stdin_runner.rb', line 20
attr_reader :offenses, :config_for_working_directory, :processed_source
#processed_source (readonly)
[ GitHub ]# File 'lib/rubocop/lsp/stdin_runner.rb', line 20
attr_reader :offenses, :config_for_working_directory, :processed_source
Instance Method Details
#build_project_index(target_files) (private)
The project index is built from files on disk, not from the in-memory buffer, so it does not change while the user is typing. Build it once and reuse it across runs instead of re-walking and re-indexing the whole project on every request; #reset_project_index drops the cache when the on-disk state changes.
# File 'lib/rubocop/lsp/stdin_runner.rb', line 84
def build_project_index(target_files) return if @project_index_built super @project_index_built = true end
#do_inspection_loop(file, source = nil) (private)
[ GitHub ]# File 'lib/rubocop/lsp/stdin_runner.rb', line 95
def do_inspection_loop(file, source = nil) processed_source, offenses = super @processed_source = processed_source [processed_source, offenses] end
#file_finished(_file, offenses) (private)
[ GitHub ]#formatted_source
[ GitHub ]# File 'lib/rubocop/lsp/stdin_runner.rb', line 65
def formatted_source @options[:stdin] end
#reset_project_index
Drop the cached project index so the next run rebuilds it. Called when a file is saved or a watched file changes, i.e. when the on-disk state the index is derived from may have changed.
# File 'lib/rubocop/lsp/stdin_runner.rb', line 72
def reset_project_index @project_index = nil @project_index_built = false end
#run(path, contents, options, prism_result: nil)
# File 'lib/rubocop/lsp/stdin_runner.rb', line 42
def run(path, contents, , prism_result: nil) # The cops mobilized for a configuration are cached, which only holds while # every run asks for the same ones. selection = .values_at(:only, :except) unless selection == @cop_selection forget_mobilized_cops @cop_selection = selection end @options = .merge(DEFAULT_RUBOCOP_OPTIONS) @options[:stdin] = contents @prism_result = prism_result @processed_source = nil @offenses = [] @warnings = [] @errors = [] super([path]) raise Interrupt if aborting? end