Skip to content

Commit

Permalink
Add TODO and FIXME checker
Browse files Browse the repository at this point in the history
  • Loading branch information
snthpr1d3 committed May 12, 2016
1 parent 41d6245 commit 05b9689
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/face_control/checkers.rb
@@ -1,2 +1,3 @@
require 'face_control/checkers/rubocop'
require 'face_control/checkers/coffeelint'
require 'face_control/checkers/comments'
32 changes: 32 additions & 0 deletions lib/face_control/checkers/comments.rb
@@ -0,0 +1,32 @@
require 'face_control/comment'

module FaceControl
module Checkers
class Comments
def relevant_globs
%w(*.rb)
end

def command(filenames)
"grep -inEH '(todo|fixme)' #{filenames}"
end

def parse(command_output)
comments = []
unless command_output.empty?
command_output.each_line do |line|
file, line_num, description = line.split(":", 3)
comments.push(
Comment.new(
file: file,
line: line_num,
text: "File includes the annotation keyword: #{description}"
)
)
end
end
comments
end
end
end
end
3 changes: 2 additions & 1 deletion lib/face_control/cli.rb
Expand Up @@ -28,7 +28,8 @@ def check(pull_request, ignored_severities, logger)

checkers = [
FaceControl::CheckerRunner.new(FaceControl::Checkers::RuboCop, filenames, ignored_severities: ignored_severities),
FaceControl::CheckerRunner.new(FaceControl::Checkers::CoffeeLint, filenames)
FaceControl::CheckerRunner.new(FaceControl::Checkers::CoffeeLint, filenames),
FaceControl::CheckerRunner.new(FaceControl::Checkers::Comments, filenames)
]

checkers.map(&:comments).flatten
Expand Down
4 changes: 2 additions & 2 deletions test/face_control/cli_test.rb
Expand Up @@ -2,9 +2,9 @@

class CLITest < Minitest::Test
def test_check
pull_request = OpenStruct.new(filenames_with_added_lines: %w(test/fixtures/foo.rb test/fixtures/foo.coffee))
pull_request = OpenStruct.new(filenames_with_added_lines: %w(test/fixtures/foo.rb test/fixtures/commented.rb test/fixtures/foo.coffee))
logger = Logger.new('/dev/null')
comments = FaceControl::CLI.new.check(pull_request, %w(foo), logger)
assert_equal 2, comments.size
assert_equal 5, comments.size
end
end
7 changes: 7 additions & 0 deletions test/fixtures/commented.rb
@@ -0,0 +1,7 @@
class Foo
# FIXME: incorrect format of annotation keyword
# TODO: something
def something
"something"
end
end

0 comments on commit 05b9689

Please sign in to comment.