Showing 21 of 49 total issues
File Purge.php
has 345 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace SteadLane\Cloudflare;
use SilverStripe\Core\Extensible;
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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')) {
- Create a ticketCreate a ticket
File CloudFlare.php
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace SteadLane\Cloudflare;
use Psr\Log\LoggerInterface;
- Create a ticketCreate a ticket
Method fetchZoneID
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fetchZoneID()
{
if (!$this->hasCFCredentials()) {
return null;
}
- Create a ticketCreate a ticket
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));
- Create a ticketCreate a ticket
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();
}
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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 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();
- Create a ticketCreate a ticket
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",
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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 $zoneID;
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return false;
- Create a ticketCreate a ticket
Function getUrlVariants
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getUrlVariants($urls)
{
$output = array();
foreach ($urls as $url) {
- Read upRead up
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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"