Skip to content

Commit febd6a9

Browse files
authored
Merge pull request #7 from backdrop-contrib/cs
Code style fixes from coder_review.admin.inc..coder_review.common.inc.
2 parents 4f6aae2 + dbbe940 commit febd6a9

File tree

4 files changed

+80
-31
lines changed

4 files changed

+80
-31
lines changed

coder.drush.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,3 @@ function drush_coder_format() {
6868
}
6969
}
7070
}
71-

coder_review.admin.inc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function coder_review_admin_settings($form, &$form_state) {
1616
require_once realpath(dirname(__FILE__)) . '/coder_review.common.inc';
1717

1818
$settings = _coder_review_get_default_settings();
19-
dpm($settings);
19+
2020
$form = _coder_review_settings_form($settings, $system, $files);
2121
$form['help'] = array(
2222
'#type' => 'markup',
@@ -33,7 +33,8 @@ function coder_review_admin_settings($form, &$form_state) {
3333
'#value' => t('Save configuration'),
3434
);
3535

36-
return $form;}
36+
return $form;
37+
}
3738

3839
/**
3940
* Form submission handler for coder_review_settings_form().
@@ -53,7 +54,7 @@ function coder_review_settings_form_submit($form, &$form_state) {
5354
*/
5455
function coder_review_admin_settings_submit($form, &$form_state) {
5556
form_state_values_clean($form_state);
56-
dpm($form_state['values']);
57+
5758
$config = config('coder_review.settings');
5859
foreach ($form_state['values'] as $key => $value) {
5960
$config->set($key, $value);

coder_review.api.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
* - #image:
1919
* - #description:
2020
* - #file:
21-
2221
*
2322
* Each Rule array must have the following keys:
2423
* - #type: (required) A string that describes the type of coder check. Possible
@@ -49,7 +48,6 @@
4948
* - #link: (optional)
5049
*
5150
* A Results array is an associative array ...
52-
*
5351
*/
5452

5553
/**
@@ -64,7 +62,7 @@
6462
* provided by the module that implements this hook.
6563
*/
6664
function hook_reviews() {
67-
$review = array(
68-
);
65+
$review = array();
66+
6967
return $review;
7068
}

coder_review.common.inc

Lines changed: 74 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ function coder_review_reviews() {
8484
* @see _coder_review_get_default_settings()
8585
*/
8686
function _coder_review_default_reviews() {
87-
// Do not use backdrop_map_assoc() so that this will run without Backdrop being
88-
// bootstraped.
87+
// Do not use backdrop_map_assoc() so that this will run without Backdrop
88+
// being bootstraped.
8989
return array(
9090
'style' => 'style',
9191
'sql' => 'sql',
@@ -200,7 +200,12 @@ function do_coder_reviews(array $coder_args) {
200200
}
201201
}
202202

203-
$results['#stats'] = array('minor' => 0, 'normal' => 0, 'critical' => 0, 'ignored' => 0);
203+
$results['#stats'] = array(
204+
'minor' => 0,
205+
'normal' => 0,
206+
'critical' => 0,
207+
'ignored' => 0,
208+
);
204209

205210
// Skip PHP include files when the user requested severity is above minor.
206211
if (isset($coder_args['#php_minor']) && _substr($coder_args['#filename'], -4) == '.php') {
@@ -301,10 +306,19 @@ function theme_coder_review_warning($variables) {
301306
}
302307
if ($lineno) {
303308
if ($lineno > 0) {
304-
$warning = _t('Line @number: !warning [@review_@rule]', array('@number' => $lineno, '!warning' => $warning, '@review' => $review_name, '@rule' => $rule_name));
309+
$warning = _t('Line @number: !warning [@review_@rule]', array(
310+
'@number' => $lineno,
311+
'!warning' => $warning,
312+
'@review' => $review_name,
313+
'@rule' => $rule_name,
314+
));
305315
}
306316
else {
307-
$warning = _t('File: !warning [@review_@rule]', array('!warning' => $warning, '@review' => $review_name, '@rule' => $rule_name));
317+
$warning = _t('File: !warning [@review_@rule]', array(
318+
'!warning' => $warning,
319+
'@review' => $review_name,
320+
'@rule' => $rule_name,
321+
));
308322
}
309323
if ($line) {
310324
$warning .= '<pre>' . check_plain($line) . '</pre>';
@@ -451,7 +465,7 @@ function _coder_review_read_and_parse_file(array &$coder_args) {
451465
// Get the current character.
452466
$char = $content[$pos];
453467
// Look ahead to the next character, to cater for \r\n line ends.
454-
$next_char = isset($content[$pos+1]) ? $content[$pos+1] : '';
468+
$next_char = isset($content[$pos + 1]) ? $content[$pos + 1] : '';
455469
if ($char == "\n" || $char . $next_char == "\r\n") {
456470
// End C++ style comments on newline.
457471
if ($in_comment === '/' || $in_comment === '#') {
@@ -577,8 +591,10 @@ function _coder_review_read_and_parse_file(array &$coder_args) {
577591
}
578592

579593
elseif ($in_heredoc) {
580-
// @note: backdrop_substr does not properly handle multi-byte characters in this string.
581-
// @todo: check other places where the backdrop_ string functions fail.
594+
// @note: backdrop_substr does not properly handle multi-byte
595+
// characters in this string.
596+
// @todo: check other places where the backdrop_ string functions
597+
// fail.
582598
if ($beginning_of_line && $char == $in_heredoc[0] && substr($content, $pos, $in_heredoc_length) == $in_heredoc) {
583599
$this_all_lines .= _substr($content, $pos + 1, $in_heredoc_length - 1);
584600
$in_heredoc = 0;
@@ -923,7 +939,14 @@ function _coder_review_severity_name(array $coder_args, array $review, array $ru
923939
* @see _coder_review_read_and_parse_file()
924940
*/
925941
function do_coder_review(array $coder_args, array $review) {
926-
$results = array('#stats' => array('minor' => 0, 'normal' => 0, 'critical' => 0, 'ignored' => 0));
942+
$results = array(
943+
'#stats' => array(
944+
'minor' => 0,
945+
'normal' => 0,
946+
'critical' => 0,
947+
'ignored' => 0,
948+
),
949+
);
927950
$allowed_extensions = array_merge(
928951
$coder_args['#php_extensions'],
929952
$coder_args['#include_extensions'],
@@ -1024,9 +1047,13 @@ function do_coder_review(array $coder_args, array $review) {
10241047
* regular expression string.
10251048
*
10261049
* @param array $coder_args
1027-
* A Coder settings array, passed by reference. See do_coder_review() for format.
1050+
* A Coder settings array, passed by reference. See do_coder_review() for
1051+
* format.
1052+
*
10281053
* @param array $review
1029-
* Review array the current rule belongs to, used by _coder_review_severity_name().
1054+
* Review array the current rule belongs to, used by
1055+
* _coder_review_severity_name().
1056+
*
10301057
* @param array $rule
10311058
* Rule array being checked.
10321059
* @param array $lines
@@ -1054,7 +1081,7 @@ function do_coder_review_regex(array &$coder_args, array $review, array $rule, a
10541081
if (preg_match($regex, $line, $matches)) {
10551082
// Some rules apply only within certain functions and classes.
10561083
list($class_current, $function_current) = isset($coder_args['#stack'][$lineno]) ? $coder_args['#stack'][$lineno] : array('', '');
1057-
if ( ($function_regex && (!$function_current || !preg_match($function_regex, $function_current)))
1084+
if (($function_regex && (!$function_current || !preg_match($function_regex, $function_current)))
10581085
|| ($function_not_regex && $function_current && preg_match($function_not_regex, $function_current))
10591086
|| ($class_regex && (!$class_current || !preg_match($class_regex, $class_current[0])))
10601087
|| ($class_not_regex && $class_current && preg_match($class_not_regex, $class_current[0]))
@@ -1153,13 +1180,19 @@ function _coder_review_ignore(array $rule, $lineno, array $ignores) {
11531180
* This type of do_coder_review_* searches for the occurance of a string.
11541181
*
11551182
* @param array $coder_args
1156-
* A Coder settings array, passed by reference. See do_coder_review() for format.
1183+
* A Coder settings array, passed by reference. See do_coder_review() for
1184+
* format.
1185+
*
11571186
* @param array $review
1158-
* Review array the current rule belongs to, used by _coder_review_severity_name().
1187+
* Review array the current rule belongs to, used by
1188+
* _coder_review_severity_name().
1189+
*
11591190
* @param array $rule
11601191
* Rule array being checked.
1192+
*
11611193
* @param array $lines
11621194
* Pertinent source file lines according to rule's '#source' value.
1195+
*
11631196
* @param array $results
11641197
* Results array variable to save errors to, passed by reference.
11651198
*
@@ -1187,13 +1220,19 @@ function do_coder_review_grep(array &$coder_args, array $review, array $rule, ar
11871220
* string.
11881221
*
11891222
* @param array $coder_args
1190-
* A Coder settings array, passed by reference. See do_coder_review() for format.
1223+
* A Coder settings array, passed by reference. See do_coder_review() for
1224+
* format.
1225+
*
11911226
* @param array $review
1192-
* Review array the current rule belongs to, used by _coder_review_severity_name().
1227+
* Review array the current rule belongs to, used by
1228+
* _coder_review_severity_name().
1229+
*
11931230
* @param array $rule
11941231
* Rule array being checked.
1232+
*
11951233
* @param array $lines
11961234
* Pertinent source file lines according to rule's '#source' value.
1235+
*
11971236
* @param array $results
11981237
* Results array variable to save errors to, passed by reference.
11991238
*
@@ -1221,13 +1260,19 @@ function do_coder_review_grep_invert(array &$coder_args, array $review, array $r
12211260
* perform a review.
12221261
*
12231262
* @param array $coder_args
1224-
* A Coder settings array, passed by reference. See do_coder_review() for format.
1263+
* A Coder settings array, passed by reference. See do_coder_review() for
1264+
* format.
1265+
*
12251266
* @param array $review
1226-
* Review array the current rule belongs to, used by _coder_review_severity_name().
1267+
* Review array the current rule belongs to, used by
1268+
* _coder_review_severity_name().
1269+
*
12271270
* @param array $rule
12281271
* Rule array being checked.
1272+
*
12291273
* @param array $lines
12301274
* Pertinent source file lines according to rule's '#source' value.
1275+
*
12311276
* @param array $results
12321277
* Results array variable to save errors to, passed by reference.
12331278
*
@@ -1238,7 +1283,12 @@ function do_coder_review_callback(array &$coder_args, array $review, array $rule
12381283
$function = $rule['#value'];
12391284
if ($function) {
12401285
if (function_exists($function)) {
1241-
call_user_func_array($function, array(&$coder_args, $review, $rule, $lines, &$results));
1286+
call_user_func_array($function, array(
1287+
&$coder_args,
1288+
$review, $rule,
1289+
$lines,
1290+
&$results,
1291+
));
12421292
}
12431293
else {
12441294
static $bad;
@@ -1260,7 +1310,7 @@ function do_coder_review_callback(array &$coder_args, array $review, array $rule
12601310
* @param array $rule
12611311
* A Rule array to process.
12621312
*
1263-
* @return
1313+
* @return int
12641314
* TRUE if needle is in haystack; otherwise, FALSE.
12651315
*/
12661316
function _coder_review_search_string($line, $rule) {
@@ -1285,11 +1335,11 @@ function _coder_review_search_string($line, $rule) {
12851335
* The name is a misnomer, but is a largely correct characterization
12861336
* for most of Coder's settings as the variables usually do not exist.
12871337
*
1288-
* @param string $args
1338+
* @param string $arg
12891339
* (optional) A string settings argument, can be 'settings', 'active', 'core',
12901340
* 'all' and 'default'. Defaults to 'default'.
12911341
*
1292-
* @return
1342+
* @return array $settings
12931343
* Associative array of settings in the form of setting name => setting value.
12941344
*/
12951345
function _coder_review_get_default_settings($arg = 'default') {
@@ -1389,7 +1439,8 @@ function _coder_review_is_backdrop_core($system) {
13891439
* @todo Is this an HTML string? Is it sanitized? Needs better explanation.
13901440
*/
13911441
function _coder_review_warning(array $rule) {
1392-
/* @todo: add version check so we handle tranlations right for older rules definitions.
1442+
/* @todo: add version check so we handle tranlations right for older rules
1443+
* definitions.
13931444
* ... or should we just ignore them?
13941445
* This will require passing the review to this function.
13951446
*/

0 commit comments

Comments
 (0)