Skip to content

Commit

Permalink
Allow debugger when it is in another context.
Browse files Browse the repository at this point in the history
We only want to catch debugger when it is being used as a debugger
statement. Not when it is in commments, or quotes, or any other
intended use.
  • Loading branch information
jish committed Jun 11, 2014
1 parent 214e861 commit d144398
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/pre_commit/checks/debugger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def message
end

def pattern
'debugger'
'-e "^[ ]*debugger"'
end

def self.description
Expand Down
2 changes: 1 addition & 1 deletion test/files/debugger_file.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class DebuggerFile
def blam
debugger
debugger
end
end
3 changes: 3 additions & 0 deletions test/files/valid_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# class docs for rubocop
class ValidFile

# Comments with the word: debugger should be allowed
def no_problems_here!
end

end
2 changes: 1 addition & 1 deletion test/unit/plugins/pre_commit/checks/debugger_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
it "fails if file contains debugger" do
subject.call([fixture_file('debugger_file.rb')]).must_equal(<<-EXPECTED)
debugger statement(s) found:
test/files/debugger_file.rb:3: debugger
test/files/debugger_file.rb:3: debugger
EXPECTED
end

Expand Down

0 comments on commit d144398

Please sign in to comment.