steadlane/silverstripe-cloudflare

View on GitHub

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;
Severity: Minor
Found in src/Purge/Purge.php - About 4 hrs to fix

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')) {
Severity: Minor
Found in src/Extensions/CloudFlareExtension.php - About 3 hrs to fix

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) {

Severity: Minor
Found in src/Purge/Purge.php - About 3 hrs to fix

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;

Severity: Minor
Found in src/Purge/Purge.php - About 3 hrs to fix

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')) {
Severity: Major
Found in src/Extensions/CloudFlareExtension.php - About 2 hrs to fix

File CloudFlare.php has 255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace SteadLane\Cloudflare;

use Psr\Log\LoggerInterface;
Severity: Minor
Found in src/CloudFlare.php - About 2 hrs to fix

Method fetchZoneID has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function fetchZoneID()
    {
        if (!$this->hasCFCredentials()) {
            return null;
        }
Severity: Minor
Found in src/CloudFlare.php - About 2 hrs to fix

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));
Severity: Minor
Found in src/Purge/Purge.php - About 1 hr to fix

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();
        }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php - About 1 hr to fix

Function fetchZoneID has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function fetchZoneID()
    {
        if (!$this->hasCFCredentials()) {
            return null;
        }
Severity: Minor
Found in src/CloudFlare.php - About 1 hr to fix

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)) {
Severity: Minor
Found in src/Purge/Purge.php - About 1 hr to fix

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();
Severity: Minor
Found in src/CloudFlare.php - About 1 hr to fix

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",
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php - About 1 hr to fix

Function handleMessage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function handleMessage($message, $params = null)
    {
        if (!$message) {
            return;
        }
Severity: Minor
Found in src/Messages/Notifications.php - About 55 mins to fix

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));
Severity: Minor
Found in src/Purge/Purge.php - About 45 mins to fix

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?)
Severity: Minor
Found in src/CloudFlare.php - About 35 mins to fix

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;
Severity: Major
Found in src/CloudFlare.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return false;
Severity: Major
Found in src/Purge/Purge.php - About 30 mins to fix

Function getUrlVariants has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getUrlVariants($urls)
    {
        $output = array();

        foreach ($urls as $url) {
Severity: Minor
Found in src/Purge/Purge.php - About 25 mins to fix

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)) {
Severity: Minor
Found in src/CloudFlare.php - About 25 mins to fix

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

Severity
Category
Status
Source
Language