Avoid Methods and Functions with lines of more than 120 characters (PHP) | CAST Appmarq

Avoid Methods and Functions with lines of more than 120 characters (PHP)


Rule Definition
For readability reasons, Functions and Methods should not contain lines with more than 120 characters.

Remediation
Modify the source code to reduce the number of Functions and Methods containing lines of more than 120 characters.

Violation Code Sample
class CastTest{
   
    var $items;
    var $Var1;
    var $Var2;
    var $Var3;
    // Add of the Item

    function add_item($artnr, $num) { $this->items[$artnr] += $num;$Var1 =$Var1+1;$Var2 =$Var2+1;$Var3 =$Var3+1;$Var2 =$Var2+1;$Var3 =$Var3+1;   }
}
Fixed Code Sample
class CastTest{
   
    var $items;
    var $Var1;
    var $Var2;
    var $Var3;
    // Add of the Item

    function add_item($artnr, $num) 
 { $this->items[$artnr] += $num;
   $Var1 =$Var1+1;
   $Var2 =$Var2+1;
   $Var3 =$Var3+1;
   $Var2 =$Var2+1;
   $Var3 =$Var3+1;   
 }
}

Related Technologies

Health Factor

  Total Quality Index


Technical Criterion
Documentation - Style Conformity

About CAST Appmarq

CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.

Benchmark Statistics

Global Compliance

77.71%

Total Violations
20,183
Total Opportunities
90,566
Average Violations / App.
403.66
The compliance score represents 1 minus the ratio between the number of times a rule has been violated compared to the number of opportunities in a set of applications that the rule could have been violated.

Industry Insights

Select from drop-down

85.43%

Telecommunications

74.52%

IT & Business Consulting

88.35%