diff --git a/webapp/src/Controller/Jury/ExecutableController.php b/webapp/src/Controller/Jury/ExecutableController.php index ca81cbd36b..8da23368b1 100644 --- a/webapp/src/Controller/Jury/ExecutableController.php +++ b/webapp/src/Controller/Jury/ExecutableController.php @@ -68,7 +68,6 @@ public function indexAction(Request $request): Response ]; $propertyAccessor = PropertyAccess::createPropertyAccessor(); - $executables_table = []; $configScripts = []; foreach (['compare', 'run', 'full_debug'] as $config_script) { try { diff --git a/webapp/src/Controller/Jury/JudgehostController.php b/webapp/src/Controller/Jury/JudgehostController.php index fe2dcd07d1..fb0024bedd 100644 --- a/webapp/src/Controller/Jury/JudgehostController.php +++ b/webapp/src/Controller/Jury/JudgehostController.php @@ -323,7 +323,7 @@ public function autohideInactive(): RedirectResponse $time_crit = $this->config->get('judgehost_critical'); $critical_threshold = $now - $time_crit; - $ret = $this->em->createQuery( + $this->em->createQuery( 'UPDATE App\Entity\Judgehost j set j.enabled = false, j.hidden = true WHERE j.polltime IS NULL OR j.polltime < :threshold') ->setParameter('threshold', $critical_threshold) ->execute(); diff --git a/webapp/src/Controller/Jury/TeamAffiliationController.php b/webapp/src/Controller/Jury/TeamAffiliationController.php index 8c60ffd2e0..e74f986b85 100644 --- a/webapp/src/Controller/Jury/TeamAffiliationController.php +++ b/webapp/src/Controller/Jury/TeamAffiliationController.php @@ -70,8 +70,6 @@ public function indexAction( array_slice($table_fields, 1, null, true); } - $webDir = realpath(sprintf('%s/public', $projectDir)); - $propertyAccessor = PropertyAccess::createPropertyAccessor(); $team_affiliations_table = []; foreach ($teamAffiliations as $teamAffiliationData) { diff --git a/webapp/src/DataFixtures/DefaultData/ExecutableFixture.php b/webapp/src/DataFixtures/DefaultData/ExecutableFixture.php index 9e2a8a8dd5..87ad229594 100644 --- a/webapp/src/DataFixtures/DefaultData/ExecutableFixture.php +++ b/webapp/src/DataFixtures/DefaultData/ExecutableFixture.php @@ -32,7 +32,7 @@ public function load(ObjectManager $manager): void foreach ($data as $item) { // Note: we only create the executable if it doesn't exist yet. // If it does, we will not update the data - if (!($executable = $manager->getRepository(Executable::class)->find($item[0]))) { + if (!$manager->getRepository(Executable::class)->find($item[0])) { $file = sprintf('%s/files/defaultdata/%s.zip', $this->sqlDir, $item[0] ); diff --git a/webapp/src/DataFixtures/DefaultData/UserFixture.php b/webapp/src/DataFixtures/DefaultData/UserFixture.php index 0a0f667740..f24bb1f07b 100644 --- a/webapp/src/DataFixtures/DefaultData/UserFixture.php +++ b/webapp/src/DataFixtures/DefaultData/UserFixture.php @@ -23,7 +23,7 @@ public function __construct( public function load(ObjectManager $manager): void { - if (!($adminUser = $manager->getRepository(User::class)->findOneBy(['username' => 'admin']))) { + if (!$manager->getRepository(User::class)->findOneBy(['username' => 'admin'])) { $adminPasswordFile = sprintf( '%s/%s', $this->dj->getDomjudgeEtcDir(), @@ -53,7 +53,7 @@ public function load(ObjectManager $manager): void $this->logger->info('User admin already exists, not created'); } - if (!($judgehostUser = $manager->getRepository(User::class)->findOneBy(['username' => 'judgehost']))) { + if (!$manager->getRepository(User::class)->findOneBy(['username' => 'judgehost'])) { $judgehostUser = new User(); $judgehostUser ->setExternalid('judgehost') diff --git a/webapp/src/DataFixtures/Test/RejudgingFirstToSolveFixture.php b/webapp/src/DataFixtures/Test/RejudgingFirstToSolveFixture.php index 32132653e8..b6022682ad 100644 --- a/webapp/src/DataFixtures/Test/RejudgingFirstToSolveFixture.php +++ b/webapp/src/DataFixtures/Test/RejudgingFirstToSolveFixture.php @@ -32,7 +32,7 @@ public function load(ObjectManager $manager): void $language = $manager->getRepository(Language::class)->find('cpp'); $problem = $contest->getProblems()->filter(fn(ContestProblem $problem) => $problem->getShortname() === 'A')->first(); - foreach ($submissionData as $index => $submissionItem) { + foreach ($submissionData as $submissionItem) { $submission = (new Submission()) ->setContest($contest) ->setTeam($submissionItem[0]) diff --git a/webapp/src/DataFixtures/Test/RejudgingStatesFixture.php b/webapp/src/DataFixtures/Test/RejudgingStatesFixture.php index debcc7aa9a..205d76fdd3 100644 --- a/webapp/src/DataFixtures/Test/RejudgingStatesFixture.php +++ b/webapp/src/DataFixtures/Test/RejudgingStatesFixture.php @@ -29,7 +29,7 @@ public function load(ObjectManager $manager): void { /** @var User $user */ $user = $manager->getRepository(User::class)->findOneBy(['username' => 'admin']); - foreach (static::rejudgingStages() as $index => $rejudgingStage) { + foreach (static::rejudgingStages() as $rejudgingStage) { $rejudging = (new Rejudging()) ->setStarttime(Utils::toEpochFloat('2019-01-01 07:07:07')) ->setStartUser($user) diff --git a/webapp/src/Serializer/TeamAffiliationVisitor.php b/webapp/src/Serializer/TeamAffiliationVisitor.php index b55b078427..061ea6a97e 100644 --- a/webapp/src/Serializer/TeamAffiliationVisitor.php +++ b/webapp/src/Serializer/TeamAffiliationVisitor.php @@ -55,9 +55,6 @@ public function onPostSerialize(ObjectEvent $event): void ]; foreach ($countryFlagSizes as $size => $viewBoxSize) { - $alpha3code = strtoupper($affiliation->getCountry()); - $alpha2code = strtolower(Countries::getAlpha2Code($alpha3code)); - $flagFile = sprintf('%s/public/flags/%s/%s.svg', $this->dj->getDomjudgeWebappDir(), $size, $alpha2code); $route = $this->dj->apiRelativeUrl( 'v4_app_api_generalinfo_countryflag', ['countryCode' => $affiliation->getCountry(), 'size' => $size] ); diff --git a/webapp/src/Service/AwardService.php b/webapp/src/Service/AwardService.php index 647bbf5d96..1ffa8eac34 100644 --- a/webapp/src/Service/AwardService.php +++ b/webapp/src/Service/AwardService.php @@ -104,7 +104,7 @@ protected function loadAwards(Contest $contest, Scoreboard $scoreboard): void foreach ($medal_winners as $metal => $team_ids) { $type = $metal . '-medal'; $result = [ - 'id' => $metal . '-medal', + 'id' => $type, 'citation' => ucfirst($metal) . ' medal winner', 'team_ids' => $team_ids ]; diff --git a/webapp/src/Service/ImportExportService.php b/webapp/src/Service/ImportExportService.php index c41961f79c..b323070015 100644 --- a/webapp/src/Service/ImportExportService.php +++ b/webapp/src/Service/ImportExportService.php @@ -573,8 +573,8 @@ public function importJson(string $type, UploadedFile $file, ?string &$message = // Check if we can parse it as YAML try { $data = Yaml::parse($content, Yaml::PARSE_DATETIME); - } catch (ParseException $e) { - $message = "File contents is not valid JSON or YAML: " . $e->getMessage(); + } catch (ParseException $parseException) { + $message = "File contents is not valid JSON or YAML: " . $parseException->getMessage(); return -1; } } @@ -605,9 +605,7 @@ public function importJson(string $type, UploadedFile $file, ?string &$message = protected function importGroupsTsv(array $content, ?string &$message = null): int { $groupData = []; - $l = 1; foreach ($content as $line) { - $l++; $line = Utils::parseTsvLine(trim($line)); $groupData[] = [ 'categoryid' => @$line[0], @@ -627,7 +625,7 @@ protected function importGroupsTsv(array $content, ?string &$message = null): in public function importGroupsJson(array $data, ?string &$message = null, ?array &$saved = null): int { $groupData = []; - foreach ($data as $idx => $group) { + foreach ($data as $group) { $groupData[] = [ 'categoryid' => @$group['id'], 'icpc_id' => @$group['icpc_id'], @@ -713,7 +711,7 @@ protected function importGroupData(array $groupData, ?array &$saved = null): int public function importOrganizationsJson(array $data, ?string &$message = null, ?array &$saved = null): int { $organizationData = []; - foreach ($data as $idx => $organization) { + foreach ($data as $organization) { $organizationData[] = [ 'externalid' => @$organization['id'], 'shortname' => @$organization['short_name'] ?? @$organization['short-name'] ?? @$organization['shortname'] ?? @$organization['name'], @@ -790,9 +788,7 @@ protected function importOrganizationData(array $organizationData, ?array &$save protected function importTeamsTsv(array $content, ?string &$message = null): int { $teamData = []; - $l = 1; foreach ($content as $line) { - $l++; $line = Utils::parseTsvLine(trim($line)); // teams.tsv contains data pertaining both to affiliations and teams. @@ -845,7 +841,7 @@ protected function importTeamsTsv(array $content, ?string &$message = null): int public function importTeamsJson(array $data, ?string &$message = null, ?array &$saved = null): int { $teamData = []; - foreach ($data as $idx => $team) { + foreach ($data as $team) { $teamData[] = [ 'team' => [ 'teamid' => $team['id'] ?? null, @@ -1015,8 +1011,6 @@ protected function importTeamData(array $teamData, ?string &$message, ?array &$s $teamItem['team']['category'] = $teamCategory; unset($teamItem['team']['categoryid']); - $metadata = $this->em->getClassMetaData(Team::class); - // Determine if we need to set the team ID manually or automatically if (empty($teamItem['team']['teamid'])) { $team = null; diff --git a/webapp/src/Service/ImportProblemService.php b/webapp/src/Service/ImportProblemService.php index 8a0d1883e5..e0e6ea3642 100644 --- a/webapp/src/Service/ImportProblemService.php +++ b/webapp/src/Service/ImportProblemService.php @@ -269,7 +269,7 @@ public function importZippedProblem( $yamlProblemProperties = []; if (isset($yamlData['name'])) { if (is_array($yamlData['name'])) { - foreach ($yamlData['name'] as $lang => $name) { + foreach ($yamlData['name'] as $name) { // TODO: select a specific instead of the first language. $yamlProblemProperties['name'] = $name; break; @@ -389,7 +389,7 @@ public function importZippedProblem( $baseFileName = sprintf('data/%s/%s', $type, $dataFile); $testInput = $zip->getFromName($baseFileName . '.in'); $testOutput = $zip->getFromName($baseFileName . '.ans'); - $imageFile = $imageType = $imageThumb = false; + $imageType = $imageThumb = false; foreach (['png', 'jpg', 'jpeg', 'gif'] as $imgExtension) { $imageFileName = $baseFileName . '.' . $imgExtension; if (($imageFile = $zip->getFromName($imageFileName)) !== false) { diff --git a/webapp/src/Service/SubmissionService.php b/webapp/src/Service/SubmissionService.php index c53cd17e45..33b10ce20e 100644 --- a/webapp/src/Service/SubmissionService.php +++ b/webapp/src/Service/SubmissionService.php @@ -569,7 +569,7 @@ public function submitSolution( // SQL transaction time below. if ($this->dj->checkrole('jury')) { $results = null; - foreach ($files as $rank => $file) { + foreach ($files as $file) { $fileResult = self::getExpectedResults(file_get_contents($file->getRealPath()), $this->config->get('results_remap')); if ($fileResult === false) {