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
-
#exclude_limit ⇒ Integer
readonly
Number of offenses to allow before simply disabling the linter.
-
#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, limit: 15) ⇒ 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_corrected_lints, #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, limit: 15) ⇒ DisabledConfigReporter
Create the reporter that will display the report and write the config.
28 29 30 31 32 33 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 28 def initialize(log, limit: 15) super(log) @linters_with_lints = Hash.new { |hash, key| hash[key] = [] } @linters_lint_count = Hash.new(0) @exclude_limit = limit end |
Instance Attribute Details
#exclude_limit ⇒ Integer (readonly)
Number of offenses to allow before simply disabling the linter
50 51 52 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 50 def exclude_limit @exclude_limit end |
#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.
39 40 41 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 39 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.
45 46 47 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 45 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.
21 22 23 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 21 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.
56 57 58 59 60 61 62 63 64 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 56 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.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 71 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 |