public static void createComments( final ViolationsLogger violationsLogger, final List<Violation> violations, final Integer maxCommentSize, final CommentsProvider commentsProvider) { final CommentsCreator commentsCreator = new CommentsCreator(violationsLogger, commentsProvider, violations, maxCommentSize); commentsCreator.createComments(); }
public void toPullRequest() throws Exception { populateFromEnvironmentVariables(); checkState(); final CommentsProvider commentsProvider = new GitHubCommentsProvider(violationsLogger, this); createComments(violationsLogger, violations, MAX_VALUE, commentsProvider); }
public void createComments() { if (commentsProvider.shouldCreateCommentWithAllSingleFileComments()) { createCommentWithAllSingleFileComments(); } if (commentsProvider.shouldCreateSingleFileComment()) { createSingleFileComments(); } if (!commentsProvider.shouldCreateCommentWithAllSingleFileComments() && !commentsProvider.shouldCreateSingleFileComment()) { violationsLogger.log( INFO, "Will not comment because both 'CreateCommentWithAllSingleFileComments' and 'CreateSingleFileComment' is false."); } }
private void createCommentWithAllSingleFileComments() { final List<String> accumulatedComments = getAccumulatedComments( violations, files, commentsProvider.findCommentTemplate().orElse(null), maxCommentSize); for (final String accumulatedComment : accumulatedComments) { violationsLogger.log( INFO, "Asking " + commentsProvider.getClass().getSimpleName() + " to create comment with all single file comments."); List<Comment> oldComments = commentsProvider.getComments(); oldComments = filterCommentsWithContent(oldComments, FINGERPRINT_ACC); final List<Comment> alreadyMadeComments = filterCommentsWithContent(oldComments, accumulatedComment); removeOldCommentsThatAreNotStillReported(oldComments, alreadyMadeComments); if (violations.isEmpty()) { return; } final boolean commentHasNotBeenMade = alreadyMadeComments.isEmpty(); if (commentHasNotBeenMade) { commentsProvider.createCommentWithAllSingleFileComments(accumulatedComment); } } }
CommentsCreator( ViolationsLogger violationsLogger, final CommentsProvider commentsProvider, final List<Violation> violations, final Integer maxCommentSize) { checkNotNull(violations, "violations"); checkNotNull(commentsProvider, "commentsProvider"); this.violationsLogger = checkNotNull(violationsLogger, "violationsLogger"); this.commentsProvider = commentsProvider; files = commentsProvider.getFiles(); this.violations = filterChanged(violations); this.maxCommentSize = maxCommentSize; }
public void toPullRequest() throws Exception { if (Utils.isNullOrEmpty(commentTemplate)) { commentTemplate = getDefaultTemplate(); } final CommentsProvider commentsProvider = new GitLabCommentsProvider(violationsLogger, this); createComments(violationsLogger, violations, MAX_VALUE, commentsProvider); }
removeOldCommentsThatAreNotStillReported(oldComments, alreadyMadeComments.getComments());