Showing 158 of 158 total issues

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

    Function toEquivUrisInTriples has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        function toEquivUrisInTriples( $triples, $propUrisFilter = null ) {
    
            $equivUriCache = array();
    
            foreach ( $triples as $tripleidx => $triple ) {
    Severity: Minor
    Found in classes/RDFIO_ARC2StoreWrapper.php - About 3 hrs 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 convert has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    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 );
    
    
    Severity: Minor
    Found in classes/parsers/RDFIO_ARC2ToWikiConverter.php - About 3 hrs 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 convert has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    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 );
    
    
    Severity: Major
    Found in classes/parsers/RDFIO_ARC2ToWikiConverter.php - About 3 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 RDFIOURIToTitleConverter has 11 public methods. Consider refactoring RDFIOURIToTitleConverter to keep number of public methods under 10.
        Open

        class RDFIOURIToTitleConverter { 
        
            protected $arc2Triples = null;
            protected $arc2ResourceIndex = null;
            protected $arc2NSPrefixes = null;

        TooManyPublicMethods

        Since: 0.1

        A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

        By default it ignores methods starting with 'get' or 'set'.

        Example

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

        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 execute has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        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 - About 3 hrs 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

        File SpecialRDFImport.php has 284 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        class RDFImport extends RDFIOSpecialPage {
        
            function __construct() {
        Severity: Minor
        Found in specials/SpecialRDFImport.php - About 2 hrs to fix

          Function import has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function import( $limit = 25, $offset = 0 ) {
                  $wOut = $this->getOutput();
                  $wRequest = $this->getRequest();
          
                  $externalSparqlUrl = $wRequest->getText( 'extsparqlurl' );
          Severity: Minor
          Found in specials/SpecialSPARQLImport.php - About 2 hrs 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 getHTMLFormContent has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getHTMLFormContent( $requestData, $user, $extraFormContent = '' ) {
                  $textfieldHiddenHTML = '';
                  $urlChecked = ( $requestData->importSource === 'url' );
                  $textfieldChecked = ( $requestData->importSource === 'textfield' );
          
          
          Severity: Major
          Found in specials/SpecialRDFImport.php - About 2 hrs to fix

            Method execute has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function execute( $par ) {
                    unset( $par ); // Needed to suppress warning about unused variable which we include just for consistency.
            
                    // Require rdfio-admin permission for the current user
                    if ( !$this->userCanExecute( $this->getUser() ) ) {
            Severity: Major
            Found in specials/SpecialRDFIOAdmin.php - About 2 hrs to fix

              Function importData has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  function importData( RDFIORequestData $requestData ) {
                      $rdfImporter = new RDFIORDFImporter();
                      if ( $requestData->importSource === 'url' ) {
                          if ( $requestData->externalRdfUrl === '' ) {
                              throw new RDFIOException( 'URL field is empty!' );
              Severity: Minor
              Found in specials/SpecialRDFImport.php - About 2 hrs 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 import has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function import( $wikiPages ) {
              
                      // ----------------------------------------------------------------------
                      //  1. Loop over wiki pages
                      // ----------------------------------------------------------------------
              Severity: Minor
              Found in classes/RDFIO_SMWPageWriter.php - About 2 hrs 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 applyGlobalSettingForPropertiesToUseAsWikiTitle has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  function applyGlobalSettingForPropertiesToUseAsWikiTitle( $uri ) {
                      global $rdfiogTitleProperties;
              
                      $title = '';
              
              
              Severity: Minor
              Found in classes/parsers/RDFIO_URIToWikiTitleConverter.php - About 2 hrs 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 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  function execute( $par ) {
                      unset( $par ); // Needed to suppress warning about unused variable which we include just for consistency.
              
                      // Require rdfio-import permission for the current user
                      if ( !$this->userCanExecute( $this->getUser() ) ) {
              Severity: Minor
              Found in specials/SpecialRDFImport.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

              Function splitURI has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function splitURI( $uri ) {
                      global $rdfiogBaseURIs;
                      /* ADAPTED FROM ARC2 WITH SOME MODIFICATIONS
                       * the following namespaces may lead to conflated URIs,
                       * we have to set the split position manually
              Severity: Minor
              Found in classes/parsers/RDFIO_URIToWikiTitleConverter.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 47 lines of code (exceeds 25 allowed). Consider refactoring.
              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 - About 1 hr to fix

                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

                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

                Severity
                Category
                Status
                Source
                Language