Showing 21 of 44 total issues
File Purge.php
has 345 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace SteadLane\Cloudflare;
use SilverStripe\Core\Extensible;
Function onAfterPublish
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function onAfterPublish(&$original)
{
// if the page was just created, then there is no cache to purge and $original doesn't actually exist so bail out - resolves #3
// we don't purge anything if we're operating on localhost
if (CloudFlare::singleton()->hasCFCredentials() && $original && strlen($original->URLSegment) && Permission::check('CF_PURGE_PAGE')) {
- 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 fileSearchAux
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function fileSearchAux($dir, $pattern, &$files) {
$handle = opendir($dir);
if ($handle) {
while (($file = readdir($handle)) !== 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"
Further reading
Purge
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class Purge
{
use Injectable;
use Extensible;
Method onAfterPublish
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onAfterPublish(&$original)
{
// if the page was just created, then there is no cache to purge and $original doesn't actually exist so bail out - resolves #3
// we don't purge anything if we're operating on localhost
if (CloudFlare::singleton()->hasCFCredentials() && $original && strlen($original->URLSegment) && Permission::check('CF_PURGE_PAGE')) {
File CloudFlare.php
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace SteadLane\Cloudflare;
use Psr\Log\LoggerInterface;
Method fetchZoneID
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fetchZoneID()
{
if (!$this->hasCFCredentials()) {
return null;
}
Method quick
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function quick($what, $other_id = null)
{
// create a new instance of self so we don't interrupt anything
$purger = self::create();
$what = trim(strtolower($what));
Method purge_single
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function purge_single()
{
if (!Permission::check('CF_PURGE_SINGLE')) {
Security::permissionFailure();
}
Function fetchZoneID
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function fetchZoneID()
{
if (!$this->hasCFCredentials()) {
return null;
}
- 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 isSuccessful
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function isSuccessful()
{
$response = $this->getResponse();
if (!is_array($response)) {
- 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 providePermissions
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function providePermissions()
{
return array(
"CF_PURGE_ALL" => array(
'name' => "Cloudflare: Purge All Cache",
Method curlRequest
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function curlRequest($url, $data = null, $method = 'DELETE')
{
$curlTimeout = $this->getCurlTimeout();
$curl = curl_init();
Function handleMessage
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function handleMessage($message, $params = null)
{
if (!$message) {
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
Function quick
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function quick($what, $other_id = null)
{
// create a new instance of self so we don't interrupt anything
$purger = self::create();
$what = trim(strtolower($what));
- 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 getServerName
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getServerName()
{
$serverName = '';
if (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])) {
$serverName = Convert::raw2xml($_SERVER['HTTP_HOST']); // "Fixes" #1 (what?)
- 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
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $zoneID;
Function handleRequest
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function handleRequest(array $data = null, $isRecursing = null, $method = 'DELETE')
{
if (array_key_exists('files', $data) && !$isRecursing) {
// get URL variants
$data['files'] = $this->getUrlVariants($data['files']);
- 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 prependServerName
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function prependServerName($input)
{
$serverName = CloudFlare::singleton()->getServerName();
if (is_array($input)) {
- 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"