Skip to content

Commit

Permalink
Remove unused variables where easily possible.
Browse files Browse the repository at this point in the history
No functional changes intended.
  • Loading branch information
meisterT committed Nov 23, 2023
1 parent 7112ab3 commit f6af277
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 27 deletions.
1 change: 0 additions & 1 deletion webapp/src/Controller/Jury/ExecutableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Controller/Jury/JudgehostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions webapp/src/Controller/Jury/TeamAffiliationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/DataFixtures/DefaultData/ExecutableFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/DataFixtures/DefaultData/UserFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/DataFixtures/Test/RejudgingStatesFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions webapp/src/Serializer/TeamAffiliationVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Service/AwardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
Expand Down
16 changes: 5 additions & 11 deletions webapp/src/Service/ImportExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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],
Expand All @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/Service/ImportProblemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Service/SubmissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f6af277

Please sign in to comment.