Skip to content

Commit

Permalink
Merge pull request #8 from dr2m/todo
Browse files Browse the repository at this point in the history
Add TODO and FIXME checker
  • Loading branch information
vassilevsky committed May 13, 2016
2 parents 3fa53e4 + 4900042 commit d566fb3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/face_control/checkers.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
require 'face_control/checkers/rubocop'
require 'face_control/checkers/coffeelint'
require 'face_control/checkers/comments'
23 changes: 23 additions & 0 deletions lib/face_control/checkers/comments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'face_control/comment'

module FaceControl
module Checkers
class Comments

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

def parse(command_output)
command_output.lines.map do |line|
file, line_num = line.split(":", 3)
Comment.new(
file: file,
line: line_num,
text: "Do not bury this task in code. Do it now or create a JIRA issue."
)
end
end
end
end
end
3 changes: 2 additions & 1 deletion lib/face_control/cli.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Foo
# FIXME: incorrect format of annotation keyword
# TODO: something
def something
"something"
end
end

0 comments on commit d566fb3

Please sign in to comment.