Firesphere/silverstripe-solr-search

View on GitHub

Showing 114 of 187 total issues

Avoid using static access to class '\SilverStripe\Core\ClassInfo' in method 'findOrigin'.
Open

                $dataclasses = array_diff($dataclasses, array_values(ClassInfo::subclassesFor($dataclass)));
Severity: Minor
Found in src/Helpers/FieldResolver.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

The method resolveField uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $value = $this->component->getValue();
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

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

    private static $table_name = 'Solr_SearchSynonym';
Severity: Minor
Found in src/Models/SearchSynonym.php by phpmd

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 unused private fields such as '$table_name'.
Open

    private static $table_name = 'Solr_SolrLog';
Severity: Minor
Found in src/Models/SolrLog.php by phpmd

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

The method doReindex() contains an exit expression.
Open

            exit(0);
Severity: Minor
Found in src/Tasks/SolrIndexTask.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

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

getSuggestion accesses the super-global variable $_SERVER.
Open

function getSuggestion()
{
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php')) {
        require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
    }
Severity: Minor
Found in client/proxy/autosuggest.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

getSuggestion accesses the super-global variable $_SERVER.
Open

function getSuggestion()
{
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php')) {
        require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
    }
Severity: Minor
Found in client/proxy/autosuggest.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

The variable $IDs is not named in camelCase.
Open

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName(['Class', 'IDs']);

Severity: Minor
Found in src/Models/DirtyClass.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $IDs is not named in camelCase.
Open

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName(['Class', 'IDs']);

Severity: Minor
Found in src/Models/DirtyClass.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

XXX found
Open

         such as /select?qt=XXX
Severity: Minor
Found in Solr/4/extras/solrconfig.xml by fixme

XXX found
Open

         such as /select?qt=XXX
Severity: Minor
Found in Solr/5/extras/solrconfig.xml by fixme

TODO found
Open

            <item>TODO</item>
Severity: Minor
Found in phpdoc.dist.xml by fixme

XXX found
Open

         such as /select?qt=XXX
Severity: Minor
Found in Solr/7/extras/solrconfig.xml by fixme

XXX found
Open

         such as /select?qt=XXX
Severity: Minor
Found in Solr/9/extras/solrconfig.xml by fixme
Severity
Category
Status
Source
Language