modules/Import/readers/ICSReader.php
The method getFirstRowData has a boolean flag argument $hasHeader, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public function getFirstRowData($hasHeader = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Remove the unused function parameter "$hasHeader". Open
Open
public function getFirstRowData($hasHeader = true)
- Read upRead up
- Exclude checks
Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.
Noncompliant Code Example
function doSomething($a, $b) { // "$a" is unused return compute($b); }
Compliant Solution
function doSomething($b) { return compute($b); }
Exceptions
Functions in classes that override a class or implement interfaces are ignored.
class C extends B { function doSomething($a, $b) { // no issue reported on $b compute($a); } }
See
- MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
- MISRA C:2012, 2.7 - There should be no unused parameters in functions
- CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
- CERT, MSC12-CPP. - Detect and remove code that has no effect
Avoid unused parameters such as '$hasHeader'. Open
Open
public function getFirstRowData($hasHeader = true)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Saw unextractable annotation for comment '* @return <boolean>'</boolean>
Open
Open
* @return <boolean>
- Exclude checks
Saw unextractable annotation for comment '* @param <boolean> $hasHeader'</boolean>
Open
Open
* @param <boolean> $hasHeader
- Exclude checks
Saw unextractable annotation for comment '* @return <boolean>'</boolean>
Open
Open
* @return <boolean>
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Import_ICSReader_Reader
- Exclude checks
The class Import_ICSReader_Reader is not named in CamelCase. Open
Open
class Import_ICSReader_Reader
{
/**
* Function to get info about imported file contains header or not.
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get info about imported file contains First Row or not.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return <boolean>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getFirstRowData($hasHeader = true)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param <boolean> $hasHeader
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get info about imported file contains header or not.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function hasHeader()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return <boolean>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Class name "Import_ICSReader_Reader" is not in camel caps format Open
Open
class Import_ICSReader_Reader
- Exclude checks