Skip to content

Commit 0f653a8

Browse files
committed
Add skip large files limit parameter
1 parent c01757d commit 0f653a8

File tree

5 files changed

+76
-64
lines changed

5 files changed

+76
-64
lines changed

defines.php

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,83 +4,83 @@
44
* Version number.
55
*/
66

7-
define( 'VIPGOCI_VERSION', '1.0.7' );
7+
define( 'VIPGOCI_VERSION', '1.0.7' );
88

99
/*
1010
* Define minimum version requirements.
1111
*/
12-
define( 'VIPGOCI_GIT_VERSION_MINIMUM', '2.10' );
12+
define( 'VIPGOCI_GIT_VERSION_MINIMUM', '2.10' );
1313

1414
/*
1515
* Client-ID for curl-requests, etc.
1616
*/
1717

18-
define( 'VIPGOCI_CLIENT_ID', 'automattic-vip-go-ci' );
19-
define( 'VIPGOCI_SYNTAX_ERROR_STR', 'PHP Syntax Errors Found' );
20-
define( 'VIPGOCI_GITHUB_ERROR_STR', 'GitHub API communication error. ' .
21-
'Please contact a human.' );
18+
define( 'VIPGOCI_CLIENT_ID', 'automattic-vip-go-ci' );
19+
define( 'VIPGOCI_SYNTAX_ERROR_STR', 'PHP Syntax Errors Found' );
20+
define( 'VIPGOCI_GITHUB_ERROR_STR', 'GitHub API communication error. ' .
21+
'Please contact a human.' );
2222
/*
2323
* Base URLs for GitHub
2424
*/
25-
define( 'VIPGOCI_GITHUB_WEB_BASE_URL', 'https://github.com' );
25+
define( 'VIPGOCI_GITHUB_WEB_BASE_URL', 'https://github.com' );
2626

2727
/* Define if not defined. Unit-tests can define this for testing. */
2828
if ( ! defined( 'VIPGOCI_GITHUB_BASE_URL' ) ) {
29-
define( 'VIPGOCI_GITHUB_BASE_URL', 'https://api.github.com' );
29+
define( 'VIPGOCI_GITHUB_BASE_URL', 'https://api.github.com' );
3030
}
3131

3232
/*
3333
* Various messages.
3434
*/
3535

3636
define( 'VIPGOCI_FILE_IS_APPROVED_MSG', 'File is approved in review database ' .
37-
'(hashes-to-hashes).' );
37+
'(hashes-to-hashes).' );
3838

3939
define( 'VIPGOCI_REVIEW_COMMENTS_TOTAL_MAX',
40-
'Total number of active review comments per ' .
41-
'Pull-Request has been reached and some ' .
42-
'comments might not appear as a result. ' .
43-
'Please resolve some issues to see more' );
40+
'Total number of active review comments per ' .
41+
'Pull-Request has been reached and some ' .
42+
'comments might not appear as a result. ' .
43+
'Please resolve some issues to see more' );
4444

4545
define( 'VIPGOCI_PHPCS_INVALID_SNIFFS',
46-
'Invalid PHPCS sniff(s) specified in ' .
47-
'options or options file. Those have ' .
48-
'been ignored temporarily. Please ' .
49-
'update the options so that scanning ' .
50-
'can continue as expected. ' );
46+
'Invalid PHPCS sniff(s) specified in ' .
47+
'options or options file. Those have ' .
48+
'been ignored temporarily. Please ' .
49+
'update the options so that scanning ' .
50+
'can continue as expected. ' );
5151

5252
define( 'VIPGOCI_PHPCS_INVALID_SNIFFS_CONT',
53-
'<br />' .
54-
PHP_EOL . PHP_EOL .
55-
'* Option name: `%s`' . PHP_EOL .
56-
'* Invalid sniff(s): `%s`' . PHP_EOL
57-
);
53+
'<br />' .
54+
PHP_EOL . PHP_EOL .
55+
'* Option name: `%s`' . PHP_EOL .
56+
'* Invalid sniff(s): `%s`' . PHP_EOL
57+
);
5858

