Class: PreCommit::DebuggerCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/pre-commit/checks/debugger_check.rb

Class Method Summary collapse

Class Method Details

.call(staged_files) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/pre-commit/checks/debugger_check.rb', line 5

def self.call(staged_files)
  files = files_to_check(staged_files)
  return if files.empty?

  errors = `#{Utils.grep} debugger #{files.join(" ")}`.strip
  return unless $?.success?

  "debugger statement(s) found:\n#{errors}"
end

.files_to_check(files) ⇒ Object



15
16
17
# File 'lib/pre-commit/checks/debugger_check.rb', line 15

def self.files_to_check(files)
  files.reject { |file| File.basename(file) =~ /^Gemfile/ }
end