fix: SA: Fix "incorrect case" rule.

SA stands for Static Analysis.
This commit is contained in:
Pol Dellaiera 2021-11-16 10:29:41 +01:00
parent 196cddab09
commit a7b96f1756
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA
4 changed files with 42 additions and 58 deletions

View File

@ -170,11 +170,6 @@ parameters:
count: 1 count: 1
path: src/Bundle/ChillCalendarBundle/Entity/Calendar.php path: src/Bundle/ChillCalendarBundle/Entity/Calendar.php
-
message: "#^Class RuntimeException referenced with incorrect case\\: RunTimeException\\.$#"
count: 5
path: src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php
- -
message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
count: 1 count: 1
@ -685,11 +680,6 @@ parameters:
count: 1 count: 1
path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php
-
message: "#^Call to method Chill\\\\MainBundle\\\\Export\\\\Formatter\\\\SpreadSheetFormatter\\:\\:generateContent\\(\\) with incorrect case\\: generatecontent$#"
count: 1
path: src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php
- -
message: "#^Foreach overwrites \\$key with its key variable\\.$#" message: "#^Foreach overwrites \\$key with its key variable\\.$#"
count: 1 count: 1
@ -1020,11 +1010,6 @@ parameters:
count: 1 count: 1
path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
-
message: "#^Call to method Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\:\\:getOpenParticipations\\(\\) with incorrect case\\: getOPenParticipations$#"
count: 2
path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
- -
message: "#^Implicit array creation is not allowed \\- variable \\$centers might not exist\\.$#" message: "#^Implicit array creation is not allowed \\- variable \\$centers might not exist\\.$#"
count: 1 count: 1

View File

@ -151,8 +151,7 @@ class CreateFieldsOnGroupCommand extends Command
return $customFieldsGroup; return $customFieldsGroup;
} }
} }
throw new \RunTimeException('The id does not match an existing ' throw new \RuntimeException('The id does not match an existing CustomFieldsGroup');
. 'CustomFieldsGroup');
} }
); );
$customFieldsGroup = $helper->ask($input, $output, $question); $customFieldsGroup = $helper->ask($input, $output, $question);
@ -205,13 +204,13 @@ class CreateFieldsOnGroupCommand extends Command
$parser = new Parser(); $parser = new Parser();
if (!file_exists($path)) { if (!file_exists($path)) {
throw new \RunTimeException("file does not exist"); throw new \RuntimeException("file does not exist");
} }
try { try {
$values = $parser->parse(file_get_contents($path)); $values = $parser->parse(file_get_contents($path));
} catch (ParseException $ex) { } catch (ParseException $ex) {
throw new \RunTimeException("The yaml file is not valid", 0, $ex); throw new \RuntimeException("The yaml file is not valid", 0, $ex);
} }
return $values; return $values;
@ -228,7 +227,7 @@ class CreateFieldsOnGroupCommand extends Command
//check the cf type exists //check the cf type exists
$cfType = $this->customFieldProvider->getCustomFieldByType($field['type']); $cfType = $this->customFieldProvider->getCustomFieldByType($field['type']);
if ($cfType === NULL) { if ($cfType === NULL) {
throw new \RunTimeException('the type '.$field['type'].' ' throw new \RuntimeException('the type '.$field['type'].' '
. 'does not exists'); . 'does not exists');
} }
@ -255,7 +254,7 @@ class CreateFieldsOnGroupCommand extends Command
.$cf->getType()."\t with slug ".$cf->getSlug(). .$cf->getType()."\t with slug ".$cf->getSlug().
"\t and names : ".implode($names, ', ')."</info>"); "\t and names : ".implode($names, ', ')."</info>");
} else { } else {
throw new \RunTimeException("Error in field ".$slug); throw new \RuntimeException("Error in field ".$slug);
} }
} }

View File

@ -229,7 +229,7 @@ class SpreadSheetFormatter implements FormatterInterface
$this->getContentType($this->formatterData['format'])); $this->getContentType($this->formatterData['format']));
$this->tempfile = \tempnam(\sys_get_temp_dir(), ''); $this->tempfile = \tempnam(\sys_get_temp_dir(), '');
$this->generatecontent(); $this->generateContent();
$f = \fopen($this->tempfile, 'r'); $f = \fopen($this->tempfile, 'r');
$response->setContent(\stream_get_contents($f)); $response->setContent(\stream_get_contents($f));

View File

@ -544,7 +544,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
*/ */
public function actualParticipationsByHousehold(): array public function actualParticipationsByHousehold(): array
{ {
$participations = $this->getOPenParticipations()->toArray(); $participations = $this->getOpenParticipations()->toArray();
$households = []; $households = [];
foreach ($participations as $p) { foreach ($participations as $p) {
@ -1074,7 +1074,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
*/ */
public function getAvailablePersonLocation(): Collection public function getAvailablePersonLocation(): Collection
{ {
return $this->getOPenParticipations() return $this->getOpenParticipations()
->filter(function(AccompanyingPeriodParticipation $p) { ->filter(function(AccompanyingPeriodParticipation $p) {
return $p->getPerson()->hasCurrentHouseholdAddress(); return $p->getPerson()->hasCurrentHouseholdAddress();
}) })