Class: FaceControl::CLI
- Inherits:
-
Object
- Object
- FaceControl::CLI
- Defined in:
- lib/face_control/cli.rb
Constant Summary collapse
- USAGE =
File.read("#{File.dirname(__FILE__)}/../../USAGE")
Instance Method Summary collapse
- #add_comments(pull_request, comments) ⇒ Object
- #check(pull_request, ignored_severities, logger) ⇒ Object
- #run ⇒ Object
Instance Method Details
#add_comments(pull_request, comments) ⇒ Object
38 39 40 41 42 |
# File 'lib/face_control/cli.rb', line 38 def add_comments(pull_request, comments) comments.each do |comment| pull_request.add_comment(comment.file, comment.line, comment.text) end end |
#check(pull_request, ignored_severities, logger) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/face_control/cli.rb', line 22 def check(pull_request, ignored_severities, logger) unless ignored_severities.empty? logger.info("Skipping RuboCop offenses with severities: #{ignored_severities.join(', ')}.") end filenames = pull_request.filenames_with_added_lines checkers = [ FaceControl::CheckerRunner.new(FaceControl::Checkers::RuboCop, filenames, ignored_severities: ignored_severities), FaceControl::CheckerRunner.new(FaceControl::Checkers::CoffeeLint, filenames), FaceControl::CheckerRunner.new(FaceControl::Checkers::Comments, filenames) ] checkers.map(&:comments).flatten end |
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/face_control/cli.rb', line 9 def run logger = Logger.new(STDOUT) project, repository, pull_request_id, ignored_severities = arguments pull_request = Stash::Config.new.server(logger).repository(project, repository).pull_request(pull_request_id) logger.info('Running checkers...') comments = check(pull_request, ignored_severities, logger) return if comments.empty? logger.info("#{comments.size} comments have been created. Posting only those for added lines...") add_comments(pull_request, comments) end |