specials/SpecialSPARQLEndpoint.php

Summary

Maintainability
D
2 days
Test Coverage

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

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

File SpecialSPARQLEndpoint.php has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

class SPARQLEndpoint extends RDFIOSpecialPage {
    protected $sparqlendpoint;
    protected $storewrapper;
Severity: Minor
Found in specials/SpecialSPARQLEndpoint.php - About 5 hrs to fix

    Method getHTMLForm has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getHTMLForm( $query = '' ) {
            $wRequest = $this->getRequest();
            $wUser = $this->getUser();
            $uriResolverURI = SpecialPage::getTitleFor( 'URIResolver' )->getFullURL() . '/';
            $defaultQuery = "@PREFIX w : <$uriResolverURI> .\n\nSELECT *\nWHERE { ?s ?p ?o }\nLIMIT 25";
    Severity: Major
    Found in specials/SpecialSPARQLEndpoint.php - About 3 hrs to fix

      The class SPARQLEndpoint has an overall complexity of 63 which is very high. The configured complexity threshold is 50.
      Open

      class SPARQLEndpoint extends RDFIOSpecialPage {
          protected $sparqlendpoint;
          protected $storewrapper;
      
          public function __construct() {
      Severity: Minor
      Found in specials/SpecialSPARQLEndpoint.php by phpmd

      Function toEquivURIsInSparqlResults has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          private function toEquivURIsInSparqlResults( $sparqlResult ) {
              $rows = $sparqlResult['result']['rows'];
              $vars = $sparqlResult['result']['variables'];
              foreach ( $rows as $rowid => $row ) {
                  foreach ( $vars as $var ) {
      Severity: Minor
      Found in specials/SpecialSPARQLEndpoint.php - About 1 hr 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

      Method execute has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      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 - About 1 hr to fix

        Method executeReadOnlyQuery has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function executeReadOnlyQuery( $options ) {
                $wikiOut = $this->getOutput();
        
                $outputSer = $this->passSparqlToARC2AndGetSerializedOutput();
        
        
        Severity: Minor
        Found in specials/SpecialSPARQLEndpoint.php - About 1 hr to fix

          Function executeReadOnlyQuery has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              private function executeReadOnlyQuery( $options ) {
                  $wikiOut = $this->getOutput();
          
                  $outputSer = $this->passSparqlToARC2AndGetSerializedOutput();
          
          
          Severity: Minor
          Found in specials/SpecialSPARQLEndpoint.php - About 1 hr 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

          Method extendQueryPatternsWithEquivUriLinks has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function extendQueryPatternsWithEquivUriLinks( $patterns ) {
                  $patternIdx = 0;
                  foreach ( $patterns as $pattern ) {
                      $equivUriUris = array(
                          's' => $this->storewrapper->getEquivURIURI(),
          Severity: Minor
          Found in specials/SpecialSPARQLEndpoint.php - About 1 hr to fix

            Avoid too many return statements within this method.
            Open

                            return;
            Severity: Major
            Found in specials/SpecialSPARQLEndpoint.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return;
              Severity: Major
              Found in specials/SpecialSPARQLEndpoint.php - About 30 mins to fix

                Function extendQueryPatternsWithEquivUriLinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function extendQueryPatternsWithEquivUriLinks( $patterns ) {
                        $patternIdx = 0;
                        foreach ( $patterns as $pattern ) {
                            $equivUriUris = array(
                                's' => $this->storewrapper->getEquivURIURI(),
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.php - About 25 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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                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 - About 25 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 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 class SPARQLEndpoint has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
                Open

                class SPARQLEndpoint extends RDFIOSpecialPage {
                    protected $sparqlendpoint;
                    protected $storewrapper;
                
                    public function __construct() {
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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

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

                        $rdfImporter = new RDFIOSMWBatchWriter( $triples, 'triples_array' );
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 '9', column '31').
                Open

                        $this->sparqlendpoint = new ARC2_StoreEndpoint( $this->getSPARQLEndpointConfig(), $this );
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 '157', column '20').
                Open

                        $seOptions = new RDFIOSPARQLEndpointOptions();
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 '373', column '14').
                Open

                        $ser = new ARC2_RDFXMLSerializer();
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 '312', column '22').
                Open

                        $rdfImporter = new RDFIORDFImporter();
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 '120', column '16').
                Open

                            $arc2 = new ARC2_Class( array(), $this );
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 '212', column '27').
                Open

                        $sparqlserializer = new ARC2_SPARQLSerializerPlugin( array(), $this );
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 '13', column '29').
                Open

                        $this->storewrapper = new RDFIOARC2StoreWrapper();
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 '25', column '14').
                Open

                            throw new PermissionsError( 'rdfio-sparql', array( 'rdfio-specialpage-access-permission-missing' ) );
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 '188', column '17').
                Open

                        $parser = new ARC2_SPARQLPlusParser( array(), $this );
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.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 excessively long variable names like $rdfiogOutputEquivUris. Keep variable name length under 20.
                Open

                        global $rdfiogQueryByEquivURIs, $rdfiogOutputEquivUris;
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.php by phpmd

                LongVariable

                Since: 0.2

                Detects when a field, formal or local variable is declared with a long name.

                Example

                class Something {
                    protected $reallyLongIntName = -3; // VIOLATION - Field
                    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                        $otherReallyLongName = -5; // VIOLATION - Local
                        for ($interestingIntIndex = 0; // VIOLATION - For
                             $interestingIntIndex < 10;
                             $interestingIntIndex++ ) {
                        }
                    }
                }

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

                Avoid excessively long variable names like $rdfiogQueryByEquivURIs. Keep variable name length under 20.
                Open

                        global $rdfiogQueryByEquivURIs, $rdfiogOutputEquivUris;
                Severity: Minor
                Found in specials/SpecialSPARQLEndpoint.php by phpmd

                LongVariable

                Since: 0.2

                Detects when a field, formal or local variable is declared with a long name.

                Example

                class Something {
                    protected $reallyLongIntName = -3; // VIOLATION - Field
                    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                        $otherReallyLongName = -5; // VIOLATION - Local
                        for ($interestingIntIndex = 0; // VIOLATION - For
                             $interestingIntIndex < 10;
                             $interestingIntIndex++ ) {
                        }
                    }
                }

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

                There are no issues that match your filters.

                Category
                Status