Skip to content

Commit 8a121cc

Browse files
committed
Make codechecker happy again
1 parent d8383d2 commit 8a121cc

17 files changed

+178
-93
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Changes
66

77
### Unreleased
88

9+
* 2025-10-15 - Make codechecker happy again
910
* 2025-10-15 - Tests: Switch Github actions workflows to reusable workflows by Moodle an Hochschulen e.V.
1011

1112
### v5.0-r1

classes/cohort_form.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
defined('MOODLE_INTERNAL') || die();
3030
global $CFG;
31-
require_once($CFG->libdir.'/formslib.php');
31+
require_once($CFG->libdir . '/formslib.php');
3232

3333
/**
3434
* Class cohort_form
@@ -37,23 +37,28 @@
3737
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3838
*/
3939
class cohort_form extends \moodleform {
40-
4140
/**
4241
* Form definition.
4342
*/
4443
protected function definition() {
4544
$mform = $this->_form;
4645
$cohorts = $this->_customdata['cohorts'];
4746

48-
$mform->addElement('html', html_writer::tag('div', get_string('cohortsintro', 'local_profilecohort').'<br />'.
47+
$mform->addElement('html', html_writer::tag(
48+
'div',
49+
get_string('cohortsintro', 'local_profilecohort') . '<br />' .
4950
get_string('invisiblecohortsnote', 'local_profilecohort'),
50-
['id' => 'intro', 'class' => 'box generalbox']));
51+
['id' => 'intro', 'class' => 'box generalbox']
52+
));
5153

5254
if (!$cohorts) {
5355
$cohorturl = new \core\url('/cohort/index.php');
5456
$link = html_writer::link($cohorturl, get_string('cohorts', 'core_cohort'));
55-
$mform->addElement('html', html_writer::tag('div', get_string('nocohorts', 'local_profilecohort', $link),
56-
['class' => 'alert alert-warning']));
57+
$mform->addElement('html', html_writer::tag(
58+
'div',
59+
get_string('nocohorts', 'local_profilecohort', $link),
60+
['class' => 'alert alert-warning']
61+
));
5762
} else {
5863
foreach ($cohorts as $cohort) {
5964
$mform->addElement('advcheckbox', "cohort[$cohort->id]", null, format_string($cohort->name));

classes/field_base.php

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ abstract class field_base {
113113
* @throws \coding_exception
114114
*/
115115
public static function make_instance($ruledata, $strictness = MUST_EXIST) {
116-
$classname = __NAMESPACE__.'\field_'.$ruledata->datatype;
116+
$classname = __NAMESPACE__ . '\field_' . $ruledata->datatype;
117117
if (!class_exists($classname)) {
118118
if ($strictness == MUST_EXIST) {
119119
throw new \coding_exception('Non-existent rule type');
@@ -342,8 +342,13 @@ public function add_form_field(MoodleQuickForm $mform, $values, $rulecount) {
342342
$group = $this->add_form_field_internal($mform, $id);
343343
$valuelabel = html_writer::span(get_string('selectvalue', 'local_profilecohort'), 'localprofile-value pe-2');
344344
$group[] = $mform->createElement('static', "valuelabel[$id]", '', $valuelabel);
345-
$group[] = $mform->createElement('select', "value[$id]", get_string('selectvalue', 'local_profilecohort'), $values,
346-
['class' => 'localprofile-value pe-2']);
345+
$group[] = $mform->createElement(
346+
'select',
347+
"value[$id]",
348+
get_string('selectvalue', 'local_profilecohort'),
349+
$values,
350+
['class' => 'localprofile-value pe-2']
351+
);
347352
$mform->setDefault("value[$id]", $this->value);
348353

349354
$prefix = '';
@@ -354,25 +359,40 @@ public function add_form_field(MoodleQuickForm $mform, $values, $rulecount) {
354359
$moveopts = range(1, $rulecount);
355360
$moveopts = array_combine($moveopts, $moveopts);
356361
$actiongroup[] = $mform->createElement('static', "movelabel[$id]", '', get_string('moveto', 'local_profilecohort'));
357-
$actiongroup[] = $mform->createElement('select', "moveto[$id]", get_string('moveto', 'local_profilecohort'),
358-
$moveopts, ['class' => 'moveto']);
362+
$actiongroup[] = $mform->createElement(
363+
'select',
364+
"moveto[$id]",
365+
get_string('moveto', 'local_profilecohort'),
366+
$moveopts,
367+
['class' => 'moveto']
368+
);
359369
$mform->setDefault("moveto[$id]", $this->formposition);
360370
$actiongroup[] = $mform->createElement('static', '', '', '<br>');
361371

362-
$actiongroup[] = $mform->createElement('advcheckbox', "andnextrule[$id]", '',
363-
get_string('andnextrule', 'local_profilecohort'), ['class' => 'andnextrule']);
372+
$actiongroup[] = $mform->createElement(
373+
'advcheckbox',
374+
"andnextrule[$id]",
375+
'',
376+
get_string('andnextrule', 'local_profilecohort'),
377+
['class' => 'andnextrule']
378+
);
364379
$mform->setDefault("andnextrule[$id]", $this->andnextrule);
365380
$actiongroup[] = $mform->createElement('static', '', '', '<br>');
366381
}
367382

368-
$actiongroup[] = $mform->createElement('advcheckbox', "delete[$id]", '', get_string('delete', 'local_profilecohort'),
369-
['class' => 'deleterule']);
383+
$actiongroup[] = $mform->createElement(
384+
'advcheckbox',
385+
"delete[$id]",
386+
'',
387+
get_string('delete', 'local_profilecohort'),
388+
['class' => 'deleterule']
389+
);
370390
$actiongroup[] = $mform->createElement('static', '', '', '</div>');
371391

372-
$prefix = '<span class="localprofile-number">'.$this->formposition.'</span>. ';
392+
$prefix = '<span class="localprofile-number">' . $this->formposition . '</span>. ';
373393
}
374394

375-
$name = $prefix.get_string('iffield', 'local_profilecohort', format_string($this->name));
395+
$name = $prefix . get_string('iffield', 'local_profilecohort', format_string($this->name));
376396
$mform->addElement('html', '<div class="localprofile-fieldwrapper">');
377397
$mform->addGroup($group, "group-$id", $name, ' ', false);
378398
if (isset($actiongroup)) {

classes/field_checkbox.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ protected function add_form_field_internal(MoodleQuickForm $mform, $id) {
5252
self::MATCH_NOTDEFINED => get_string('match_notdefined', 'local_profilecohort'),
5353
];
5454

55-
$label = $mform->createElement('static', "matchlabel[$id]", '', get_string('match_exact', 'local_profilecohort').
55+
$label = $mform->createElement('static', "matchlabel[$id]", '', get_string('match_exact', 'local_profilecohort') .
5656
'<span class="pe-2"></span>');
57-
$sel = $mform->createElement('select', "matchvalue[$id]", get_string('matchvalue', 'local_profilecohort'), $opts,
58-
['class' => 'pe-2']);
57+
$sel = $mform->createElement(
58+
'select',
59+
"matchvalue[$id]",
60+
get_string('matchvalue', 'local_profilecohort'),
61+
$opts,
62+
['class' => 'pe-2']
63+
);
5964
$mform->setDefault("matchvalue[$id]", $matchvalue);
6065
return [$label, $sel];
6166
}

classes/field_menu.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,16 @@ protected function add_form_field_internal(MoodleQuickForm $mform, $id) {
6767
$matchvalue = $this->matchtype;
6868
}
6969

70-
$label = $mform->createElement('static', "matchlabel[$id]", '', get_string('match_exact', 'local_profilecohort').
70+
$label = $mform->createElement('static', "matchlabel[$id]", '', get_string('match_exact', 'local_profilecohort') .
7171
'<span class="pe-2"></span>');
7272
$opts = [null => get_string('choosedots')] + $this->opts;
73-
$sel = $mform->createElement('select', "matchvalue[$id]", get_string('matchvalue', 'local_profilecohort'), $opts,
74-
['class' => 'pe-2']);
73+
$sel = $mform->createElement(
74+
'select',
75+
"matchvalue[$id]",
76+
get_string('matchvalue', 'local_profilecohort'),
77+
$opts,
78+
['class' => 'pe-2']
79+
);
7580
$mform->setType("matchvalue[$id]", PARAM_TEXT);
7681
$mform->setDefault("matchvalue[$id]", $matchvalue);
7782
return [$label, $sel];

classes/field_text.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,25 @@ protected function matches_internal($value) {
113113
protected function add_form_field_internal(MoodleQuickForm $mform, $id) {
114114
$matchopts = [];
115115
foreach (self::$matchtypes as $matchtype) {
116-
$strmatchtype = 'match_'.str_replace('!', '', $matchtype);
116+
$strmatchtype = 'match_' . str_replace('!', '', $matchtype);
117117
$matchopts[$matchtype] = get_string($strmatchtype, 'local_profilecohort');
118118
}
119-
$type = $mform->createElement('select', "matchtype[$id]", get_string('matchtype', 'local_profilecohort'), $matchopts,
120-
['class' => 'pe-2']);
119+
$type = $mform->createElement(
120+
'select',
121+
"matchtype[$id]",
122+
get_string('matchtype', 'local_profilecohort'),
123+
$matchopts,
124+
['class' => 'pe-2']
125+
);
121126
$mform->setType("matchtype[$id]", PARAM_TEXT);
122127
$mform->setDefault("matchtype[$id]", $this->matchtype);
123128

124-
$match = $mform->createElement('text', "matchvalue[$id]", get_string('matchvalue', 'local_profilecohort'),
125-
['class' => 'pe-2']);
129+
$match = $mform->createElement(
130+
'text',
131+
"matchvalue[$id]",
132+
get_string('matchvalue', 'local_profilecohort'),
133+
['class' => 'pe-2']
134+
);
126135
$mform->setType("matchvalue[$id]", PARAM_TEXT);
127136
$mform->setDefault("matchvalue[$id]", $this->matchvalue);
128137
$mform->disabledIf("matchvalue[$id]", "matchtype[$id]", 'eq', self::MATCH_ISDEFINED);
@@ -141,10 +150,12 @@ protected function add_form_field_internal(MoodleQuickForm $mform, $id) {
141150
*/
142151
protected function validation_internal($formdata, $id) {
143152
$errors = [];
144-
if (!in_array($formdata['matchtype'][$id], [
153+
if (
154+
!in_array($formdata['matchtype'][$id], [
145155
self::MATCH_ISDEFINED, self::MATCH_NOTDEFINED,
146156
self::MATCH_EMPTY, self::MATCH_NOTEMPTY,
147-
])) {
157+
])
158+
) {
148159
if (empty($formdata['matchvalue'][$id])) {
149160
$errors["matchvalue[$id]"] = get_string('required');
150161
}

classes/fields_form.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
defined('MOODLE_INTERNAL') || die();
3030
global $CFG;
31-
require_once($CFG->libdir.'/formslib.php');
31+
require_once($CFG->libdir . '/formslib.php');
3232

3333
/**
3434
* Class fields_form
@@ -37,7 +37,6 @@
3737
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3838
*/
3939
class fields_form extends moodleform {
40-
4140
/**
4241
* Return the current list of rules.
4342
* @return field_base[]

classes/privacy/provider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
3434
class provider implements \core_privacy\local\metadata\null_provider {
35-
3635
/**
3736
* Get the language string identifier with the component's language
3837
* file to explain why this plugin stores no data.

classes/profilecohort.php

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,16 @@ public function output_form() {
8383
*/
8484
protected function extra_tabs() {
8585
return [
86-
new \core\output\tabobject('members', new \core\url($this->get_index_url(), ['action' => 'members']),
87-
get_string('members', 'local_profilecohort')),
88-
new \core\output\tabobject('cohorts', new \core\url('/local/profilecohort/cohorts.php'),
89-
get_string('selectcohorts', 'local_profilecohort')),
86+
new \core\output\tabobject(
87+
'members',
88+
new \core\url($this->get_index_url(), ['action' => 'members']),
89+
get_string('members', 'local_profilecohort')
90+
),
91+
new \core\output\tabobject(
92+
'cohorts',
93+
new \core\url('/local/profilecohort/cohorts.php'),
94+
get_string('selectcohorts', 'local_profilecohort')
95+
),
9096
];
9197
}
9298

@@ -101,9 +107,12 @@ protected function output_members() {
101107
$tabs = $this->get_tabs();
102108
$out .= $OUTPUT->render($tabs);
103109

104-
$out .= html_writer::tag('div', get_string('membersintro', 'local_profilecohort').'<br/>'.
110+
$out .= html_writer::tag(
111+
'div',
112+
get_string('membersintro', 'local_profilecohort') . '<br/>' .
105113
get_string('invisiblecohortsnote', 'local_profilecohort'),
106-
['id' => 'intro', 'class' => 'box generalbox']);
114+
['id' => 'intro', 'class' => 'box generalbox']
115+
);
107116

108117
$namefields = \core_user\fields::get_name_fields();
109118
$namefields = preg_filter('/^/', 'u.', $namefields);
@@ -159,16 +168,23 @@ private function output_members_entry($cohortname, $cohortmembers, $lastcohortid
159168
$id = 'profilecohort-cohortlist-' . $lastcohortid;
160169

161170
// Bootstrap collapse header.
162-
$out .= html_writer::start_tag('h2', ['class' => 'accordion-header', 'id' => $id.'-heading']);
171+
$out .= html_writer::start_tag('h2', ['class' => 'accordion-header', 'id' => $id . '-heading']);
163172
$out .= html_writer::start_tag('button', ['class' => 'accordion-button collapsed', 'type' => 'button',
164-
'data-bs-toggle' => 'collapse', 'data-bs-target' => '#'.$id, 'aria-expanded' => 'false', 'aria-controls' => $id, ]);
173+
'data-bs-toggle' => 'collapse', 'data-bs-target' => '#' . $id, 'aria-expanded' => 'false',
174+
'aria-controls' => $id, ]);
165175
$out .= format_string($cohortname);
166176
if ($cohortmembers) {
167-
$out .= html_writer::tag('span', get_string('countusers', 'local_profilecohort', count($cohortmembers)),
168-
['class' => 'badge bg-primary text-light ms-2']);
177+
$out .= html_writer::tag(
178+
'span',
179+
get_string('countusers', 'local_profilecohort', count($cohortmembers)),
180+
['class' => 'badge bg-primary text-light ms-2']
181+
);
169182
} else {
170-
$out .= html_writer::tag('span', get_string('countnousers', 'local_profilecohort'),
171-
['class' => 'badge bg-secondary text-dark ms-2']);
183+
$out .= html_writer::tag(
184+
'span',
185+
get_string('countnousers', 'local_profilecohort'),
186+
['class' => 'badge bg-secondary text-dark ms-2']
187+
);
172188
}
173189
$out .= html_writer::end_tag('button');
174190
$out .= html_writer::end_tag('h2');
@@ -187,7 +203,7 @@ private function output_members_entry($cohortname, $cohortmembers, $lastcohortid
187203
$content = get_string('nousers', 'local_profilecohort');
188204
}
189205

190-
$out .= html_writer::start_div('accordion-collapse collapse', ['id' => $id, 'aria-labelledby' => $id.'-heading',
206+
$out .= html_writer::start_div('accordion-collapse collapse', ['id' => $id, 'aria-labelledby' => $id . '-heading',
191207
'data-bs-parent' => '#profilecohort-cohortlist', ]);
192208
$out .= html_writer::div($content, 'accordion-body');
193209
$out .= html_writer::end_div();
@@ -202,7 +218,7 @@ private function output_members_entry($cohortname, $cohortmembers, $lastcohortid
202218
*/
203219
public static function set_cohorts_from_profile(?\core\event\base $event = null, $userid = null) {
204220
global $USER, $DB, $CFG;
205-
require_once($CFG->dirroot.'/cohort/lib.php');
221+
require_once($CFG->dirroot . '/cohort/lib.php');
206222

207223
if ($event) {
208224
$userid = $event->userid;
@@ -216,7 +232,7 @@ public static function set_cohorts_from_profile(?\core\event\base $event = null,
216232
return; // No cohorts handled by this plugin => nothing to do.
217233
}
218234

219-
list($csql, $params) = $DB->get_in_or_equal($allowedcohortids, SQL_PARAMS_NAMED);
235+
[$csql, $params] = $DB->get_in_or_equal($allowedcohortids, SQL_PARAMS_NAMED);
220236
$params['userid'] = $userid;
221237
$select = "userid = :userid AND cohortid $csql";
222238
$oldcohortids = $DB->get_fieldset_select('cohort_members', 'cohortid', $select, $params);
@@ -301,7 +317,7 @@ protected function apply_all_rules() {
301317
*/
302318
public function update_all_cohorts_from_rules() {
303319
global $DB, $CFG;
304-
require_once($CFG->dirroot.'/cohort/lib.php');
320+
require_once($CFG->dirroot . '/cohort/lib.php');
305321

306322
// Create a recordset to load the relevant user profile fields for all users.
307323
$fieldids = [];
@@ -316,7 +332,7 @@ public function update_all_cohorts_from_rules() {
316332
$fieldsql[] = "(SELECT data FROM {user_info_data} WHERE fieldid = {$fieldid} AND userid = u.id) AS field_{$fieldid}";
317333
}
318334
if ($fieldsql) {
319-
$fieldsql = implode(', ', $fieldsql).', ';
335+
$fieldsql = implode(', ', $fieldsql) . ', ';
320336
} else {
321337
$fieldsql = '';
322338
}

0 commit comments

Comments
 (0)