diff --git a/lib/face_control/checkers.rb b/lib/face_control/checkers.rb index 6c83b54..0107e51 100644 --- a/lib/face_control/checkers.rb +++ b/lib/face_control/checkers.rb @@ -1,2 +1,3 @@ require 'face_control/checkers/rubocop' require 'face_control/checkers/coffeelint' +require 'face_control/checkers/comments' diff --git a/lib/face_control/checkers/comments.rb b/lib/face_control/checkers/comments.rb new file mode 100644 index 0000000..77e2f5a --- /dev/null +++ b/lib/face_control/checkers/comments.rb @@ -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 diff --git a/lib/face_control/cli.rb b/lib/face_control/cli.rb index 53895e1..3e1f8f7 100644 --- a/lib/face_control/cli.rb +++ b/lib/face_control/cli.rb @@ -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 diff --git a/test/face_control/cli_test.rb b/test/face_control/cli_test.rb index 1be6a8f..f74690e 100644 --- a/test/face_control/cli_test.rb +++ b/test/face_control/cli_test.rb @@ -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 diff --git a/test/fixtures/commented.rb b/test/fixtures/commented.rb new file mode 100644 index 0000000..bfdfb27 --- /dev/null +++ b/test/fixtures/commented.rb @@ -0,0 +1,7 @@ +class Foo + # FIXME: incorrect format of annotation keyword + # TODO: something + def something + "something" + end +end