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
- DEFAULT_EXCLUDE_LIMIT =
15- HEADING_TEMPLATE =
['# This configuration was generated by', '# `%<command>s`', '# on %<timestamp>s using Haml-Lint version %<version>s.', '# 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: DEFAULT_EXCLUDE_LIMIT, options: {}) ⇒ 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: DEFAULT_EXCLUDE_LIMIT, options: {}) ⇒ DisabledConfigReporter
Create the reporter that will display the report and write the config.
30 31 32 33 34 35 36 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 30 def initialize(log, limit: DEFAULT_EXCLUDE_LIMIT, options: {}) super(log) @linters_with_lints = Hash.new { |hash, key| hash[key] = [] } @linters_lint_count = Hash.new(0) @exclude_limit = limit @options = end |
Instance Attribute Details
#exclude_limit ⇒ Integer (readonly)
Number of offenses to allow before simply disabling the linter
53 54 55 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 53 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.
42 43 44 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 42 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.
48 49 50 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 48 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.
23 24 25 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 23 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.
59 60 61 62 63 64 65 66 67 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 59 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.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/haml_lint/reporter/disabled_config_reporter.rb', line 74 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 |