Skip to content

Commit df4d43b

Browse files
committed
Merge pull request #571 from TGMPA/feature/scrutinizer-config
More comprehensive scrutinizer config.
2 parents a0aa2aa + 46b4485 commit df4d43b

File tree

2 files changed

+226
-42
lines changed

2 files changed

+226
-42
lines changed

.scrutinizer.yml

Lines changed: 202 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,46 @@
1+
tools:
2+
php_sim: true
3+
php_pdepend: true
4+
php_analyzer: true
5+
sensiolabs_security_checker: true
6+
17
checks:
28
php:
9+
useless_calls: true
10+
unused_variables: true
11+
unused_properties: true
12+
unused_parameters: true
13+
unused_methods: true
14+
unreachable_code: true
15+
too_many_arguments: true
16+
no_unnecessary_if: true
17+
no_unnecessary_final_modifier: true
18+
no_empty_statements: true
19+
fix_use_statements:
20+
remove_unused: true
21+
preserve_multiple: false
22+
preserve_blanklines: false
23+
order_alphabetically: true
24+
avoid_useless_overridden_methods: true
325
use_self_instead_of_fqcn: true
426
uppercase_constants: true
27+
single_namespace_per_use: false
528
simplify_boolean_return: true
6-
return_doc_comment_if_not_inferrable: true
29+
require_scope_for_properties: true
30+
require_scope_for_methods: true
731
remove_extra_empty_lines: true
32+
psr2_switch_declaration: true
33+
psr2_class_declaration: true
34+
properties_in_camelcaps: false
835
prefer_while_loop_over_for_loop: true
9-
parameter_doc_comments: true
10-
param_doc_comment_if_not_inferrable: true
36+
parameters_in_camelcaps: false
1137
optional_parameters_at_the_end: true
12-
no_short_method_names:
13-
minimum: '3'
14-
no_long_variable_names:
15-
maximum: '25'
16-
no_goto: true
38+
no_underscore_prefix_in_properties: true
39+
no_underscore_prefix_in_methods: true
40+
no_trailing_whitespace: true
41+
no_new_line_at_end_of_file: false
42+
no_error_suppression: false
43+
no_commented_out_code: true
1744
newline_at_end_of_file: true
1845
naming_conventions:
1946
local_variable: '^[a-z][a-z_0-9]*$'
@@ -27,24 +54,181 @@ checks:
2754
type_name: '^[A-Z][a-zA-Z0-9_]*$'
2855
exception_name: '^[A-Z][a-zA-Z0-9_]*Exception$'
2956
isser_method_name: '^(?:is|has|should|may|supports)'
30-
more_specific_types_in_doc_comments: true
57+
function_in_camel_caps: false
3158
fix_line_ending: true
32-
fix_use_statements:
33-
remove_unused: true
34-
preserve_multiple: false
35-
preserve_blanklines: false
36-
order_alphabetically: true
3759
encourage_single_quotes: true
3860
encourage_postdec_operator: true
61+
classes_in_camel_caps: false
62+
blank_line_after_namespace_declaration: true
3963
avoid_todo_comments: true
4064
avoid_perl_style_comments: true
4165
avoid_multiple_statements_on_same_line: true
66+
avoid_length_functions_in_loops: true
4267
avoid_fixme_comments: true
68+
avoid_closing_tag: true
69+
avoid_aliased_php_functions: true
4370
align_assignments: true
44-
no_global_keyword: false
45-
one_class_per_file: false
71+
duplication: true
72+
sql_injection_vulnerabilities: true
73+
security_vulnerabilities: true
74+
no_eval: true
75+
switch_fallthrough_commented: true
76+
phpunit_assertions: false
77+
overriding_private_members: true
78+
non_commented_empty_catch_block: true
79+
no_short_variable_names:
80+
minimum: '3'
81+
no_short_method_names:
82+
minimum: '3'
83+
no_long_variable_names:
84+
maximum: '30'
85+
no_goto: true
86+
avoid_usage_of_logical_operators: true
87+
return_doc_comments: true
88+
return_doc_comment_if_not_inferrable: true
89+
parameter_doc_comments: true
90+
param_doc_comment_if_not_inferrable: true
91+
more_specific_types_in_doc_comments: false
92+
fix_doc_comments: true
93+
verify_property_names: true
94+
verify_argument_usable_as_reference: true
95+
verify_access_scope_valid: true
96+
variable_existence: true
97+
use_statement_alias_conflict: true
98+
symfony_request_injection: true
99+
precedence_mistakes: true
100+
precedence_in_conditions: true
101+
parameter_non_unique: true
102+
no_property_on_interface: true
103+
no_non_implemented_abstract_methods: true
104+
no_duplicate_arguments: true
105+
missing_arguments: true
106+
method_calls_on_non_object: true
107+
instanceof_class_exists: true
108+
foreach_usable_as_reference: true
109+
foreach_traversable: true
110+
encourage_shallow_comparison: true
111+
closure_use_not_conflicting: true
112+
closure_use_modifiable: true
113+
catch_class_exists: true
114+
avoid_entity_manager_injection: true
115+
avoid_conflicting_incrementers: true
116+
assignment_of_null_return: true
117+
argument_type_checks: true
118+
avoid_unnecessary_concatenation: true
119+
deprecated_code_usage: true
46120
side_effects_or_types: false
121+
require_php_tag_first: true
122+
php5_style_constructor: true
123+
one_class_per_file: false
124+
no_short_open_tag: true
125+
no_global_keyword: true
126+
no_exit: false
47127
avoid_superglobals: false
128+
avoid_duplicate_types: true
129+
avoid_corrupting_byteorder_marks: true
130+
no_debug_code: true
131+
code_rating: true
48132

