Skip to content

Commit 190040c

Browse files
committed
IniSet: Ruleset tests
Since WPCS contains whitelist and blacklist, add each item of each to our ruleset test and adjust ruleset test line numbers. See #413.
1 parent fdeb48e commit 190040c

File tree

2 files changed

+210
-144
lines changed

2 files changed

+210
-144
lines changed

WordPressVIPMinimum/ruleset-test.inc

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ $b = function () {
5050
$listofthings = wp_cache_get( $listofthings );
5151
if ( ! $listofthings ) {
5252
$foo = "column = 'test'";
53-
53+
5454
$listofthings = $wpdb->query( 'SELECT something FROM somewhere WHERE ' . $foo ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Error.
5555
wp_cache_set( 'foo', $listofthings );
56-
}
56+
}
5757
};
5858

5959
// WordPress.DB.DirectDatabaseQuery
@@ -124,7 +124,7 @@ class TestClass extends MyClass {
124124
?> <?= esc_html( $var ); // Error.
125125

126126
// Squiz.PHP.CommentedOutCode <!-- Warning. -->
127-
// if (empty($this)) {echo 'This is will not work';}
127+
// if (empty($this)) {echo 'This is will not work';}
128128

129129
// Squiz.PHP.Eval
130130
eval('$var = 4;'); // Error + Message.
@@ -146,12 +146,6 @@ $handle = popen( '/bin/ls', 'r' ); // Warning.
146146
// WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting
147147
error_reporting(); // Error.
148148

149-
// WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_ini_set
150-
ini_set(); // Error.
151-
152-
// WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_ini_alter
153-
ini_alter(); // Error.
154-
155149
// WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_ini_restore
156150
ini_restore(); // Error.
157151

@@ -198,12 +192,58 @@ phpinfo(); // Error.
198192
// WordPress.PHP.DevelopmentFunctions.error_log_error_log
199193
error_log(); // Error.
200194

195+
// WordPress.PHP.IniSet
196+
ini_set( 'auto_detect_line_endings', true ); // Ok.
197+
ini_set( 'highlight.bg', '#000000' ); // Ok.
198+
ini_set( 'highlight.comment', '#000000' ); // Ok.
199+
ini_set( 'highlight.default', '#000000' ); // Ok.
200+
ini_set( 'highlight.html', '#000000' ); // Ok.
201+
ini_set( 'highlight.keyword', '#000000' ); // Ok.
202+
ini_set( 'highlight.string', '#000000' ); // Ok.
203+
ini_set( 'short_open_tag', 1 ); // Ok.
204+
ini_set( 'bcmath.scale', 1 ); // Error.
205+
ini_set( 'display_errors', 1 ); // Error.
206+
ini_set( 'error_reporting', 1 ); // Error.
207+
ini_set( 'filter.default', 1 ); // Error.
208+
ini_set( 'filter.default_flags', 1 ); // Error.
209+
ini_set( 'iconv.input_encoding', 1 ); // Error.
210+
ini_set( 'iconv.internal_encoding', 1 ); // Error.
211+
ini_set( 'iconv.output_encoding', 1 ); // Error.
212+
ini_set( 'ignore_user_abort', 1 ); // Error.
213+
ini_set( 'log_errors', 1 ); // Error.
214+
ini_set( 'max_execution_time', 1 ); // Error.
215+
ini_set( 'memory_limit', 1 ); // Error.
216+
ini_set( 'short_open_tag', 'off' ); // Error.
217+
ini_set( 'foo', true ); // Warning.
218+
ini_alter( 'auto_detect_line_endings', true ); // Ok.
219+
ini_alter( 'highlight.bg', '#000000' ); // Ok.
220+
ini_alter( 'highlight.comment', '#000000' ); // Ok.
221+
ini_alter( 'highlight.default', '#000000' ); // Ok.
222+
ini_alter( 'highlight.html', '#000000' ); // Ok.
223+
ini_alter( 'highlight.keyword', '#000000' ); // Ok.
224+
ini_alter( 'highlight.string', '#000000' ); // Ok.
225+
ini_alter( 'short_open_tag', 1 ); // Ok.
226+
ini_alter( 'bcmath.scale', 1 ); // Error.
227+
ini_alter( 'display_errors', 1 ); // Error.
228+
ini_alter( 'error_reporting', 1 ); // Error.
229+
ini_alter( 'filter.default', 1 ); // Error.
230+
ini_alter( 'filter.default_flags', 1 ); // Error.
231+
ini_alter( 'iconv.input_encoding', 1 ); // Error.
232+
ini_alter( 'iconv.internal_encoding', 1 ); // Error.
233+
ini_alter( 'iconv.output_encoding', 1 ); // Error.
234+
ini_alter( 'ignore_user_abort', 1 ); // Error.
235+
ini_alter( 'log_errors', 1 ); // Error.
236+
ini_alter( 'max_execution_time', 1 ); // Error.
237+
ini_alter( 'memory_limit', 1 ); // Error.
238+
ini_alter( 'short_open_tag', 'off' ); // Error.
239+
ini_alter( 'foo', true ); // Warning.
240+
201241
// WordPress.WP.AlternativeFunctions
202242
curl_init(); // Warning + Message.
203243
curl_close( $ch ); // Warning + Message.
204244
CURL_getinfo(); // Warning + Message.
205-
parse_url( 'http://example.com/' ); // Warning + Message.
206-
$json = json_encode( $thing ); // Warning + Message.
245+
parse_url( 'http://example.com/' ); // Warning.
246+
$json = json_encode( $thing ); // Warning.
207247
readfile(); // Warning.
208248
fclose(); // Warning.
209249
fopen(); // Warning.
@@ -430,7 +470,7 @@ $args = array(
430470
);
431471
$query_args['orderby'] = 'rand'; // Error.
432472

433-
// WordPressVIPMinimum.Performance.RegexpCompare
473+
// WordPressVIPMinimum.Performance.RegexpCompare
434474
$query_args = array(
435475
'posts_per_page' => 1,
436476
'post_status' => 'draft',

0 commit comments

Comments
 (0)