Skip to content

Commit

Permalink
codecheck-comply - New line in arrays and update indent
Browse files Browse the repository at this point in the history
  • Loading branch information
EJMFarrow committed Apr 17, 2024
1 parent 0900256 commit c08ccc5
Show file tree
Hide file tree
Showing 106 changed files with 4,280 additions and 2,917 deletions.
3 changes: 2 additions & 1 deletion adminui/bulktestindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
}
$availablequestionsbycontext[$name] = [
'contextid' => $contextid,
'numquestions' => $numquestions,];
'numquestions' => $numquestions,
];
}
}

Expand Down
3 changes: 2 additions & 1 deletion adminui/compiledquestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
$selected = [
'units' => $q->get_cached('units'),
'langs' => $q->get_cached('langs'),
'forbiddenkeys' => array_keys($q->get_cached('forbiddenkeys')),];
'forbiddenkeys' => array_keys($q->get_cached('forbiddenkeys')),
];
echo '<pre>' . htmlspecialchars(json_encode($selected, JSON_PRETTY_PRINT), ENT_COMPAT) . '</pre>';


Expand Down
16 changes: 10 additions & 6 deletions adminui/replacedollars.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,16 @@ class qtype_stack_dollar_fixer {
*/
public function __construct($preview) {
$this->preview = $preview;
$this->search = [s('<ins>\[</ins>'), s('<ins>\]</ins>'),
s('<ins>\(</ins>'), s('<ins>\)</ins>'),
s('<ins>{@</ins>'), s('<ins>@}</ins>'),];
$this->replace = ['<del>$$</del><ins>\[</ins>', '<del>$$</del><ins>\]</ins>',
'<del>$</del><ins>\(</ins>', '<del>$</del><ins>\)</ins>',
'<del>@</del><ins>{@</ins>', '<del>@</del><ins>@}</ins>',];
$this->search = [
s('<ins>\[</ins>'), s('<ins>\]</ins>'),
s('<ins>\(</ins>'), s('<ins>\)</ins>'),
s('<ins>{@</ins>'), s('<ins>@}</ins>'),
];
$this->replace = [
'<del>$$</del><ins>\[</ins>', '<del>$$</del><ins>\]</ins>',
'<del>$</del><ins>\(</ins>', '<del>$</del><ins>\)</ins>',
'<del>@</del><ins>{@</ins>', '<del>@</del><ins>@}</ins>',
];
}

/**
Expand Down
22 changes: 13 additions & 9 deletions api/emulation/HtmlWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,10 @@ public static function table(html_table $table) {

// Explicitly assigned properties override those defined via $table->attributes.
$table->attributes['class'] = trim($table->attributes['class']);
$attributes = array_merge($table->attributes, ['id' => $table->id, 'width' => $table->width,
$attributes = array_merge($table->attributes, [
'id' => $table->id, 'width' => $table->width,
'summary' => $table->summary, 'cellpadding' => $table->cellpadding, 'cellspacing' => $table->cellspacing,
]);
]);
$output = self::start_tag('table', $attributes) . "\n";

$countcols = 0;
Expand Down Expand Up @@ -565,9 +566,10 @@ public static function table(html_table $table) {
$heading->attributes['class'] .= ' ' . $table->colclasses[$key];
}
$heading->attributes['class'] = trim($heading->attributes['class']);
$attributes = array_merge($heading->attributes, ['style' => $table->align[$key] . $table->size[$key] .
$attributes = array_merge($heading->attributes, [
'style' => $table->align[$key] . $table->size[$key] .
$heading->style, 'scope' => $heading->scope, 'colspan' => $heading->colspan,
]);
]);

$tagtype = 'td';
if ($heading->header === true) {
Expand Down Expand Up @@ -621,9 +623,10 @@ public static function table(html_table $table) {
$row->attributes['class'] .= ' lastrow';
}

$output .= self::start_tag('tr', ['class' => trim($row->attributes['class']),
'style' => $row->style, 'id' => $row->id,
]) . "\n";
$output .= self::start_tag('tr', [
'class' => trim($row->attributes['class']),
'style' => $row->style, 'id' => $row->id,
]) . "\n";
$keys2 = array_keys($row->cells);
$lastkey = end($keys2);

Expand Down Expand Up @@ -658,10 +661,11 @@ public static function table(html_table $table) {
$tdstyle .= isset($table->size[$key]) ? $table->size[$key] : '';
$tdstyle .= isset($table->wrap[$key]) ? $table->wrap[$key] : '';
$cell->attributes['class'] = trim($cell->attributes['class']);
$tdattributes = array_merge($cell->attributes, ['style' => $tdstyle .
$tdattributes = array_merge($cell->attributes, [
'style' => $tdstyle .
$cell->style, 'colspan' => $cell->colspan, 'rowspan' => $cell->rowspan,
'id' => $cell->id, 'abbr' => $cell->abbr, 'scope' => $cell->scope,
]);
]);
$tagtype = 'td';
if ($cell->header === true) {
$tagtype = 'th';
Expand Down
32 changes: 19 additions & 13 deletions backup/moodle2/backup_qtype_stack_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,35 @@ protected function define_question_plugin_structure() {

// Now create the necessary elements.
$stackoptions = new backup_nested_element('stackoptions', ['id'],
['stackversion', 'questionvariables', 'specificfeedback', 'specificfeedbackformat',
'questionnote', 'questionsimplify', 'assumepositive', 'assumereal',
'prtcorrect', 'prtcorrectformat', 'prtpartiallycorrect', 'prtpartiallycorrectformat',
'prtincorrect', 'prtincorrectformat', 'decimals', 'multiplicationsign', 'sqrtsign',
'complexno', 'inversetrig', 'logicsymbol', 'matrixparens', 'variantsselectionseed',]);
[
'stackversion', 'questionvariables', 'specificfeedback', 'specificfeedbackformat',
'questionnote', 'questionsimplify', 'assumepositive', 'assumereal',
'prtcorrect', 'prtcorrectformat', 'prtpartiallycorrect', 'prtpartiallycorrectformat',
'prtincorrect', 'prtincorrectformat', 'decimals', 'multiplicationsign', 'sqrtsign',
'complexno', 'inversetrig', 'logicsymbol', 'matrixparens', 'variantsselectionseed',
]);

$stackinputs = new backup_nested_element('stackinputs');
$stackinput = new backup_nested_element('stackinput', ['id'],
['name', 'type', 'tans', 'boxsize', 'strictsyntax', 'insertstars',
'syntaxhint', 'syntaxattribute', 'forbidwords', 'allowwords', 'forbidfloat', 'requirelowestterms',
'checkanswertype', 'mustverify', 'showvalidation', 'options',]);
[
'name', 'type', 'tans', 'boxsize', 'strictsyntax', 'insertstars',
'syntaxhint', 'syntaxattribute', 'forbidwords', 'allowwords', 'forbidfloat', 'requirelowestterms',
'checkanswertype', 'mustverify', 'showvalidation', 'options',
]);

$stackprts = new backup_nested_element('stackprts');
$stackprt = new backup_nested_element('stackprt', ['id'],
['name', 'value', 'autosimplify', 'feedbackstyle', 'feedbackvariables', 'firstnode']);

$stackprtnodes = new backup_nested_element('stackprtnodes');
$stackprtnode = new backup_nested_element('stackprtnode', ['id'],
['nodename', 'answertest', 'sans', 'tans', 'testoptions', 'quiet',
'truescoremode', 'truescore', 'truepenalty', 'truenextnode',
'trueanswernote', 'truefeedback', 'truefeedbackformat',
'falsescoremode', 'falsescore', 'falsepenalty', 'falsenextnode',
'falseanswernote', 'falsefeedback', 'falsefeedbackformat',]);
[
'nodename', 'answertest', 'sans', 'tans', 'testoptions', 'quiet',
'truescoremode', 'truescore', 'truepenalty', 'truenextnode',
'trueanswernote', 'truefeedback', 'truefeedbackformat',
'falsescoremode', 'falsescore', 'falsepenalty', 'falsenextnode',
'falseanswernote', 'falsefeedback', 'falsefeedbackformat',
]);

$stackqtests = new backup_nested_element('stackqtests');
$stackqtest = new backup_nested_element('stackqtest', ['id'], ['testcase', 'description', 'timemodified']);
Expand Down
6 changes: 4 additions & 2 deletions cli/answertests_docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@
// If we don't strip id tags the whole file will change everytime we add a test!
// String too long for a single regular expression match.
$lines = explode("\n", $output);
$pat = ['/\sid="stack_answertests_r\d+_c\d+"/',
'/\sid="stack_answertests_r\d+"/',];
$pat = [
'/\sid="stack_answertests_r\d+_c\d+"/',
'/\sid="stack_answertests_r\d+"/',
];
$rep = ['', ''];
foreach ($lines as $key => $line) {
$lines[$key] = preg_replace($pat, $rep, $line);
Expand Down
52 changes: 35 additions & 17 deletions cli/ast_filter_tester.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
require_once(__DIR__ . '/../stack/utils.class.php');

// Now get cli options.
list($options, $unrecognized) = cli_get_params(['help' => false,
'string' => '1+2x', 'ast' => false, 'only' => false,], ['h' => 'help']);
list($options, $unrecognized) = cli_get_params([
'help' => false,
'string' => '1+2x', 'ast' => false, 'only' => false,
], ['h' => 'help']);
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
Expand Down Expand Up @@ -80,8 +82,10 @@
} catch (SyntaxError $e) {
$parseable = false;

$ast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, ['startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),]);
$ast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, [
'startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),
]);
}
if ($ast === null) {
cli_writeln('The test-string was not parseable, even with the corrective parser.');
Expand Down Expand Up @@ -143,8 +147,10 @@ function check_filter($ast, $filter, $security, $filtername) {
if ($parseable) {
$freshast = maxima_parser_utils::parse($teststring);
} else {
$freshast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, ['startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),]);
$freshast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, [
'startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),
]);
}
check_filter($freshast, $filter, new stack_cas_security(false), $filtername);
}
Expand All @@ -157,8 +163,10 @@ function check_filter($ast, $filter, $security, $filtername) {
if ($parseable) {
$freshast = maxima_parser_utils::parse($teststring);
} else {
$freshast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, ['startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),]);
$freshast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, [
'startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),
]);
}
check_filter($freshast, $filter, new stack_cas_security(true), $filtername);
}
Expand All @@ -169,26 +177,36 @@ function check_filter($ast, $filter, $security, $filtername) {
if ($parseable) {
$freshast = maxima_parser_utils::parse($teststring);
} else {
$freshast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, ['startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),]);
$freshast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, [
'startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),
]);
}

$pipeline = stack_parsing_rule_factory::get_filter_pipeline(['995_ev_modification',
'996_call_modification', '998_security',], ['998_security' => ['security' => 's'],
'995_ev_modification' => ['flags' => false],], true);
$pipeline = stack_parsing_rule_factory::get_filter_pipeline([
'995_ev_modification',
'996_call_modification', '998_security',
], [
'998_security' => ['security' => 's'],
'995_ev_modification' => ['flags' => false],
], true);
check_filter($freshast, $pipeline, new stack_cas_security(false), 'core + security(s)');

cli_heading('= core + security(t) + strict =');
$freshast = null;
if ($parseable) {
$freshast = maxima_parser_utils::parse($teststring);
} else {
$freshast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, ['startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),]);
$freshast = maxima_corrective_parser::parse($teststring, $errors, $answernotes, [
'startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),
]);
}

$pipeline = stack_parsing_rule_factory::get_filter_pipeline(['995_ev_modification', '996_call_modification',
'998_security', '999_strict',],
$pipeline = stack_parsing_rule_factory::get_filter_pipeline([
'995_ev_modification', '996_call_modification',
'998_security', '999_strict',
],
['998_security' => ['security' => 't'], '995_ev_modification' => ['flags' => true]], true);
check_filter($freshast, $pipeline, new stack_cas_security(false), 'core + security(t) + strict');
}
24 changes: 16 additions & 8 deletions cli/ast_test_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
$okinputs = [];
foreach ($inputs as $input) {
$test = maxima_corrective_parser::parse($input,
$devnull, $devnull, ['startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),]);
$devnull, $devnull, [
'startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),
]);
if ($test !== null) {
$okinputs[] = $input;
}
Expand Down Expand Up @@ -83,12 +85,16 @@
$asts['no units'][$key] = [];
foreach ($inputs as $input) {
$ast = maxima_corrective_parser::parse($input,
$devnull, $devnull, ['startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),]);
$devnull, $devnull, [
'startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),
]);
$asts['units'][$key][$input] = $ast;
$ast = maxima_corrective_parser::parse($input,
$devnull, $devnull, ['startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),]);
$devnull, $devnull, [
'startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),
]);
$asts['no units'][$key][$input] = $ast;
$total = $total + 2;
}
Expand Down Expand Up @@ -239,8 +245,10 @@ function escp(string $string): string {
foreach ($inputs as $input) {
// What does it look if nothing changes.
$base = maxima_corrective_parser::parse($input,
$devnull, $devnull, ['startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),]);
$devnull, $devnull, [
'startRule' => 'Root',
'letToken' => stack_string('equiv_LET'),
]);
$basestring = $base->toString(['nosemicolon' => true]);

// Check with units.
Expand Down
6 changes: 4 additions & 2 deletions cli/bulkseed.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ function cat_to_course($catid) {
}
$c++;
$questiondata = question_bank::load_question_data($id->id);
$urlparams = ['qperpage' => 1000,
$urlparams = [
'qperpage' => 1000,
'category' => $questiondata->category,
'lastchanged' => $id->id,
'courseid' => cat_to_course($questiondata->category),];
'courseid' => cat_to_course($questiondata->category),
];
if (property_exists($questiondata, 'hidden') && $questiondata->hidden) {
$urlparams['showhidden'] = 1;
}
Expand Down
6 changes: 4 additions & 2 deletions cli/castextcompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
require_once(__DIR__ . '/../stack/maximaparser/utils.php');

// Now get cli options.
list($options, $unrecognized) = cli_get_params(['help' => false,
'string' => '{@foo@}', 'ast' => false,], ['h' => 'help']);
list($options, $unrecognized) = cli_get_params([
'help' => false,
'string' => '{@foo@}', 'ast' => false,
], ['h' => 'help']);
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
Expand Down
6 changes: 4 additions & 2 deletions cli/maximaidentifierupdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
// @copyright 2018 Aalto University.
// @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.

list($options, $unrecognized) = cli_get_params(['help' => false, 'version' => '5.42.0',
'data' => '-',],
list($options, $unrecognized) = cli_get_params([
'help' => false, 'version' => '5.42.0',
'data' => '-',
],
['h' => 'help']);
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
Expand Down
12 changes: 8 additions & 4 deletions cli/maximalibcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,16 @@
ksort($functionscalled);
ksort($globalvariablesused);

$raw = ['declared functions' => $functionsdeclared, 'declared values' => $variablesdeclared,
'called functions' => $functionscalled, 'global variables used in functions' => $globalvariablesused,];
$raw = [
'declared functions' => $functionsdeclared, 'declared values' => $variablesdeclared,
'called functions' => $functionscalled, 'global variables used in functions' => $globalvariablesused,
];

$data = ['security-map' => ['undeclared functions' => [], 'undeclared variables' => []],
$data = [
'security-map' => ['undeclared functions' => [], 'undeclared variables' => []],
'declared functions not used internaly' => [], 'external functions used' => [],
'functions with undeclared global variables' => [], 'raw' => $raw,];
'functions with undeclared global variables' => [], 'raw' => $raw,
];

// Check the security-map, if the identifiers are not there maybe they should be.
$security = false;
Expand Down
6 changes: 4 additions & 2 deletions doc/maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ function report($d) {
$fileslinkedto[$found[0][$i]] = true;
}
if ('/' == substr($link, -1)) {
$a[] = [$fpath, 'E', 'Link [' . $found[0][$i] .
'] calls a directory. This should have explicit <tt>index.md</tt> but does not.',];
$a[] = [
$fpath, 'E', 'Link [' . $found[0][$i] .
'] calls a directory. This should have explicit <tt>index.md</tt> but does not.',
];
}
}
}
Expand Down
Loading

0 comments on commit c08ccc5

Please sign in to comment.