lib/slim_lint/linter/rubocop.rb in slim_lint-0.4.0 vs lib/slim_lint/linter/rubocop.rb in slim_lint-0.5.0

- old
+ new

@@ -49,11 +49,11 @@ # # @param rubocop [RuboCop::CLI] # @param file [String] # @return [Array<RuboCop::Cop::Offense>] def lint_file(rubocop, file) - rubocop.run(%w[--format SlimLint::OffenseCollector] << file) + rubocop.run(rubocop_flags << file) OffenseCollector.offenses end # Aggregates RuboCop offenses and converts them to {SlimLint::Lint}s # suitable for reporting. @@ -64,11 +64,20 @@ offenses.select { |offense| !config['ignored_cops'].include?(offense.cop_name) } .each do |offense| @lints << Lint.new(self, document.file, source_map[offense.line], - "#{offense.cop_name}: #{offense.message}") + offense.message) end + end + + # Returns flags that will be passed to RuboCop CLI. + # + # @return [Array<String>] + def rubocop_flags + flags = %w[--format SlimLint::OffenseCollector] + flags += ['--config', ENV['SLIM_LINT_RUBOCOP_CONF']] if ENV['SLIM_LINT_RUBOCOP_CONF'] + flags end end # Collects offenses detected by RuboCop. class OffenseCollector < ::RuboCop::Formatter::BaseFormatter