49-
tools:
50-
sensiolabs_security_checker: true
133+
coding_style:
134+
php:
135+
indentation:
136+
general:
137+
use_tabs: true
138+
size: 4
139+
switch:
140+
indent_case: true
141+
spaces:
142+
before_parentheses:
143+
function_declaration: false
144+
closure_definition: false
145+
function_call: false
146+
if: true
147+
for: true
148+
while: true
149+
switch: true
150+
catch: true
151+
array_initializer: false
152+
around_operators:
153+
assignment: true
154+
logical: true
155+
equality: true
156+
relational: true
157+
bitwise: true
158+
additive: true
159+
multiplicative: true
160+
shift: true
161+
unary_additive: false
162+
concatenation: true
163+
negation: true
164+
before_left_brace:
165+
class: true
166+
function: true
167+
if: true
168+
else: true
169+
for: true
170+
while: true
171+
do: true
172+
switch: true
173+
try: true
174+
catch: true
175+
finally: true
176+
before_keywords:
177+
else: true
178+
while: true
179+
catch: true
180+
finally: true
181+
within:
182+
brackets: false
183+
array_initializer: true
184+
grouping: true
185+
function_call: true
186+
function_declaration: true
187+
if: true
188+
for: true
189+
while: true
190+
switch: true
191+
catch: true
192+
type_cast: false
193+
ternary_operator:
194+
before_condition: true
195+
after_condition: true
196+
before_alternative: true
197+
after_alternative: true
198+
in_short_version: true
199+
other:
200+
before_comma: false
201+
after_comma: true
202+
before_semicolon: false
203+
after_semicolon: true
204+
after_type_cast: true
205+
braces:
206+
classes_functions:
207+
class: end-of-line
208+
function: end-of-line
209+
closure: end-of-line
210+
if:
211+
opening: end-of-line
212+
always: true
213+
else_on_new_line: false
214+
for:
215+
opening: end-of-line
216+
always: true
217+
while:
218+
opening: end-of-line
219+
always: true
220+
do_while:
221+
opening: end-of-line
222+
always: true
223+
while_on_new_line: false
224+
switch:
225+
opening: end-of-line
226+
try:
227+
opening: end-of-line
228+
catch_on_new_line: false
229+
finally_on_new_line: false
230+
upper_lower_casing:
231+
keywords:
232+
general: lower
233+
constants:
234+
true_false_null: lower

class-tgm-plugin-activation.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,11 +1015,11 @@ public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) {
10151015
$subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) );
10161016

