Skip to content

Commit e358932

Browse files
authored
Merge pull request #6754 from paulbalandan/code-coverage-ignore
Simplify `@codeCoverageIgnore*` tags
2 parents a88ceea + ff3992d commit e358932

File tree

6 files changed

+18
-46
lines changed

6 files changed

+18
-46
lines changed

system/Common.php

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ function command(string $command)
145145
$args[] = stripcslashes($match[1]);
146146
} else {
147147
// @codeCoverageIgnoreStart
148-
throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($command, $cursor, 10)));
148+
throw new InvalidArgumentException(sprintf(
149+
'Unable to parse input near "... %s ...".',
150+
substr($command, $cursor, 10)
151+
));
149152
// @codeCoverageIgnoreEnd
150153
}
151154

@@ -357,12 +360,10 @@ function db_connect($db = null, bool $getShared = true)
357360
*/
358361
function dd(...$vars)
359362
{
360-
// @codeCoverageIgnoreStart
361363
Kint::$aliases[] = 'dd';
362364
Kint::dump(...$vars);
363365

364366
exit;
365-
// @codeCoverageIgnoreEnd
366367
}
367368
}
368369

@@ -494,18 +495,13 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
494495
}
495496

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

502501
// If the session status is active, we should regenerate
503502
// the session ID for safety sake.
504503
if (ENVIRONMENT !== 'testing' && session_status() === PHP_SESSION_ACTIVE) {
505-
// @codeCoverageIgnoreStart
506-
Services::session(null, true)
507-
->regenerate();
508-
// @codeCoverageIgnoreEnd
504+
Services::session(null, true)->regenerate(); // @codeCoverageIgnore
509505
}
510506

511507
$baseURL = config(App::class)->baseURL;
@@ -530,9 +526,7 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
530526
$response->sendHeaders();
531527

532528
if (ENVIRONMENT !== 'testing') {
533-
// @codeCoverageIgnoreStart
534-
exit();
535-
// @codeCoverageIgnoreEnd
529+
exit(); // @codeCoverageIgnore
536530
}
537531
}
538532
}
@@ -796,10 +790,7 @@ function log_message(string $level, string $message, array $context = [])
796790
return $logger->log($level, $message, $context);
797791
}
798792

799-
// @codeCoverageIgnoreStart
800-
return Services::logger(true)
801-
->log($level, $message, $context);
802-
// @codeCoverageIgnoreEnd
793+
return Services::logger(true)->log($level, $message, $context); // @codeCoverageIgnore
803794
}
804795
}
805796

@@ -834,9 +825,7 @@ function old(string $key, $default = null, $escape = 'html')
834825
{
835826
// Ensure the session is loaded
836827
if (session_status() === PHP_SESSION_NONE && ENVIRONMENT !== 'testing') {
837-
// @codeCoverageIgnoreStart
838-
session();
839-
// @codeCoverageIgnoreEnd
828+
session(); // @codeCoverageIgnore
840829
}
841830

842831
$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)