Class: HamlLint::Reporter::DisabledConfigReporter
- Inherits:
-
ProgressReporter
- Object
- HamlLint::Reporter
- ProgressReporter
- HamlLint::Reporter::DisabledConfigReporter
- Defined in:
- lib/haml_lint/reporter/disabled_config_reporter.rb
Overview
Outputs a YAML configuration file based on existing violations.
Constant Summary collapse
- HEADING =
['# This configuration was generated by', '# `haml-lint --auto-gen-config`', "# on #{Time.now} using Haml-Lint version #{HamlLint::VERSION}.", '# The point is for the user to remove these configuration records', '# one by one as the lints are removed from the code base.', '# Note that changes in the inspected code, or installation of new', '# versions of Haml-Lint, may require this file to be generated again.'] .join("\n")
Constants inherited from ProgressReporter
Instance Attribute Summary collapse
-
#linters_lint_count ⇒ Hash<String, Integer] a Hash with linter name keys and lint count values
readonly
A hash of linters with the files that have that type of lint.
-
#linters_with_lints ⇒ Hash<String, Array<String>>
readonly
A hash of linters with the files that have that type of lint.
Class Method Summary collapse
-
.available? ⇒ false
Disables this reporter on the CLI since it doesn’t output anything.
Instance Method Summary collapse
-
#display_report(report) ⇒ void
Prints the standard progress reporter output and writes the new config file.
-
#finished_file(file, lints) ⇒ void
Prints the standard progress report marks and tracks files with lint.
-
#initialize(_log) ⇒ DisabledConfigReporter
constructor
Create the reporter that will display the report and write the config.
Methods inherited from ProgressReporter
Methods included from Utils
#pluralize, #print_lint, #print_location, #print_message, #print_summary, #print_summary_files, #print_summary_lints, #print_type
Methods inherited from HamlLint::Reporter
available, cli_name, descendants, inherited
Methods included from Hooks
Constructor Details
#initialize(_log) ⇒ DisabledConfigReporter
Create the reporter that will display the report and write the config.
26 27 28 29 30 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 26 def initialize(_log) super @linters_with_lints = Hash.new { |hash, key| hash[key] = [] } @linters_lint_count = Hash.new(0) end |
Instance Attribute Details
#linters_lint_count ⇒ Hash<String, Integer] a Hash with linter name keys and lint count values (readonly)
A hash of linters with the files that have that type of lint.
36 37 38 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 36 def linters_lint_count @linters_lint_count end |
#linters_with_lints ⇒ Hash<String, Array<String>> (readonly)
A hash of linters with the files that have that type of lint.
42 43 44 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 42 def linters_with_lints @linters_with_lints end |
Class Method Details
.available? ⇒ false
Disables this reporter on the CLI since it doesn’t output anything.
19 20 21 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 19 def self.available? false end |
Instance Method Details
#display_report(report) ⇒ void
This method returns an undefined value.
Prints the standard progress reporter output and writes the new config file.
48 49 50 51 52 53 54 55 56 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 48 def display_report(report) super File.write(ConfigurationLoader::AUTO_GENERATED_FILE, config_file_contents) log.log "Created #{ConfigurationLoader::AUTO_GENERATED_FILE}." log.log "Run `haml-lint --config #{ConfigurationLoader::AUTO_GENERATED_FILE}`" \ ", or add `inherits_from: #{ConfigurationLoader::AUTO_GENERATED_FILE}` in a " \ '.haml-lint.yml file.' end |
#finished_file(file, lints) ⇒ void
This method returns an undefined value.
Prints the standard progress report marks and tracks files with lint.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 63 def finished_file(file, lints) super if lints.any? lints.each do |lint| linters_with_lints[lint.linter.name] |= [lint.filename] linters_lint_count[lint.linter.name] += 1 end end end |