10171017
if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) {
1018-
$from = untrailingslashit( $source );
1019-
$to = trailingslashit( $remote_source ) . $desired_slug;
1018+
$from_path = untrailingslashit( $source );
1019+
$to_path = trailingslashit( $remote_source ) . $desired_slug;
10201020

1021-
if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) {
1022-
return trailingslashit( $to );
1021+
if ( true === $GLOBALS['wp_filesystem']->move( $from_path, $to_path ) ) {
1022+
return trailingslashit( $to_path );
10231023
} else {
10241024
return new WP_Error( 'rename_failed', esc_html__( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
10251025
}
@@ -1186,7 +1186,7 @@ public function notices() {
11861186
$line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n";
11871187

11881188
if ( ! current_user_can( 'activate_plugins' ) && ! current_user_can( 'install_plugins' ) && ! current_user_can( 'update_plugins' ) ) {
1189-
$rendered = esc_html__( $this->strings['notice_cannot_install_activate'] ) . ' ' . esc_html__( $this->strings['contact_admin'] );
1189+
$rendered = esc_html__( $this->strings['notice_cannot_install_activate'] ) . ' ' . esc_html__( $this->strings['contact_admin'] );
11901190
$rendered .= $this->create_user_action_links_for_notice( 0, 0, 0, $line_template );
11911191
} else {
11921192

@@ -1452,13 +1452,13 @@ public function sanitize_key( $key ) {
14521452
$key = preg_replace( '`[^A-Za-z0-9_-]`', '', $key );
14531453

14541454
/**
1455-
* Filter a sanitized key string.
1456-
*
1457-
* @since 2.5.0
1458-
*
1459-
* @param string $key Sanitized key.
1460-
* @param string $raw_key The key prior to sanitization.
1461-
*/
1455+
* Filter a sanitized key string.
1456+
*
1457+
* @since 2.5.0
1458+
*
1459+
* @param string $key Sanitized key.
1460+
* @param string $raw_key The key prior to sanitization.
1461+
*/
14621462
return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key );
14631463
}
14641464

@@ -1501,7 +1501,7 @@ public function config( $config ) {
15011501
* @since 2.0.0
15021502
*
15031503
* @param array $install_actions Existing array of actions.
1504-
* @return array Amended array of actions.
1504+
* @return false|array Amended array of actions.
15051505
*/
15061506
public function actions( $install_actions ) {
15071507
// Remove action links on the TGMPA install page.
@@ -1871,7 +1871,7 @@ public function is_plugin_updatetable( $slug ) {
18711871
if ( ! $this->is_plugin_installed( $slug ) ) {
18721872
return false;
18731873
} else {
1874-
return ( $this->does_plugin_have_update( $slug ) && $this->can_plugin_update( $slug ) );
1874+
return ( false !== $this->does_plugin_have_update( $slug ) && $this->can_plugin_update( $slug ) );
18751875
}
18761876
}
18771877

@@ -2069,7 +2069,7 @@ public function show_tgmpa_version() {
20692069
*
20702070
* @since 2.4.0
20712071
*
2072-
* @return object The TGM_Plugin_Activation object.
2072+
* @return \TGM_Plugin_Activation The TGM_Plugin_Activation object.
20732073
*/
20742074
public static function get_instance() {
20752075
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
@@ -2275,7 +2275,7 @@ protected function _gather_plugin_data() {
22752275
if ( ! empty( $upgrade_notice ) ) {
22762276
$table_data[ $i ]['upgrade_notice'] = $upgrade_notice;
22772277

2278-
add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 );
2278+
add_action( "tgmpa_after_plugin_row_{$slug}", array( $this, 'wp_plugin_update_row' ), 10, 2 );
22792279
}
22802280

22812281
$table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin );
@@ -3267,7 +3267,7 @@ public function run( $options ) {
32673267
*
32683268
* @param array $plugins The plugin sources needed for installation.
32693269
* @param array $args Arbitrary passed extra arguments.
3270-
* @return string|bool Install confirmation messages on success, false on failure.
3270+
* @return array|false Install confirmation messages on success, false on failure.
32713271
*/
32723272
public function bulk_install( $plugins, $args = array() ) {
32733273
// [TGMPA + ] Hook auto-activation in.
@@ -3566,22 +3566,22 @@ public function add_strings() {
35663566
/* translators: 1: plugin name, 2: error message. */
35673567
$this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' );
35683568
/* translators: 1: plugin name. */
3569-
$this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' );
3569+
$this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' );
35703570

35713571
if ( $this->tgmpa->is_automatic ) {
35723572
// Automatic activation strings.
3573-
$this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
3573+
$this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
35743574
/* translators: 1: plugin name. */
3575-
$this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'tgmpa' ) . '</span>.</a>';
3576-
$this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' );
3575+
$this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'tgmpa' ) . '</span>.</a>';
3576+
$this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' );
35773577
/* translators: 1: plugin name, 2: action number 3: total number of actions. */
35783578
$this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
35793579
} else {
35803580
// Default installation strings.
3581-
$this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
3581+
$this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
35823582
/* translators: 1: plugin name. */
3583-
$this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'tgmpa' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'tgmpa' ) . '</span>.</a>';
3584-
$this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' );
3583+
$this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'tgmpa' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'tgmpa' ) . '</span>.</a>';
3584+
$this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' );
35853585
/* translators: 1: plugin name, 2: action number 3: total number of actions. */
35863586
$this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
35873587
}

0 commit comments

Comments
 (0)