Skip to content

Commit

Permalink
Add cop to avoid focus
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Feb 11, 2020
1 parent 9608b2a commit 6857889
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require:
- ./cop/none_without_block_cop
- ./cop/no_focus_cop

AllCops:
DisabledByDefault: true
Expand Down
19 changes: 19 additions & 0 deletions cop/no_focus_cop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true
require 'rubocop'

module Cop
# Make sure no tests are focused, from https://github.com/rubocop-hq/rubocop/issues/3773#issuecomment-420662102
class NoFocusCop < RuboCop::Cop::Cop
MSG = 'Remove `focus` from tests.'

def_node_matcher :focused?, <<-MATCHER
(send nil? :focus)
MATCHER

def on_send(node)
return unless focused?(node)

add_offense node
end
end
end

0 comments on commit 6857889

Please sign in to comment.