Class: DebuggerCheck
- Inherits:
-
Object
- Object
- DebuggerCheck
- Defined in:
- lib/pre-commit/checks/debugger_check.rb
Instance Attribute Summary collapse
-
#error_message ⇒ Object
Returns the value of attribute error_message.
-
#grep_command ⇒ Object
Returns the value of attribute grep_command.
-
#staged_files ⇒ Object
Returns the value of attribute staged_files.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#error_message ⇒ Object
Returns the value of attribute error_message.
2 3 4 |
# File 'lib/pre-commit/checks/debugger_check.rb', line 2 def end |
#grep_command ⇒ Object
Returns the value of attribute grep_command.
2 3 4 |
# File 'lib/pre-commit/checks/debugger_check.rb', line 2 def grep_command @grep_command end |
#staged_files ⇒ Object
Returns the value of attribute staged_files.
2 3 4 |
# File 'lib/pre-commit/checks/debugger_check.rb', line 2 def staged_files @staged_files end |
Class Method Details
.call(quiet = false) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/pre-commit/checks/debugger_check.rb', line 4 def self.call(quiet=false) dirs = ['app/', 'lib/', 'script/', 'vendor/', 'test/'].reject {|d| !File.exists?(d)} check = new check.staged_files = Utils.staged_files(*dirs) result = check.run if !quiet && !result $stderr.puts check. end result end |
Instance Method Details
#detected_bad_code? ⇒ Boolean
28 29 30 31 |
# File 'lib/pre-commit/checks/debugger_check.rb', line 28 def detected_bad_code? cmd = grep_command || "git grep" system("#{cmd} -nH -q debugger #{staged_files}") end |
#instances_of_debugger_violations ⇒ Object
33 34 35 36 |
# File 'lib/pre-commit/checks/debugger_check.rb', line 33 def instances_of_debugger_violations cmd = grep_command || "git grep" `#{cmd} -nH debugger #{staged_files}` end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pre-commit/checks/debugger_check.rb', line 16 def run return true if staged_files.empty? if detected_bad_code? = "pre-commit: debugger statement found:\n" += instances_of_debugger_violations false else true end end |