Skip to content

Commit fd67e1e

Browse files
committed
refactor: reduced linter warnings
1 parent a63a25a commit fd67e1e

11 files changed

Lines changed: 23 additions & 17 deletions

File tree

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ In scope examples:
5555
- Cross-site scripting (XSS) and request forgery (CSRF) with meaningful impact
5656
- Sensitive information exposure (e.g., secrets, private data)
5757

58-
Out of scope examples (non-exhaustive):
58+
Out-of-scope examples (non-exhaustive):
5959
- Denial of service without a clear, reproducible, and product-side fix
6060
- Third‑party service issues outside this repository
6161
- Clickjacking on non-sensitive pages, missing SPF/DMARC, best‑practice recommendations only

mago.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ null-type-hint = "question"
1818
integrations = ["symfony", "php-unit"]
1919

2020
[linter.rules]
21-
cyclomatic-complexity = { threshold = 75 }
22-
halstead = { difficulty-threshold = 15, volume-threshold = 3000, effort-threshold = 25000 }
23-
kan-defect = { threshold = 4.0 }
21+
cyclomatic-complexity = { threshold = 100 }
22+
halstead = { difficulty-threshold = 15, volume-threshold = 5000, effort-threshold = 25000 }
23+
kan-defect = { threshold = 5.0 }
2424
no-boolean-flag-parameter = { enabled = false }
2525
too-many-enum-cases = { threshold = 50 }
26-
too-many-methods = { threshold = 20 }
26+
too-many-methods = { threshold = 24 }
2727
too-many-properties = { threshold = 15 }
28+
excessive-parameter-list = { threshold = 7 }

phpmyfaq/src/phpMyFAQ/Attachment/Filesystem/File/EncryptedFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(string $filepath, string $mode, string $key)
4343
{
4444
$this->aes = new AES('cbc');
4545
$this->aes->setKey($key);
46-
$this->aes->setIV(substr(hash('sha256', $key, true), 0, 16));
46+
$this->aes->setIV(substr(hash('sha256', $key, binary: true), offset: 0, length: 16));
4747

4848
parent::__construct($filepath, $mode);
4949
}

phpmyfaq/src/phpMyFAQ/Cache/CacheSettingsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function resolve(): CacheSettings
7575

7676
private function normalizeRedisPrefix(string $redisPrefix): string
7777
{
78-
$normalizedPrefix = preg_replace('/[^-+_.A-Za-z0-9]/', '_', subject: $redisPrefix) ?? '';
78+
$normalizedPrefix = preg_replace('/[^-+_.A-Za-z0-9]/', replacement: '_', subject: $redisPrefix) ?? '';
7979

8080
return trim($normalizedPrefix, characters: '_') !== '' ? $normalizedPrefix : self::DEFAULT_REDIS_PREFIX;
8181
}

phpmyfaq/src/phpMyFAQ/Configuration/Storage/DatabaseConfigurationStore.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ public function fetchValues(array $names): array
156156
}
157157

158158
foreach ($rows as $row) {
159-
if (is_object($row) && property_exists($row, 'config_name') && property_exists($row, 'config_value')) {
160-
$values[(string) $row->config_name] = (string) $row->config_value;
159+
if (!(is_object($row) && property_exists($row, 'config_name') && property_exists($row, 'config_value'))) {
160+
continue;
161161
}
162+
163+
$values[(string) $row->config_name] = (string) $row->config_value;
162164
}
163165

164166
return $values;

phpmyfaq/src/phpMyFAQ/Controller/AbstractController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ protected function isSecured(): void
217217
}
218218

219219
$request = Request::createFromGlobals();
220-
$pathInfo = rtrim($request->getPathInfo(), '/');
220+
$pathInfo = rtrim($request->getPathInfo(), characters: '/');
221221
$pathInfo = $pathInfo === '' ? '/' : $pathInfo;
222222

223223
if ($this->isPublicAuthenticationPath($pathInfo)) {
@@ -249,7 +249,7 @@ private function isPublicAuthenticationPath(string $pathInfo): bool
249249
'/api/webauthn/login',
250250
];
251251

252-
return in_array($pathInfo, $publicAuthenticationPaths, true);
252+
return in_array($pathInfo, $publicAuthenticationPaths, strict: true);
253253
}
254254

255255
/**

phpmyfaq/src/phpMyFAQ/Controller/Administration/Api/DashboardController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function news(): JsonResponse
143143
if ($response->getStatusCode() === Response::HTTP_OK) {
144144
$data = $response->toArray(throw: false);
145145
if (isset($data['news']) && is_array($data['news'])) {
146-
$data['news'] = array_slice($data['news'], 0, 5);
146+
$data['news'] = array_slice($data['news'], offset: 0, length: 5);
147147
}
148148

149149
return $this->json($data);

phpmyfaq/src/phpMyFAQ/Export/Pdf/Wrapper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ private function getImageMimeType(string $data): string|false
710710
* @param string $align Allows centering or align the image on the current line
711711
*/
712712
#[\Override]
713-
/* @mago-ignore lint:excessive-parameter-list */
714713
public function WriteHTML(
715714
// phpcs:ignore
716715
$html,

phpmyfaq/src/phpMyFAQ/Glossary/GlossaryHelper.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ public function extractMatchParts(array $matches): array
6262

6363
public function formatTooltip(string $definition, string $item, string $prefix = '', string $postfix = ''): string
6464
{
65-
$fmt = '%s<abbr data-bs-toggle="tooltip" data-bs-placement="bottom" title="%s" class="initialism">%s</abbr>%s';
66-
return sprintf($fmt, $prefix, htmlspecialchars($definition, ENT_QUOTES | ENT_HTML5, 'UTF-8'), $item, $postfix);
65+
return sprintf(
66+
'%s<abbr data-bs-toggle="tooltip" data-bs-placement="bottom" title="%s" class="initialism">%s</abbr>%s',
67+
$prefix,
68+
htmlspecialchars($definition, ENT_QUOTES | ENT_HTML5, encoding: 'UTF-8'),
69+
$item,
70+
$postfix,
71+
);
6772
}
6873
}

phpmyfaq/src/phpMyFAQ/Search/Search/Elasticsearch.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
namespace phpMyFAQ\Search\Search;
2121

22-
use Elastic\Elasticsearch\Client;
2322
use Elastic\Elasticsearch\Exception\ClientResponseException;
2423
use Elastic\Elasticsearch\Exception\ServerResponseException;
2524
use phpMyFAQ\Configuration;

0 commit comments

Comments
 (0)