5959
define( 'VIPGOCI_PHPCS_DUPLICATE_SNIFFS',
60-
'Sniff(s) has been found in duplicate in ' .
61-
'options or options file. Those have ' .
62-
'been ignored temporarily. Please ' .
63-
'update the options so that scanning ' .
64-
'can continue as expected. ' .
65-
'<br /> ');
60+
'Sniff(s) has been found in duplicate in ' .
61+
'options or options file. Those have ' .
62+
'been ignored temporarily. Please ' .
63+
'update the options so that scanning ' .
64+
'can continue as expected. ' .
65+
'<br /> ' );
6666

6767
define( 'VIPGOCI_PHPCS_DUPLICATE_SNIFFS_CONT',
68-
'<br />' .
69-
PHP_EOL . PHP_EOL .
70-
'* Options: `%s` and `%s`' . PHP_EOL .
71-
'* Sniff(s) in duplicate: `%s`' . PHP_EOL .
72-
'<br />' );
68+
'<br />' .
69+
PHP_EOL . PHP_EOL .
70+
'* Options: `%s` and `%s`' . PHP_EOL .
71+
'* Sniff(s) in duplicate: `%s`' . PHP_EOL .
72+
'<br />' );
7373

7474
/*
7575
* Define exit-codes
7676
*/
7777

78-
define( 'VIPGOCI_EXIT_NORMAL', 0 );
79-
define( 'VIPGOCI_EXIT_EXEC_TIME', 249 );
80-
define( 'VIPGOCI_EXIT_CODE_ISSUES', 250 );
81-
define( 'VIPGOCI_EXIT_SYSTEM_PROBLEM', 251 );
82-
define( 'VIPGOCI_EXIT_GITHUB_PROBLEM', 252 );
83-
define( 'VIPGOCI_EXIT_USAGE_ERROR', 253 );
78+
define( 'VIPGOCI_EXIT_NORMAL', 0 );
79+
define( 'VIPGOCI_EXIT_EXEC_TIME', 249 );
80+
define( 'VIPGOCI_EXIT_CODE_ISSUES', 250 );
81+
define( 'VIPGOCI_EXIT_SYSTEM_PROBLEM', 251 );
82+
define( 'VIPGOCI_EXIT_GITHUB_PROBLEM', 252 );
83+
define( 'VIPGOCI_EXIT_USAGE_ERROR', 253 );
8484

8585

8686
/*
@@ -91,16 +91,16 @@
9191
* -- altering these is not recommended.
9292
*/
9393

94-
define( 'VIPGOCI_STATS_PHPCS', 'phpcs' );
95-
define( 'VIPGOCI_STATS_LINT', 'lint' );
96-
define( 'VIPGOCI_STATS_HASHES_API', 'hashes-api' );
94+
define( 'VIPGOCI_STATS_PHPCS', 'phpcs' );
95+
define( 'VIPGOCI_STATS_LINT', 'lint' );
96+
define( 'VIPGOCI_STATS_HASHES_API', 'hashes-api' );
9797

9898
/*
9999
* Define auto-approval types
100100
*/
101101

102-
define( 'VIPGOCI_APPROVAL_AUTOAPPROVE', 'auto-approval' );
103-
define( 'VIPGOCI_APPROVAL_HASHES_API', 'hashes-api' );
102+
define( 'VIPGOCI_APPROVAL_AUTOAPPROVE', 'auto-approval' );
103+
define( 'VIPGOCI_APPROVAL_HASHES_API', 'hashes-api' );
104104

105105

106106
/*
@@ -115,42 +115,43 @@
115115
* Defines for vipgoci_counter_report()
116116
*/
117117

118-
define( 'VIPGOCI_COUNTERS_DUMP', 'dump' );
119-
define( 'VIPGOCI_COUNTERS_DO', 'do' );
118+
define( 'VIPGOCI_COUNTERS_DUMP', 'dump' );
119+
define( 'VIPGOCI_COUNTERS_DO', 'do' );
120120

121121
/*
122122
* Define for vipgoci_cache()
123123
*/
124124

125-
define( 'VIPGOCI_CACHE_CLEAR', '--VIPGOCI-CACHE-CLEAR-0x321--' );
125+
define( 'VIPGOCI_CACHE_CLEAR', '--VIPGOCI-CACHE-CLEAR-0x321--' );
126126

127127
/*
128128
* Defines for files.
129129
*/
130130

131-
define( 'VIPGOCI_OPTIONS_FILE_NAME', '.vipgoci_options' );
131+
define( 'VIPGOCI_OPTIONS_FILE_NAME', '.vipgoci_options' );
132132

