Showing 10 of 145 total issues
Function toYml
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public static function toYml($response, $return = false)
{
$cspHeader = $response->getHeader('content-security-policy') ?? $response->getHeader('content-security-policy-report-only');
$asArray = explode(';', $cspHeader);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function onBeforeInit
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function onBeforeInit()
{
if (self::$isTesting || !DB::is_active() || !ClassInfo::hasTable('Member') || Director::is_cli()) {
return;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File ControllerCSPExtension.php
has 273 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Firesphere\CSPHeaders\Extensions;
Method addPermissionsHeaders
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function addPermissionsHeaders(mixed $ymlConfig, Controller $controller)
{
$config = Injector::inst()->convertServiceProperty($ymlConfig);
$policies = [];
foreach ($config as $key => $value) {
Method toYml
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function toYml($response, $return = false)
{
$cspHeader = $response->getHeader('content-security-policy') ?? $response->getHeader('content-security-policy-report-only');
$asArray = explode(';', $cspHeader);
Method onBeforeInit
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onBeforeInit()
{
if (self::$isTesting || !DB::is_active() || !ClassInfo::hasTable('Member') || Director::is_cli()) {
return;
}
Function addPermissionsHeaders
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function addPermissionsHeaders(mixed $ymlConfig, Controller $controller)
{
$config = Injector::inst()->convertServiceProperty($ymlConfig);
$policies = [];
foreach ($config as $key => $value) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function onBeforeWrite
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function onBeforeWrite()
{
$body = null;
// Since this is called from CSP Backend, an SRI for external files is automatically created
if (!Director::is_site_url($this->File)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function addCSPHeaders
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function addCSPHeaders(mixed $ymlConfig, Controller $owner): void
{
$config = Injector::inst()->convertServiceProperty($ymlConfig);
$legacy = $config['legacy'] ?? true;
$unsafeCSSInline = $config['style-src']['unsafe-inline'];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function buildSRI
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function buildSRI($file, array $htmlAttributes): array
{
$skipFiles = $this->config()->get('skip_domains') ?? [];
foreach ($skipFiles as $filename) {
if (strpos($file, $filename) === 0) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"