File SpecialRDFImport.php
has 284 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
class RDFImport extends RDFIOSpecialPage {
function __construct() {
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' );
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 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
Method getExampleRDFXMLData
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getExampleRDFXMLData() {
return '<rdf:RDF\\n\
xmlns:rdf=\\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\\"\\n\
xmlns:cd=\\"http://www.recshop.fake/cd#\\"\\n\
xmlns:countries=\\"http://www.countries.org/onto/\\"\\n\
Method getJsCode
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getJsCode() {
$jsCode = '
<script type="text/javascript">
function pasteExampleRDFXMLData(textFieldId) {
var textfield = document.getElementById(textFieldId);
Method execute
has 32 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-import permission for the current user
if ( !$this->userCanExecute( $this->getUser() ) ) {
Method getExampleTurtleData
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getExampleTurtleData() {
$exampleData = <<<EOT
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\\n\
@prefix cd: <http://www.recshop.fake/cd#> .\\n\
@prefix countries: <http://www.countries.org/onto/> .\\n\
Method importData
has 27 lines of code (exceeds 25 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!' );
Missing class import via use statement (line '68', column '15'). Open
throw new RDFIOException( 'URL field is empty!' );
- Read upRead up
- Exclude checks
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 '102', column '22'). Open
$requestData = new RDFIORequestData();
- Read upRead up
- Exclude checks
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 '70', column '15'). Open
throw new RDFIOException( 'Invalid URL provided!' );
- Read upRead up
- Exclude checks
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 '78', column '14'). Open
throw new RDFIOException( 'Import source is not selected!' );
- Read upRead up
- Exclude checks
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 '43', column '25'). Open
$rdfImporter = new RDFIORDFImporter();
- Read upRead up
- Exclude checks
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 '65', column '22'). Open
$rdfImporter = new RDFIORDFImporter();
- Read upRead up
- Exclude checks
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 '75', column '15'). Open
throw new RDFIOException( 'RDF field is empty!' );
- Read upRead up
- Exclude checks
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 '18', column '14'). Open
throw new PermissionsError( 'rdfio-import', array( 'rdfio-specialpage-access-permission-missing' ) );
- Read upRead up
- Exclude checks
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
The method importData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new RDFIOException( 'Import source is not selected!' );
}
- Read upRead up
- Exclude checks
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
}
}
}