Class: Tabs
- Inherits:
-
Object
- Object
- Tabs
- Defined in:
- lib/pre-commit/checks/tabs.rb
Instance Attribute Summary collapse
-
#error_message ⇒ Object
Returns the value of attribute error_message.
-
#staged_files ⇒ Object
Returns the value of attribute staged_files.
Class Method Summary collapse
-
.call ⇒ Object
Maintaining the functionality of ‘call` for backwards compatibility Currently, the call method is expected to: * run a check * print any corresponding error messages if the check fails.
Instance Method Summary collapse
Instance Attribute Details
#error_message ⇒ Object
Returns the value of attribute error_message.
3 4 5 |
# File 'lib/pre-commit/checks/tabs.rb', line 3 def end |
#staged_files ⇒ Object
Returns the value of attribute staged_files.
3 4 5 |
# File 'lib/pre-commit/checks/tabs.rb', line 3 def staged_files @staged_files end |
Class Method Details
.call ⇒ Object
Maintaining the functionality of ‘call` for backwards compatibility Currently, the call method is expected to:
-
run a check
-
print any corresponding error messages if the check fails
9 10 11 12 13 |
# File 'lib/pre-commit/checks/tabs.rb', line 9 def self.call check = new check.staged_files = Utils.staged_files('*') check.run end |
Instance Method Details
#detected_bad_code? ⇒ Boolean
34 35 36 |
# File 'lib/pre-commit/checks/tabs.rb', line 34 def detected_bad_code? system("grep -PnIH -q '^\t' #{staged_files}") end |
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pre-commit/checks/tabs.rb', line 15 def run # There is nothing to check if staged_files.empty? return true end if detected_bad_code? = "pre-commit: detected tab before initial space:\n" += violations $stderr.puts $stderr.puts @passed = false else @passed = true end end |
#violations ⇒ Object
38 39 40 |
# File 'lib/pre-commit/checks/tabs.rb', line 38 def violations `grep -PnIH '^\t' #{staged_files}` end |