133133
/*
134134
* Define for vipgoci_git_diffs_fetch()
135135
*/
136136

137-
define( 'VIPGOCI_GIT_DIFF_CALC_CHANGES', array ('+' => 'additions', '-' => 'deletions') );
138-
define( 'VIPGOCI_GIT_DIFF_DATA_SOURCE_GIT_REPO', 'local-git-repo' );
139-
define( 'VIPGOCI_GIT_DIFF_DATA_SOURCE_GITHUB_API', 'github-api' );
140-
137+
define( 'VIPGOCI_GIT_DIFF_CALC_CHANGES', array( '+' => 'additions', '-' => 'deletions' ) );
138+
define( 'VIPGOCI_GIT_DIFF_DATA_SOURCE_GIT_REPO', 'local-git-repo' );
139+
define( 'VIPGOCI_GIT_DIFF_DATA_SOURCE_GITHUB_API', 'github-api' );
141140

142141

143142
/**
144-
* Define file number of lines limit
143+
* Defines skip large files constants
144+
* Should be called in the run constructor/injected
145145
*/
146-
define( 'VIPGOCI_SKIPPED_FILES', 'skipped-files' );
147-
148-
define( 'VIPGOCI_VALIDATION_MAXIMUM_LINES_LIMIT', 15000 );
149-
define( 'VIPGOCI_VALIDATION_MAXIMUM_LINES', 'max-lines' );
150-
define(
151-
'VIPGOCI_VALIDATION',
152-
[
153-
VIPGOCI_VALIDATION_MAXIMUM_LINES
146+
function vipgoci_define_skip_large_files_dependencies( array $options ): void {
147+
define( 'VIPGOCI_SKIPPED_FILES', 'skipped-files' );
148+
define( 'VIPGOCI_VALIDATION_MAXIMUM_LINES_LIMIT', $options['skip-large-files-limit'] );
149+
define( 'VIPGOCI_VALIDATION_MAXIMUM_LINES', 'large-files-limit' );
150+
define(
151+
'VIPGOCI_VALIDATION',
152+
[
153+
VIPGOCI_VALIDATION_MAXIMUM_LINES
154154
=> 'Maximum number of lines exceeded (' . VIPGOCI_VALIDATION_MAXIMUM_LINES_LIMIT . ')'
155-
]
156-
);
155+
]
156+
);
157+
}

main.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ function vipgoci_options_recognized() {
225225
'branches-ignore:',
226226
'local-git-repo:',
227227
'skip-large-files:',
228+
'skip-large-files-limit:',
228229

229230
/*
230231
* Environmental & repo configuration
@@ -840,6 +841,8 @@ function vipgoci_run() {
840841

841842
vipgoci_option_bool_handle( $options, 'skip-large-files', 'true' );
842843

844+
vipgoci_option_integer_handle( $options, 'skip-large-files-limit', 1500 );
845+
843846
vipgoci_option_bool_handle( $options, 'lint-skip-folders-in-repo-options-file', 'false' );
844847

845848
vipgoci_option_bool_handle( $options, 'dismiss-stale-reviews', 'false' );
@@ -850,6 +853,8 @@ function vipgoci_run() {
850853

851854
vipgoci_option_bool_handle( $options, 'review-comments-include-severity', 'false' );
852855

856+
vipgoci_define_skip_large_files_dependencies( $options );
857+
853858
if (
854859
( false === $options['lint'] ) &&
855860
( false === $options['phpcs'] )

tests/A09LintLintScanCommitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ protected function setUp(): void {
5555

5656
$this->options['skip-large-files'] = true;
5757

58+
$this->options['skip-large-files-limit'] = 1500;
59+
5860
global $vipgoci_debug_level;
5961
$vipgoci_debug_level = 2;
6062
}

tests/PhpcsScanScanCommitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ protected function setUp(): void {
6666
$this->options['skip-draft-prs'] = false;
6767

6868
$this->options['skip-large-files'] = true;
69+
70+
$this->options['skip-large-files'] = 1500;
6971
}
7072

7173
protected function tearDown(): void {

tests/PhpcsScanSingleFileTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ protected function setUp(): void {
5757
$this->options['phpcs-skip-folders'] = array();
5858

5959
$this->options['skip-large-files'] = true;
60+
61+
$this->options['skip-large-files'] = 1500;
6062
}
6163

6264
protected function tearDown(): void {

0 commit comments

Comments
 (0)