diff --git a/build/requirements.html b/build/requirements.html
new file mode 100644
index 000000000..daed6bc4b
--- /dev/null
+++ b/build/requirements.html
@@ -0,0 +1,216 @@
+
+
+
+
+ Test Documentation
+
+
+
+ A00 Irc Api Alert Queue (Vipgoci\Tests\Unit\A00IrcApiAlertQueue)
+
+ A00 Irc Api Alert Queue Unique (Vipgoci\Tests\Unit\A00IrcApiAlertQueueUnique)
+
+ - ✓ Irc queue unique 1
+ - ✓ Irc queue unique 2
+ - ✓ Irc queue unique 3
+
+ A00 Stats Counters (Vipgoci\Tests\Unit\A00StatsCounters)
+
+ - ✓ Counter report 1
+ - ✓ Counter report 2
+ - ✓ Counter update with issues found 1
+
+
+
+ - ✓ Curl headers 1
+ - ✓ Curl headers 2
+
+
+
+ Git Hub Oauth Signature Get Hmac Sha1 (Vipgoci\Tests\Unit\GitHubOauthSignatureGetHmacSha1)
+
+
+
+ - ✓ Blame filter comments 1
+
+ Misc Cache (Vipgoci\Tests\Unit\MiscCache)
+
+ - ✓ Cache 1
+ - ✓ Cache 2
+
+ Misc Cached Indication Str (Vipgoci\Tests\Unit\MiscCachedIndicationStr)
+
+ - ✓ Cached indication str 1
+
+ Misc Convert String To Type (Vipgoci\Tests\Unit\MiscConvertStringToType)
+
+ Misc File Extension (Vipgoci\Tests\Unit\MiscFileExtension)
+
+ - ✓ File extension 1
+ - ✓ File extension 2
+ - ✓ File extension 3
+
+ Misc Filter File Path (Vipgoci\Tests\Unit\MiscFilterFilePath)
+
+ - ✓ Filter file path 1
+ - ✓ Filter file path 2
+ - ✓ Filter file path 3
+ - ✓ Filter file path 4
+ - ✓ Filter file path 5
+
+ Misc Find Fields In Array (Vipgoci\Tests\Unit\MiscFindFieldsInArray)
+
+
+
+ Misc Git Hub Emojis (Vipgoci\Tests\Unit\MiscGitHubEmojis)
+
+ Misc Git Hub Pr Remove Drafts (Vipgoci\Tests\Unit\MiscGitHubPrRemoveDrafts)
+
+
+
+ Misc Round Array Items (Vipgoci\Tests\Unit\MiscRoundArrayItems)
+
+ Misc Sanitize Path Prefix (Vipgoci\Tests\Unit\MiscSanitizePathPrefix)
+
+ - ✓ Sanitize path prefix 1
+ - ✓ Sanitize path prefix 2
+ - ✓ Sanitize path prefix 3
+
+ Misc Sanitize String (Vipgoci\Tests\Unit\MiscSanitizeString)
+
+
+
+ - ✓ Option generic support comments match
+
+
+
+ - ✓ Option generic support comment process boolean
+ - ✓ Option generic support comment process string string not lower
+ - ✓ Option generic support comment process string string lower
+ - ✓ Option generic support comment process array not lower
+ - ✓ Option generic support comment process array lower
+
+ Options Get Starting With (Vipgoci\Tests\Unit\OptionsGetStartingWith)
+
+ - ✓ Options starting with
+
+ Options Sensitive Clean (Vipgoci\Tests\Unit\OptionsSensitiveClean)
+
+ Options Skip Folder Handle (Vipgoci\Tests\Unit\OptionsSkipFolderHandle)
+
+ - ✓ Option skip folder handle 1
+
+ Phpcs Scan Issues Filter Duplicate (Vipgoci\Tests\Unit\PhpcsScanIssuesFilterDuplicate)
+
+ - ✓ Filter duplicate 1
+ - ✓ Filter duplicate 2
+
+ Phpcs Scan Issues Filter Irrellevant (Vipgoci\Tests\Unit\PhpcsScanIssuesFilterIrrellevant)
+
+ - ✓ Do scan issues filter 1
+
+ Stats Run Time Measure (Vipgoci\Tests\Unit\StatsRunTimeMeasure)
+
+ - ✓ Runtime measure 1
+ - ✓ Runtime measure 2
+ - ✓ Runtime measure 3
+ - ✓ Runtime measure 4
+
+ Stats Stats Init (Vipgoci\Tests\Unit\StatsStatsInit)
+
+ Sys Exit (Vipgoci\Tests\Unit\SysExit)
+
+ Vipgoci Exit Status (Vipgoci\Tests\Unit\VipgociExitStatus)
+
+ - ✓ Exit status 1
+ - ✓ Exit status 2
+ - ✓ Exit status will return 250 when skipped files is found
+
+ Vipgoci Options Array Handle (Vipgoci\Tests\Unit\VipgociOptionsArrayHandle)
+
+ - ✓ Options array handle 1
+ - ✓ Options array handle 2
+ - ✓ Options array handle 3
+ - ✓ Options array handle 4
+
+ Vipgoci Options Bool Handle (Vipgoci\Tests\Unit\VipgociOptionsBoolHandle)
+
+ - ✓ Options bool handle 1
+ - ✓ Options bool handle 2
+ - ✓ Options bool handle 3
+
+ Vipgoci Options Integer Handle (Vipgoci\Tests\Unit\VipgociOptionsIntegerHandle)
+
+ - ✓ Options integer handle 1
+
+ Vipgoci Options Phpcs Runtime Set (Vipgoci\Tests\Unit\VipgociOptionsPhpcsRuntimeSet)
+
+ - ✓ Options phpcs runtime set 1
+
+ Vipgoci Skip File (Vipgoci\Tests\Unit\VipgociSkipFile)
+
+ - ✓ Get skipped files will return correct value
+ - ✓ Get skipped files will return correct value for total 0
+ - ✓ Set skipped files will set correct values
+ - ✓ Set p rs implicated skipped files will set correct values
+ - ✓ Get skipped files message
+ - ✓ Get skipped files message with number of lines exceeded different than default
+ - ✓ Get skipped files issue message
+ - ✓ Vipgoci verify skip file message duplication
+ - ✓ Get large files from comments
+ - ✓ Get large files from comments will return empty when comment is not about skipped files
+ - ✓ Get large files from p r comments
+ - ✓ Get large files from p r comments when comments are not about skipped files will return empty
+
+
+
\ No newline at end of file
diff --git a/github-api.php b/github-api.php
index 40eb79e29..2f1d7ab19 100644
--- a/github-api.php
+++ b/github-api.php
@@ -2561,6 +2561,18 @@ function vipgoci_github_pr_review_submit(
'comments' => array(),
);
+ $pr_reviews_commented = vipgoci_github_pr_reviews_get(
+ $repo_owner,
+ $repo_name,
+ $pr_number,
+ $github_token,
+ array(
+ 'login' => 'myself',
+ 'state' => array( 'COMMENTED' )
+ )
+ );
+
+ $results['skipped-files'][ $pr_number ] = vipgo_skip_file_check_previous_pr_comments( $results['skipped-files'][ $pr_number ], $pr_reviews_commented );
/*
* For each issue reported, format
@@ -2806,9 +2818,24 @@ function vipgoci_github_pr_review_submit(
}
/**
- * Format skipped files message if it validation has issues
+ * Check if there're previous existent comments about the same files
+ */
+ $pr_reviews_commented = vipgoci_github_pr_reviews_get(
+ $repo_owner,
+ $repo_name,
+ $pr_number,
+ $github_token,
+ array(
+ 'login' => 'myself',
+ 'state' => array( 'COMMENTED' )
+ )
+ );
+ $results['skipped-files'][ $pr_number ] = vipgo_skip_file_check_previous_pr_comments( $results['skipped-files'][ $pr_number ], $pr_reviews_commented );
+
+ /**
+ * Format skipped files message if the validation has issues
*/
- if ( ! empty( $results[ VIPGOCI_SKIPPED_FILES ][ $pr_number ]['issues'] ) ) {
+ if ( 0 === $results[ VIPGOCI_SKIPPED_FILES ][ $pr_number ]['total'] ) {
vipgoci_markdown_comment_add_pagebreak(
$github_postfields['body']
);
diff --git a/skip-file.php b/skip-file.php
index f48dc6c2c..ff8f179e4 100644
--- a/skip-file.php
+++ b/skip-file.php
@@ -50,17 +50,17 @@ function vipgoci_set_prs_implicated_skipped_files(
/**
* @param array $skipped
- * @param int $skip_large_files_limit
+ * @param int $skip_files_lines_limit
*
* @return string
*/
-function vipgoci_get_skipped_files_message( array $skipped, int $skip_large_files_limit ): string {
+function vipgoci_get_skipped_files_message( array $skipped, int $skip_files_lines_limit ): string {
$body = PHP_EOL . '**' . VIPGOCI_SKIPPED_FILES . '**' . PHP_EOL . PHP_EOL;
foreach ( $skipped['issues'] as $issue => $file ) {
$body .= vipgoci_get_skipped_files_issue_message(
$skipped['issues'][ $issue ],
$issue,
- $skip_large_files_limit
+ $skip_files_lines_limit
);
}
@@ -105,17 +105,17 @@ function vipgoci_get_skipped_files_issue_message(
* when there are previous comments
* preventing duplicated comments
*
- * @return array
+ * @return array $pr_issues_result
*/
function vipgo_skip_file_check_previous_pr_comments( array $pr_issues_results = [], array $comments = [] ): array {
/**
* If there is no previous comments in this PR, return
*/
- if ( 0 === count( $comments ) ) {
+ if ( 0 === count( $comments ) || 0 === $pr_issues_results['total'] ) {
return $pr_issues_results;
}
- $large_files = vipgo_get_large_files_from_pr_comments( $comments );
+ $skipped_files = vipgo_get_skipped_files_from_pr_comments( $comments );
$result = [ 'issues' => [ 'max-lines' => [] ], 'total' => 0 ];
/**
@@ -124,7 +124,7 @@ function vipgo_skip_file_check_previous_pr_comments( array $pr_issues_results =
* If so, prevent a new comment about the same file
*/
foreach ( $pr_issues_results['issues']['max-lines'] as $file ) {
- if ( in_array( $file, $large_files, true ) ) {
+ if ( in_array( $file, $skipped_files, true ) ) {
continue;
}
@@ -143,8 +143,8 @@ function vipgo_skip_file_check_previous_pr_comments( array $pr_issues_results =
* @return array
* @todo add unit tests
*/
-function vipgo_get_large_files_from_pr_comments( array $comments ): array {
- $large_files = [];
+function vipgo_get_skipped_files_from_pr_comments( array $comments ): array {
+ $skipped_files = [];
foreach ( $comments as $comment ) {
/**
@@ -154,11 +154,11 @@ function vipgo_get_large_files_from_pr_comments( array $comments ): array {
if ( false === strpos( $comment->body, 'skipped-files' ) ) {
continue;
}
- $files = vipgo_get_large_files_from_comment( $comment );
- $large_files = array_merge( $large_files, $files );
+ $files = vipgo_get_skipped_files_from_comment( $comment );
+ $skipped_files = array_merge( $skipped_files, $files );
}
- return $large_files;
+ return $skipped_files;
}
/**
@@ -166,7 +166,7 @@ function vipgo_get_large_files_from_pr_comments( array $comments ): array {
*
* @return string[]
*/
-function vipgo_get_large_files_from_comment( $comment ): array {
+function vipgo_get_skipped_files_from_comment( $comment ): array {
$prefix = '):';
$suffix = strlen( PHP_EOL . PHP_EOL . VIPGOCI_VALIDATION_MAXIMUM_DETAIL_MSG );
diff --git a/tests/unit/VipgociSkipFileTest.php b/tests/unit/VipgociSkipFileTest.php
index dc18484a9..daf153a53 100644
--- a/tests/unit/VipgociSkipFileTest.php
+++ b/tests/unit/VipgociSkipFileTest.php
@@ -270,12 +270,36 @@ public function testVipgociVerifySkipFileMessageDuplication(): void {
}
/**
- * @covers ::vipgo_get_large_files_from_comment
+ * @covers ::vipgo_skip_file_check_previous_pr_comments
+ * @dataProvider vipgociVerifySkipFileMessageDuplicationWillReturnOfCommentsOreIssuesResultsAreZeroProvider
+ */
+ public function testVipgociVerifySkipFileMessageDuplicationWillReturnOfCommentsOreIssuesResultsAreZero( array $skipped_files_result, array $comments ): void {
+ $result = vipgo_skip_file_check_previous_pr_comments(
+ $skipped_files_result,
+ $comments,
+ );
+
+ $this->assertSame(
+ $result,
+ $skipped_files_result,
+ );
+ }
+
+ public function vipgociVerifySkipFileMessageDuplicationWillReturnOfCommentsOreIssuesResultsAreZeroProvider(): array {
+ return [
+ [ [ 'total' => 0 ], [ 'any' ] ],
+ [ [ 'total' => 2 ], [] ],
+ [ [ 'issues' => [ 'max-lines' => [ 'test.php' ] ], 'total' => 1 ], [ $this->getCommentMock() ] ],
+ ];
+ }
+
+ /**
+ * @covers ::vipgo_get_skipped_files_from_comment
*/
public function testGetLargeFilesFromComments(): void {
$skippedFileCommentMock = $this->getSkippedFilesCommentMock();
- $result = vipgo_get_large_files_from_comment( $skippedFileCommentMock );
+ $result = vipgo_get_skipped_files_from_comment( $skippedFileCommentMock );
$expected = [
'GoogleAtom.php',
'MySuccessClass.php',
@@ -292,12 +316,12 @@ public function testGetLargeFilesFromComments(): void {
}
/**
- * @covers ::vipgo_get_large_files_from_comment
+ * @covers ::vipgo_get_skipped_files_from_comment
*/
public function testGetLargeFilesFromCommentsWillReturnEmptyWhenCommentIsNotAboutSkippedFiles(): void {
$commentMock = $this->getCommentMock();
- $result = vipgo_get_large_files_from_comment( $commentMock );
+ $result = vipgo_get_skipped_files_from_comment( $commentMock );
$expected = array();
$this->assertSame(
@@ -307,12 +331,12 @@ public function testGetLargeFilesFromCommentsWillReturnEmptyWhenCommentIsNotAbou
}
/**
- * @covers ::vipgo_get_large_files_from_pr_comments
+ * @covers ::vipgo_get_skipped_files_from_pr_comments
*/
public function testGetLargeFilesFromPRComments(): void {
$commentsSkippedFilesMock = $this->getSkippedFilesCommentsMock();
- $result = vipgo_get_large_files_from_pr_comments( $commentsSkippedFilesMock );
+ $result = vipgo_get_skipped_files_from_pr_comments( $commentsSkippedFilesMock );
$expected = [
'GoogleAtom.php',
'MySuccessClass.php',
@@ -329,12 +353,12 @@ public function testGetLargeFilesFromPRComments(): void {
}
/**
- * @covers ::vipgo_get_large_files_from_pr_comments
+ * @covers ::vipgo_get_skipped_files_from_pr_comments
*/
public function testGetLargeFilesFromPRCommentsWhenCommentsAreNotAboutSkippedFilesWillReturnEmpty(): void {
$commentsMock = $this->getCommentMock();
- $result = vipgo_get_large_files_from_pr_comments( [ $commentsMock ] );
+ $result = vipgo_get_skipped_files_from_pr_comments( [ $commentsMock ] );
$expected = array();
$this->assertSame(