Class: CodeownersValidator::GhostCli

Inherits:
Object
  • Object
show all
Defined in:
lib/codeowners_validator/cli/ghost_cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(codeowners_path, quiet: false) ⇒ GhostCli

Returns a new instance of GhostCli.



5
6
7
8
# File 'lib/codeowners_validator/cli/ghost_cli.rb', line 5

def initialize(codeowners_path, quiet: false)
  @codeowners_path = codeowners_path
  @quiet = quiet
end

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/codeowners_validator/cli/ghost_cli.rb', line 10

def run
  return false unless codeowners_present?

  repo_root = File.dirname(File.expand_path(@codeowners_path))
  lines = File.readlines(@codeowners_path, chomp: true)
  entries = Parser.new(lines).parse
  result = GhostPatternChecker.new(entries, repo_root).run

  if result.ghosts.empty?
    log "No ghost CODEOWNERS patterns found."
    true
  else
    print_ghosts(result.ghosts)
    false
  end
end