Skip to content

Commit

Permalink
CTP-3171 Fix sonarqube code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
aydevworks authored and aspark21 committed May 3, 2024
1 parent 603a621 commit b672fb4
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 15 deletions.
4 changes: 3 additions & 1 deletion apiclients/easikit/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function __construct() {
* @throws \moodle_exception
*/
public function build_request(string $action, \stdClass $data = null, submission $submission = null) {
$request = null;
switch ($action) {
case manager::PUSH_GRADE:
$request = new pushgrade($data);
Expand All @@ -76,6 +75,9 @@ public function build_request(string $action, \stdClass $data = null, submission
case manager::GET_MARKING_SCHEMES:
$request = new getmarkingschemes();
break;
default:
$request = null;
break;
}

return $request;
Expand Down
2 changes: 1 addition & 1 deletion apiclients/stutalkdirect/classes/requests/pushgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct(\stdClass $data) {
self::transform_data($data);

// Set the fields mapping, params fields and data.
parent::__construct(self::FIELDS_MAPPING, $endpointurl, self::ENDPOINT_PARAMS, $data, self::METHOD);
parent::__construct(self::FIELDS_MAPPING, $endpointurl, self::ENDPOINT_PARAMS, $data, self::METHOD);

// Set the request body.
$this->set_body($data);
Expand Down
5 changes: 4 additions & 1 deletion apiclients/stutalkdirect/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function __construct() {
* @throws \moodle_exception
*/
public function build_request(string $action, \stdClass $data = null, submission $submission = null) {
$request = null;
switch ($action) {
case manager::GET_COMPONENT_GRADE:
$request = new getcomponentgrade($data);
Expand All @@ -72,6 +71,10 @@ public function build_request(string $action, \stdClass $data = null, submission
break;
case manager::GET_MARKING_SCHEMES:
$request = new getmarkingschemes();
break;
default:
$request = null;
break;
}

return $request;
Expand Down
4 changes: 2 additions & 2 deletions classes/assessment/assessmentfactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public static function get_assessment(int|\stdClass $coursemodule) {
return new assign($coursemodule);
case 'turnitintooltwo':
return new turnitintooltwo($coursemodule);
default:
throw new \moodle_exception('Mod name '. $coursemodule->modname .' not found.');
}

throw new \moodle_exception('Mod name '. $coursemodule->modname .' not found.');
}
}
2 changes: 1 addition & 1 deletion classes/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public function save_component_grades(array $componentgrades) {
$recordsinsert[] = $record;
}
}
if (count($recordsinsert) > 0) {
if (!empty($recordsinsert)) {
$DB->insert_records(self::TABLE_COMPONENT_GRADE, $recordsinsert);
}
}
Expand Down
4 changes: 2 additions & 2 deletions classes/output/pushrecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ protected function set_transfer_records(int $assessmentmappingid, int $studentid
}
$this->lastgradepushresult = $result;
$this->lastgradepusherrortype = $errortype;
$this->lastgradepushtimestring = date('Y-m-d H:i:s', $log->timecreated);;
$this->lastgradepushtimestring = date('Y-m-d H:i:s', $log->timecreated);
$this->lastgradepushtime = $log->timecreated;
} else if ($log->type == manager::PUSH_SUBMISSION_LOG) {
$this->lastsublogpushresult = $result;
$this->lastsublogpusherrortype = $errortype;
$this->lastsublogpushtimestring = date('Y-m-d H:i:s', $log->timecreated);;
$this->lastsublogpushtimestring = date('Y-m-d H:i:s', $log->timecreated);
$this->lastsublogpushtime = $log->timecreated;
}
}
Expand Down
1 change: 0 additions & 1 deletion classes/plugininfo/sitsapiclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public function get_settings_section_name() {
*/
public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
$ADMIN = $adminroot;
$plugininfo = $this;

if (!$this->is_installed_and_upgraded()) {
return;
Expand Down
1 change: 1 addition & 0 deletions classes/submission/quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_sitsgradepush\submission;

use mod_quiz\quiz_attempt;

/**
Expand Down
4 changes: 2 additions & 2 deletions classes/submission/submissionfactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public static function get_submission(int $coursemoduleid, int $userid) {
return new assign($coursemodule, $userid);
case 'turnitintooltwo':
return new turnitintooltwo($coursemodule, $userid);
default:
throw new \moodle_exception('Mod name '. $coursemodule->modulename .' not found.');
}

throw new \moodle_exception('Mod name '. $coursemodule->modulename .' not found.');
}
}
10 changes: 7 additions & 3 deletions classes/task/pushtask.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class pushtask extends scheduled_task {

/** @var int default max concurrent tasks allowed */
const MAX_CONCURRENT_TASKS = 10;

/** @var string date time format */
const DATE_TIME_FORMAT = 'Y-m-d H:i:s';

/**
* Get a descriptive name for this task.
*
Expand All @@ -58,7 +62,7 @@ public function execute() {

if ($runningtasks >= $concurrenttasksallowed) {
// Too many tasks running, exit.
mtrace(date('Y-m-d H:i:s', time()) . ' : ' .
mtrace(date(self::DATE_TIME_FORMAT, time()) . ' : ' .
'Too many tasks running (' . $runningtasks . '/' . $concurrenttasksallowed . ')');
return;
}
Expand All @@ -68,7 +72,7 @@ public function execute() {

if (empty($tasks)) {
// No tasks to run, exit.
mtrace(date('Y-m-d H:i:s', time()) . ' : ' .
mtrace(date(self::DATE_TIME_FORMAT, time()) . ' : ' .
'No tasks to run.');
return;
}
Expand All @@ -79,7 +83,7 @@ public function execute() {
// Run the tasks.
foreach ($tasks as $task) {
// Add adhoc task.
mtrace(date('Y-m-d H:i:s', time()) . ' : ' .
mtrace(date(self::DATE_TIME_FORMAT, time()) . ' : ' .
'Spawning adhoc task [#' . $task->id . '] (' . $count . '/' . $concurrenttasksallowed . ')');

$adhoctask = new adhoctask();
Expand Down
1 change: 0 additions & 1 deletion classes/taskmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ public static function send_email_notification(int $taskid): void {
$succeededcount = 0;
$failedcount = 0;
foreach ($transferrecords as $transferrecord) {
$transfer = new \stdClass();
$response = json_decode($transferrecord->response);
if ($response->code == "0") {
$succeededcount++;
Expand Down

0 comments on commit b672fb4

Please sign in to comment.