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;
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 ) {
- Read upRead up
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 );
- Read upRead up
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 );
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";
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;
- Read upRead up
- Exclude checks
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() {
- Exclude checks
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 ) );
- Read upRead up
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() {
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' );
- Read upRead up
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' );
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() ) ) {
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!' );
- Read upRead up
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
// ----------------------------------------------------------------------
- Read upRead up
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 = '';
- Read upRead up
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() ) ) {
- Read upRead up
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
- Read upRead up
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 ) );
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 ) {
- Read upRead up
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;
- Read upRead up
- Exclude checks
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++ ) {
}
}
}