NatLibFi/Skosmos

View on GitHub

Showing 1,049 of 1,049 total issues

Avoid using static access to class 'EasyRdf\Http' in method 'initializeHttpClient'.
Open

        $httpclient = EasyRdf\Http::getDefaultHttpClient();
Severity: Minor
Found in src/model/sparql/GenericSparql.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 'Punic\Language' in method 'getLanguages'.
Open

                $langlit = Punic\Language::getName($langcode, $lang);
Severity: Minor
Found in src/model/Model.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 getPluginArray uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $pluginArray[] = $plugin->getLiteral('skosmos:usePlugin')->getValue();
                }
Severity: Minor
Found in src/model/VocabularyConfig.php by phpmd

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

The 'getShowTopConcepts()' method which returns a boolean should be named 'is...()' or 'has...()'
Open

    public function getShowTopConcepts()
    {
        return $this->getBoolean('skosmos:showTopConcepts');
    }
Severity: Minor
Found in src/model/VocabularyConfig.php by phpmd

BooleanGetMethodName

Since: 0.2

Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

Example

class Foo {
    /**
     * @return boolean
     */
    public function getFoo() {} // bad
    /**
     * @return bool
     */
    public function isFoo(); // ok
    /**
     * @return boolean
     */
    public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}

Source https://phpmd.org/rules/naming.html#booleangetmethodname

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

        } else {
            return $sidebarViews[0]; // if no alphabetical index, displaying first provided view
        }
Severity: Minor
Found in src/model/VocabularyConfig.php by phpmd

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

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

        } else { // query the default graph
            $this->graphClause = "";
        }
Severity: Minor
Found in src/model/sparql/GenericSparql.php by phpmd

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 using static access to class 'EasyRdf\RdfNamespace' in method 'generateQueryPrefixes'.
Open

        foreach (EasyRdf\RdfNamespace::namespaces() as $prefix => $uri) {
Severity: Minor
Found in src/model/sparql/GenericSparql.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 'EasyRdf\RdfNamespace' in method 'formatTypes'.
Open

                $unprefixed = EasyRdf\RdfNamespace::expand($type);
Severity: Minor
Found in src/model/sparql/GenericSparql.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 transformParentListResults() has an NPath complexity of 63362. The configured NPath complexity threshold is 200.
Open

    private function transformParentListResults($result, $lang)
    {
        $ret = array();
        foreach ($result as $row) {
            if (!isset($row->broad)) {
Severity: Minor
Found in src/model/sparql/GenericSparql.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

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

        } else { // APC not available, parse on every request
            $resource = $this->resolver->resolve($uri, $this->getConfig()->getHttpTimeout());
        }
Severity: Minor
Found in src/model/Model.php by phpmd

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 using static access to class 'EasyRdf\Format' in method 'resolve'.
Open

        EasyRdf\Format::unregister('json');

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 'EasyRdf\Http' in method 'resolve'.
Open

            $httpclient = EasyRdf\Http::getDefaultHttpClient();

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 'EasyRdf\Http' in method 'initializeHttpClient'.
Open

        EasyRdf\Http::setDefaultHttpClient($httpclient); // actually redundant..
Severity: Minor
Found in src/model/sparql/GenericSparql.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 generateConceptSearchQueryCondition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else { // too complicated - have to use a regex
            # make sure regex metacharacters are not passed through
            $term = str_replace('\\', '\\\\', preg_quote($term));
            $term = str_replace('\\\\*', '.*', $term); // convert asterisk to regex syntax
            $term = str_replace('\'', '\\\'', $term); // ensure single quotes are quoted
Severity: Minor
Found in src/model/sparql/GenericSparql.php by phpmd

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

The method transformConceptSearchResult() has an NPath complexity of 13824. The configured NPath complexity threshold is 200.
Open

    private function transformConceptSearchResult($row, $vocabs, $fields)
    {
        $hit = array();
        $hit['uri'] = $row->s->getUri();

Severity: Minor
Found in src/model/sparql/GenericSparql.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

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

        else {
            return null;
        }
Severity: Minor
Found in src/model/sparql/GenericSparql.php by phpmd

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 using static access to class 'Punic\Calendar' in method 'getInfo'.
Open

                        $val = Punic\Calendar::formatDate($val->getValue(), 'full', $lang) . ' ' . Punic\Calendar::format($val->getValue(), 'HH:mm:ss', $lang);
Severity: Minor
Found in src/model/Vocabulary.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 transformParentListResults uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            // nonexistent concept
            return null;
        }
Severity: Minor
Found in src/model/sparql/GenericSparql.php by phpmd

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

The method searchConcepts() has an NPath complexity of 1000. The configured NPath complexity threshold is 200.
Open

    public function searchConcepts($params)
    {
        // don't even try to search for empty prefix if no other search criteria (group or parent concept) has been set
        if (($params->getSearchTerm() === "" || !preg_match('/[^*]/', $params->getSearchTerm())) && !$params->getGroupLimit() && !$params->getParentLimit()) {
            return array();
Severity: Minor
Found in src/model/Model.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

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

        } else { // we have reached the end of a path and we need to start a new row in the 'stack'
            if (isset($bTresult[$uri])) {
                $path = array_merge($path, array(new Breadcrumb($uri, $bTresult[$uri]['label'])));
            }

Severity: Minor
Found in src/model/Vocabulary.php by phpmd

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

Severity
Category
Status
Source
Language