The class PlotLine has 11 public methods. Consider refactoring PlotLine to keep number of public methods under 10. Open
class PlotLine
{
public $scaleposition;
public $direction = -1;
protected $weight = 1;
- 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
Method _Stroke
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function _Stroke($aImg, $aMinX, $aMinY, $aMaxX, $aMaxY, $aXPos, $aYPos)
The method HideLegend has a boolean flag argument $f, which is a certain sign of a Single Responsibility Principle violation. Open
public function HideLegend($f = 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
The method _Stroke uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
Util\JpGraphError::RaiseL(25125); //(" Illegal direction for static line");
}
- 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
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method '_Stroke'. Open
Util\JpGraphError::RaiseL(25125); //(" Illegal direction for static line");
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused parameters such as '$aImg'. Open
public function StrokeMargin($aImg)
- 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
Avoid unused parameters such as '$aGraph'. Open
public function PreStrokeAdjust($aGraph)
- 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
Avoid unused parameters such as '$aGraph'. Open
public function PrescaleSetup($aGraph)
- 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
Avoid variables with short names like $f. Configured minimum length is 3. Open
public function HideLegend($f = true)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Method name "PlotLine::SetDirection" is not in camel caps format Open
public function SetDirection($aDir)
- Exclude checks
Method name "PlotLine::HideLegend" is not in camel caps format Open
public function HideLegend($f = true)
- Exclude checks
Method name "PlotLine::DoLegend" is not in camel caps format Open
public function DoLegend($graph)
- Exclude checks
Method name "PlotLine::StrokeMargin" is not in camel caps format Open
public function StrokeMargin($aImg)
- Exclude checks
Method name "PlotLine::Max" is not in camel caps format Open
public function Max()
- Exclude checks
Method name "PlotLine::_Stroke" is not in camel caps format Open
public function _Stroke($aImg, $aMinX, $aMinY, $aMaxX, $aMaxY, $aXPos, $aYPos)
- Exclude checks
Method name "PlotLine::Stroke" is not in camel caps format Open
public function Stroke($aImg, $aXScale, $aYScale)
- Exclude checks
Method name "PlotLine::PreStrokeAdjust" is not in camel caps format Open
public function PreStrokeAdjust($aGraph)
- Exclude checks
Method name "PlotLine::PrescaleSetup" is not in camel caps format Open
public function PrescaleSetup($aGraph)
- Exclude checks
Method name "PlotLine::Legend" is not in camel caps format Open
public function Legend($aGraph)
- Exclude checks
Method name "PlotLine::SetWeight" is not in camel caps format Open
public function SetWeight($aWeight)
- Exclude checks
Method name "PlotLine::SetLineStyle" is not in camel caps format Open
public function SetLineStyle($aStyle)
- Exclude checks
Method name "_Stroke" should not be prefixed with an underscore to indicate visibility Open
public function _Stroke($aImg, $aMinX, $aMinY, $aMaxX, $aMaxY, $aXPos, $aYPos)
- Exclude checks
Method name "PlotLine::SetLegend" is not in camel caps format Open
public function SetLegend($aLegend, $aCSIM = '', $aCSIMAlt = '', $aCSIMWinTarget = '')
- Exclude checks
Method name "PlotLine::SetPosition" is not in camel caps format Open
public function SetPosition($aScalePosition)
- Exclude checks
Method name "PlotLine::SetColor" is not in camel caps format Open
public function SetColor($aColor)
- Exclude checks
Method name "PlotLine::GetCSIMAreas" is not in camel caps format Open
public function GetCSIMAreas()
- Exclude checks
Method name "PlotLine::Min" is not in camel caps format Open
public function Min()
- Exclude checks