NatLibFi/Skosmos

View on GitHub

Showing 1,049 of 1,049 total issues

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

        } else {
            return $this->returnError(400, 'Bad Request', "uri parameter missing");
        }
Severity: Minor
Found in src/controller/RestController.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 hierarchy uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    // no main concept scheme set on the vocab, take the first value of 'tops' (sorted alphabetically)
                    $results[$uri]['top'] = $results[$uri]['tops'][0];
                }
Severity: Minor
Found in src/controller/RestController.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 getGitModifiedDate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $commitDate = $this->executeGitModifiedDateCommand($gitCommand);
        }
Severity: Minor
Found in src/controller/Controller.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 redirect uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->redirectWeb($request->getVocab(), $request->getUri());
        }
Severity: Minor
Found in src/controller/EntityController.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\Language' in method '__construct'.
Open

            $this->languages[$langcode]['lemma'] = Punic\Language::getName($langcode, $langcode);
Severity: Minor
Found in src/controller/Controller.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 hierarchy() has an NPath complexity of 756. The configured NPath complexity threshold is 200.
Open

    public function hierarchy($request)
    {
        if ($this->notModified($request->getVocab())) {
            return null;
        }
Severity: Minor
Found in src/controller/RestController.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

Avoid using static access to class 'Punic\Language' in method 'labelStatistics'.
Open

                $langdata['literal'] = Punic\Language::getName($proplang, $lang);
Severity: Minor
Found in src/controller/RestController.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 redirect uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            // guess vocabulary based on URI
            $vocab = $this->model->guessVocabularyFromURI($request->getUri());
            if ($vocab === null) {
                return $this->returnError('404', 'Not Found', 'Unrecognized URI ' . $request->getUri());
Severity: Minor
Found in src/controller/EntityController.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 findLookupHits() has an NPath complexity of 266240. The configured NPath complexity threshold is 200.
Open

    private function findLookupHits($results, $label, $lang)
    {
        $hits = array();
        // case 1: exact match on preferred label
        foreach ($results as $res) {
Severity: Minor
Found in src/controller/RestController.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

Avoid unused local variables such as '$domain'.
Open

        $domain = 'skosmos';
Severity: Minor
Found in src/controller/Controller.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Avoid using static access to class '\Punic\Language' in method '__construct'.
Open

            return Language::getName($langcode, $lang);
Severity: Minor
Found in src/controller/WebController.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 sendFeedback() has an NPath complexity of 288. The configured NPath complexity threshold is 200.
Open

    public function sendFeedback($request, $message, $messageSubject, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
    {
        $toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress();
        $messageSubject = "[" . $this->model->getConfig()->getServiceName() . "] " . $messageSubject;
        if ($fromVocab !== null && $fromVocab !== '') {
Severity: Minor
Found in src/controller/WebController.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 'getBoolean()' method which returns a boolean should be named 'is...()' or 'has...()'
Open

    protected function getBoolean($property, $default = false)
    {
        $val = $this->getResource()->getLiteral($property);
        if ($val) {
            return filter_var($val->getValue(), FILTER_VALIDATE_BOOLEAN);
Severity: Minor
Found in src/model/BaseConfig.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

Avoid using static access to class 'EasyRdf\RdfNamespace' in method 'vocabularyStatistics'.
Open

                'label' => isset($vocabStats[$groupClass]['label']) ? $vocabStats[$groupClass]['label'] : $this->model->getText(EasyRdf\RdfNamespace::shorten($groupClass)),
Severity: Minor
Found in src/controller/RestController.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 redirectToVocabData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $vocid = $request->getVocab()->getId();
                return $this->returnError('404', 'Not Found', "No download source URL known for vocabulary $vocid in language $dataLang");
            }
Severity: Minor
Found in src/controller/RestController.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 '\ML\JsonLD\JsonLD' in method 'returnDataResults'.
Open

            $compactJsonLD = \ML\JsonLD\JsonLD::compact($results, json_encode($context));
Severity: Minor
Found in src/controller/RestController.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 '\ML\JsonLD\JsonLD' in method 'returnDataResults'.
Open

            $results = \ML\JsonLD\JsonLD::toString($compactJsonLD);
Severity: Minor
Found in src/controller/RestController.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 'getProperties'.
Open

                    $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop;
Severity: Minor
Found in src/model/Concept.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 sortValues uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                        } else { // natural
                            return strnatcasecmp($anot, $bnot);
                        }
Severity: Minor
Found in src/model/ConceptProperty.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 'getReifiedPropertyValues'.
Open

            $prop = (EasyRdf\RdfNamespace::shorten($prop) !== null) ? EasyRdf\RdfNamespace::shorten($prop) : $prop;
Severity: Minor
Found in src/model/ConceptPropertyValue.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

Severity
Category
Status
Source
Language