Skip to content

Commit f709b08

Browse files
committed
Simplify @codeCoverageIgnore* tags
1 parent 1fe58f0 commit f709b08

6 files changed

Lines changed: 15 additions & 48 deletions

File tree

system/Common.php

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ function command(string $command)
144144
} elseif (preg_match('/' . $regexString . '/A', $command, $match, 0, $cursor)) {
145145
$args[] = stripcslashes($match[1]);
146146
} else {
147-
// @codeCoverageIgnoreStart
148-
throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($command, $cursor, 10)));
149-
// @codeCoverageIgnoreEnd
147+
throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($command, $cursor, 10))); // @codeCoverageIgnore
150148
}
151149

152150
$cursor += strlen($match[0]);
@@ -357,12 +355,10 @@ function db_connect($db = null, bool $getShared = true)
357355
*/
358356
function dd(...$vars)
359357
{
360-
// @codeCoverageIgnoreStart
361358
Kint::$aliases[] = 'dd';
362359
Kint::dump(...$vars);
363360

364361
exit;
365-
// @codeCoverageIgnoreEnd
366362
}
367363
}
368364

@@ -494,18 +490,13 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
494490
}
495491

496492
if ((ENVIRONMENT !== 'testing' && (is_cli() || $request->isSecure())) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'test')) {
497-
// @codeCoverageIgnoreStart
498-
return;
499-
// @codeCoverageIgnoreEnd
493+
return; // @codeCoverageIgnore
500494
}
501495

502496
// If the session status is active, we should regenerate
503497
// the session ID for safety sake.
504498
if (ENVIRONMENT !== 'testing' && session_status() === PHP_SESSION_ACTIVE) {
505-
// @codeCoverageIgnoreStart
506-
Services::session(null, true)
507-
->regenerate();
508-
// @codeCoverageIgnoreEnd
499+
Services::session(null, true)->regenerate(); // @codeCoverageIgnore
509500
}
510501

511502
$baseURL = config(App::class)->baseURL;
@@ -530,9 +521,7 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
530521
$response->sendHeaders();
531522

532523
if (ENVIRONMENT !== 'testing') {
533-
// @codeCoverageIgnoreStart
534-
exit();
535-
// @codeCoverageIgnoreEnd
524+
exit(); // @codeCoverageIgnore
536525
}
537526
}
538527
}
@@ -796,10 +785,7 @@ function log_message(string $level, string $message, array $context = [])
796785
return $logger->log($level, $message, $context);
797786
}
798787

799-
// @codeCoverageIgnoreStart
800-
return Services::logger(true)
801-
->log($level, $message, $context);
802-
// @codeCoverageIgnoreEnd
788+
return Services::logger(true)->log($level, $message, $context); // @codeCoverageIgnore
803789
}
804790
}
805791

@@ -834,9 +820,7 @@ function old(string $key, $default = null, $escape = 'html')
834820
{
835821
// Ensure the session is loaded
836822
if (session_status() === PHP_SESSION_NONE && ENVIRONMENT !== 'testing') {
837-
// @codeCoverageIgnoreStart
838-
session();
839-
// @codeCoverageIgnoreEnd
823+
session(); // @codeCoverageIgnore
840824
}
841825

842826
$request = Services::request();

system/Format/XMLFormatter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public function format($data)
3434
// SimpleXML is installed but default
3535
// but best to check, and then provide a fallback.
3636
if (! extension_loaded('simplexml')) {
37-
// never thrown in travis-ci
38-
// @codeCoverageIgnoreStart
39-
throw FormatException::forMissingExtension();
40-
// @codeCoverageIgnoreEnd
37+
throw FormatException::forMissingExtension(); // @codeCoverageIgnore
4138
}
4239

4340
$options = $config->formatterOptions['application/xml'] ?? 0;

system/Images/Handlers/ImageMagickHandler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ public function __construct($config = null)
4141
{
4242
parent::__construct($config);
4343

44-
// We should never see this, so can't test it
45-
// @codeCoverageIgnoreStart
4644
if (! (extension_loaded('imagick') || class_exists(Imagick::class))) {
47-
throw ImageException::forMissingExtension('IMAGICK');
45+
throw ImageException::forMissingExtension('IMAGICK'); // @codeCoverageIgnore
4846
}
49-
// @codeCoverageIgnoreEnd
5047
}
5148

5249
/**

system/Test/DOMParser.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ class DOMParser
3737
public function __construct()
3838
{
3939
if (! extension_loaded('DOM')) {
40-
// always there in travis-ci
41-
// @codeCoverageIgnoreStart
42-
throw new BadMethodCallException('DOM extension is required, but not currently loaded.');
43-
// @codeCoverageIgnoreEnd
40+
throw new BadMethodCallException('DOM extension is required, but not currently loaded.'); // @codeCoverageIgnore
4441
}
4542

4643
$this->dom = new DOMDocument('1.0', 'utf-8');

system/Test/FeatureTestCase.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,9 @@ public function call(string $method, string $path, ?array $params = null)
159159

160160
// Clean up any open output buffers
161161
// not relevant to unit testing
162-
// @codeCoverageIgnoreStart
163162
if (\ob_get_level() > 0 && (! isset($this->clean) || $this->clean === true)) {
164-
\ob_end_clean();
163+
\ob_end_clean(); // @codeCoverageIgnore
165164
}
166-
// @codeCoverageIgnoreEnd
167165

168166
// Simulate having a blank session
169167
$_SESSION = [];
@@ -207,15 +205,13 @@ public function call(string $method, string $path, ?array $params = null)
207205
Services::router()->setDirectory(null);
208206

209207
// Ensure the output buffer is identical so no tests are risky
210-
// @codeCoverageIgnoreStart
211208
while (\ob_get_level() > $buffer) {
212-
\ob_end_clean();
209+
\ob_end_clean(); // @codeCoverageIgnore
213210
}
214211

215212
while (\ob_get_level() < $buffer) {
216-
\ob_start();
213+
\ob_start(); // @codeCoverageIgnore
217214
}
218-
// @codeCoverageIgnoreEnd
219215

220216
return new FeatureResponse($response);
221217
}

system/Test/FeatureTestTrait.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,9 @@ public function call(string $method, string $path, ?array $params = null)
149149

150150
// Clean up any open output buffers
151151
// not relevant to unit testing
152-
// @codeCoverageIgnoreStart
153152
if (\ob_get_level() > 0 && (! isset($this->clean) || $this->clean === true)) {
154-
\ob_end_clean();
153+
\ob_end_clean(); // @codeCoverageIgnore
155154
}
156-
// @codeCoverageIgnoreEnd
157155

158156
// Simulate having a blank session
159157
$_SESSION = [];
@@ -197,15 +195,13 @@ public function call(string $method, string $path, ?array $params = null)
197195
Services::router()->setDirectory(null);
198196

199197
// Ensure the output buffer is identical so no tests are risky
200-
// @codeCoverageIgnoreStart
201198
while (\ob_get_level() > $buffer) {
202-
\ob_end_clean();
199+
\ob_end_clean(); // @codeCoverageIgnore
203200
}
204201

205202
while (\ob_get_level() < $buffer) {
206-
\ob_start();
203+
\ob_start(); // @codeCoverageIgnore
207204
}
208-
// @codeCoverageIgnoreEnd
209205

210206
return new TestResponse($response);
211207
}

0 commit comments

Comments
 (0)