Showing 158 of 158 total issues

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

        } else {
            foreach ( $this->arc2store->getErrors() as $error ) {
                throw new RDFIOARC2StoreWrapperException( $error );
            }
        }
Severity: Minor
Found in classes/RDFIO_ARC2StoreWrapper.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 'SMWDIWikiPage' in method 'getURI'.
Open

            $wikiPageDI = SMWDIWikiPage::newFromTitle( $title );
Severity: Minor
Found in stores/SMW_ARC2Store.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 'ARC2' in method 'importRdfXml'.
Open

        $arc2rdfxmlparser = ARC2::getRDFXMLParser();
Severity: Minor
Found in classes/RDFIO_RDFImporter.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 'ARC2' in method '__construct'.
Open

        $this->arc2store = ARC2::getStore( $arc2StoreConfig );
Severity: Minor
Found in stores/SMW_ARC2Store.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 'WikiPage' in method 'writeToPage'.
Open

        $mwArticleObj = WikiPage::factory( $mwTitleObj );
Severity: Minor
Found in classes/RDFIO_SMWPageWriter.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 toEquivUrisInTriples uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $objEquivUris = $this->getEquivURIsForURI( $objUri );
                    if ( count( $objEquivUris ) > 0 ) {
                        $triples[$tripleidx]['o'] = $objEquivUris[0];
                        $equivUriCache[$objUri] = $objEquivUris[0];
Severity: Minor
Found in classes/RDFIO_ARC2StoreWrapper.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 'ContentHandler' in method 'writeToPage'.
Open

        $mwArticleObj->doEditContent( ContentHandler::makeContent( $content, $mwTitleObj), $summary );
Severity: Minor
Found in classes/RDFIO_SMWPageWriter.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 updateData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $objectStr = '""';
            }
Severity: Minor
Found in stores/SMW_ARC2Store.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 convert uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $uriToTitleConv = new RDFIOURIToWikiTitleConverter( $this->arc2Triples, $this->arc2ResourceIndex, $this->arc2NSPrefixes );
            $propertyTitle = $uriToTitleConv->convert( $propertyURI );
        }

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 'SMWDataValueFactory' in method 'changeTitle'.
Open

        $newpage = SMWDataValueFactory::newTypeIDValue( '_wpg' );
Severity: Minor
Found in stores/SMW_ARC2Store.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 'ARC2' in method 'execute'.
Open

            $triples = ARC2::getTriplesFromIndex( $index );
Severity: Minor
Found in maintenance/exportRdf.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

urisToEquivURIsInQuery accesses the super-global variable $_POST.
Open

    private function urisToEquivURIsInQuery( $options ) {
        $queryInfo = $options->queryInfos;
        $patterns = $queryInfo['query']['pattern']['patterns'][0]['patterns'];

        $patterns = $this->extendQueryPatternsWithEquivUriLinks( $patterns );
Severity: Minor
Found in specials/SpecialSPARQLEndpoint.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 method toEquivUrisInTriples() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    function toEquivUrisInTriples( $triples, $propUrisFilter = null ) {

        $equivUriCache = array();

        foreach ( $triples as $tripleidx => $triple ) {
Severity: Minor
Found in classes/RDFIO_ARC2StoreWrapper.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

The method convert() has a Cyclomatic Complexity of 33. The configured cyclomatic complexity threshold is 10.
Open

    public function convert( $arc2Triples, $arc2ResourceIndex, $arc2NSPrefixes ) {
        // Instatiate wiki title converters (converting from URI and related RDF data to Wiki Title)
        $uriToTitleConv = new RDFIOURIToWikiTitleConverter( $arc2Triples, $arc2ResourceIndex, $arc2NSPrefixes );
        $uriToPropTitleConv = new RDFIOURIToPropertyTitleConverter( $arc2Triples, $arc2ResourceIndex, $arc2NSPrefixes );

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

The method execute() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    public function execute( $par ) {
        unset( $par ); // Needed to suppress warning about unused variable which we include just for consistency.

        // Require rdfio-sparql permission for the current user
        if ( !$this->userCanExecute( $this->getUser() ) ) {
Severity: Minor
Found in specials/SpecialSPARQLEndpoint.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

The method import() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    public function import( $wikiPages ) {

        // ----------------------------------------------------------------------
        //  1. Loop over wiki pages
        // ----------------------------------------------------------------------
Severity: Minor
Found in classes/RDFIO_SMWPageWriter.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

The method execute() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
Open

    public function execute() {
        $inFile = $this->getOption( 'in', '' );
        $chunksize = intval( $this->getOption( 'chunksize', 0 ) );
        $chunksleep = floatval( $this->getOption( 'chunksleep', 0.0 ) );
        $offset = intval( $this->getOption( 'offset', 0 ) );
Severity: Minor
Found in maintenance/importRdf.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

passSparqlToARC2AndGetSerializedOutput accesses the super-global variable $_POST.
Open

    private function passSparqlToARC2AndGetSerializedOutput() {
        // Make sure ARC2 returns a PHP serialization, so that we
        // can do stuff with it programmatically
        $_POST['output'] = 'php_ser';

Severity: Minor
Found in specials/SpecialSPARQLEndpoint.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

Severity
Category
Status
Source
Language