Class: Codeowners::Cli::Wizards::UselessPatternWizard

Inherits:
Object
  • Object
show all
Includes:
InteractiveOps
Defined in:
lib/codeowners/cli/wizards/useless_pattern_wizard.rb

Overview

Suggests to fix useless patterns in the codeowners file. Only returns decision without applying any modifications.

Instance Method Summary collapse

Methods included from InteractiveOps

#ask, #yes?

Instance Method Details

#suggest_fixing(line) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/codeowners/cli/wizards/useless_pattern_wizard.rb', line 13

def suggest_fixing(line)
  puts "Pattern #{line.pattern.inspect} doesn't match."
  suggestion = Codeowners::Cli::SuggestFileFromPattern.new(line.pattern).pick_suggestion

  # TODO: Handle duplicate patterns.
  if suggestion
    apply_suggestion(line, suggestion)
  else
    pattern_fix(line)
  end
end