steadlane/silverstripe-vision6

View on GitHub

Showing 79 of 79 total issues

The property $belongs_many_many is not named in camelCase.
Open

class Vision6Field extends DataObject
{
    protected static $db = array(
        "FieldID" => "Int", // The ID of the Field.
        "Name" => "Varchar(100)", // The name of the Field in the List.
Severity: Minor
Found in code/models/Vision6Field.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

Function syncFields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public static function syncFields()
    {
        if (static::$is_flushing && !defined('VISION6_API_KEY')) {
            return;
        }
Severity: Minor
Found in code/tasks/Vision6Sync.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

The class Vision6FieldFactory has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
Open

class Vision6FieldFactory extends Object
{
    /** @var  Vision6List */
    protected $list;

Severity: Minor
Found in code/Vision6FieldFactory.php by phpmd

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

Function setApiUrl has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function setApiUrl($url)
    {
        // Add API version to url
        $parts = @parse_url($url);
        if ($parts) {
Severity: Minor
Found in code/api/Vision6Service.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

Function normalizeFormData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function normalizeFormData(array $postVars)
    {
        $output = array();

        foreach ($postVars as $key => $val) {
Severity: Minor
Found in code/controllers/Vision6PageController.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

Missing class import via use statement (line '112', column '23').
Open

            throw new \RuntimeException("Field \"{$field->Name}\" is a {$field->Type} field but was provided to _textFieldFor()");
Severity: Minor
Found in code/Vision6FieldFactory.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '36', column '20').
Open

        $api = new Vision6Api();
Severity: Minor
Found in code/tasks/Vision6Sync.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '78', column '24').
Open

            return new SS_HTTPResponse(

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '68', column '20').
Open

        $api = new Vision6Api();
Severity: Minor
Found in code/tasks/Vision6Sync.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid too many return statements within this method.
Open

        return $response;
Severity: Major
Found in code/api/Vision6Service.php - About 30 mins to fix

    Missing class import via use statement (line '22', column '20').
    Open

            return new SS_HTTPResponse(

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Remove error control operator '@' on line 367.
    Open

        protected function postRequest($methodName, $postData)
        {
            // Build request headers
            $headers = array(
                'Content-Type: application/json',
    Severity: Minor
    Found in code/api/Vision6Service.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Remove error control operator '@' on line 100.
    Open

        public function setApiUrl($url)
        {
            // Add API version to url
            $parts = @parse_url($url);
            if ($parts) {
    Severity: Minor
    Found in code/api/Vision6Service.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Avoid unused parameters such as '$request'.
    Open

        public function run($request)
    Severity: Minor
    Found in code/tasks/Vision6ViewLists.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Avoid using static access to class '\Session' in method 'getSession'.
    Open

            return \Session::get('Vision6') ?: (\Session::set('Vision6', array())) ?: \Session::get('Vision6');
    Severity: Minor
    Found in code/Vision6.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid unused private fields such as '$db'.
    Open

        private static $db = array(
            'ListID' => 'Int',
            'EmailField' => 'Varchar(255)',
            'GracefulReject' => 'Boolean'
        );

    UnusedPrivateField

    Since: 0.2

    Detects when a private field is declared and/or assigned a value, but not used.

    Example

    class Something
    {
        private static $FOO = 2; // Unused
        private $i = 5; // Unused
        private $j = 6;
        public function addOne()
        {
            return $this->j++;
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedprivatefield

    Avoid using static access to class 'DropdownField' in method 'getCMSFields'.
    Open

                        DropdownField::create('ListID', 'Mailing List', $lists),

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class 'TextareaField' in method 'getTextareaFieldFor'.
    Open

            $ssObj = TextareaField::create($field->Name, $field->Name);
    Severity: Minor
    Found in code/Vision6FieldFactory.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class 'Vision6Sync' in method 'getLists'.
    Open

                Vision6Sync::flush();

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid unused parameters such as '$request'.
    Open

        public function run($request)
    Severity: Minor
    Found in code/tasks/Vision6Sync.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Severity
    Category
    Status
    Source
    Language