Function makeCSPDirectives
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
private function makeCSPDirectives( $policyConfig, $mode ) {
if ( $policyConfig === false ) {
// CSP is disabled
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
Method makeCSPDirectives
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function makeCSPDirectives( $policyConfig, $mode ) {
if ( $policyConfig === false ) {
// CSP is disabled
return '';
}
File ContentSecurityPolicy.php
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
Method getAdditionalSelfUrls
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getAdditionalSelfUrls() {
// XXX on a foreign repo, the included description page can have anything on it,
// including inline scripts. But nobody does that.
// In principle, you can have even more complex configs... (e.g. The urlsByExt option)
Function getAdditionalSelfUrls
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function getAdditionalSelfUrls() {
// XXX on a foreign repo, the included description page can have anything on it,
// including inline scripts. But nobody does that.
// In principle, you can have even more complex configs... (e.g. The urlsByExt option)
- 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 getAdditionalSelfUrlsScript
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function getAdditionalSelfUrlsScript() {
$additionalUrls = [];
// wgExtensionAssetsPath for ?debug=true mode
$pathVars = [
MainConfigNames::LoadScript,
- 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 prepareUrlForCSP
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function prepareUrlForCSP( $url ) {
$result = false;
if ( preg_match( '/^[a-z][a-z0-9+.-]*:$/i', $url ) ) {
// A schema source (e.g. blob: or data:)
return $url;
- 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 getCORSSources
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function getCORSSources() {
$additionalUrls = [];
$CORSSources = $this->mwConfig->get( MainConfigNames::CrossSiteAJAXdomains );
foreach ( $CORSSources as $source ) {
if ( strpos( $source, '?' ) !== false ) {
- 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"