Class: CodeownersValidator::DuplicateCli

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

Instance Method Summary collapse

Constructor Details

#initialize(codeowners_path, quiet: false) ⇒ DuplicateCli

Returns a new instance of DuplicateCli.



5
6
7
8
# File 'lib/codeowners_validator/cli/duplicate_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
# File 'lib/codeowners_validator/cli/duplicate_cli.rb', line 10

def run
  return false unless codeowners_present?

  lines = File.readlines(@codeowners_path, chomp: true)
  entries = Parser.new(lines).parse
  result = DuplicateChecker.new(entries).run

  if result.duplicates.empty?
    log "No duplicate CODEOWNERS entries found."
    true
  else
    print_duplicates(result.duplicates)
    false
  end
end