librenms/librenms

View on GitHub
LibreNMS/Billing.php

Summary

Maintainability
F
3 days
Test Coverage

File Billing.php has 391 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace LibreNMS;

use DateTime;
Severity: Minor
Found in LibreNMS/Billing.php - About 5 hrs to fix

    Method getBitsGraphData has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getBitsGraphData($bill_id, $from, $to, $reducefactor): array
        {
            $i = '0';
            $iter = 0;
            $first = null;
    Severity: Major
    Found in LibreNMS/Billing.php - About 3 hrs to fix

      The class Billing has an overall complexity of 59 which is very high. The configured complexity threshold is 50.
      Open

      class Billing
      {
          public static function formatBytes($value): string
          {
              return Number::formatBase($value, Config::get('billing.base'));
      Severity: Minor
      Found in LibreNMS/Billing.php by phpmd

      Method getBandwidthGraphData has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function getBandwidthGraphData($bill_id, $bill_hist_id, $from, $to, $imgtype): ?array
          {
              if (is_numeric($bill_hist_id)) {
                  $histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`, rate_95th, rate_average FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', [$bill_id, $bill_hist_id]);
      
      
      Severity: Major
      Found in LibreNMS/Billing.php - About 2 hrs to fix

        Function getBandwidthGraphData has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function getBandwidthGraphData($bill_id, $bill_hist_id, $from, $to, $imgtype): ?array
            {
                if (is_numeric($bill_hist_id)) {
                    $histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`, rate_95th, rate_average FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', [$bill_id, $bill_hist_id]);
        
        
        Severity: Minor
        Found in LibreNMS/Billing.php - About 2 hrs to fix

        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 getHistoricTransferGraphData has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getHistoricTransferGraphData($bill_id): array
            {
                $i = '0';
        
                $in_data = [];
        Severity: Minor
        Found in LibreNMS/Billing.php - About 1 hr to fix

          Function getBitsGraphData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function getBitsGraphData($bill_id, $from, $to, $reducefactor): array
              {
                  $i = '0';
                  $iter = 0;
                  $first = null;
          Severity: Minor
          Found in LibreNMS/Billing.php - About 1 hr to fix

          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 getDates has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getDates($dayofmonth, $months = 0): array
              {
                  $dayofmonth = zeropad($dayofmonth);
                  $year = date('Y');
                  $month = date('m');
          Severity: Minor
          Found in LibreNMS/Billing.php - About 1 hr to fix

            Method getRates has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function getRates($bill_id, $datefrom, $dateto, $dir_95th): array
                {
                    $data = [];
            
                    $sum_data = self::getSum($bill_id, $datefrom, $dateto);
            Severity: Minor
            Found in LibreNMS/Billing.php - About 1 hr to fix

              Method getBandwidthGraphData has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public static function getBandwidthGraphData($bill_id, $bill_hist_id, $from, $to, $imgtype): ?array
              Severity: Minor
              Found in LibreNMS/Billing.php - About 35 mins to fix

                The method getBitsGraphData() has 101 lines of code. Current threshold is set to 100. Avoid really long methods.
                Open

                    public static function getBitsGraphData($bill_id, $from, $to, $reducefactor): array
                    {
                        $i = '0';
                        $iter = 0;
                        $first = null;
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                The method getBandwidthGraphData() has an NPath complexity of 280. The configured NPath complexity threshold is 200.
                Open

                    public static function getBandwidthGraphData($bill_id, $bill_hist_id, $from, $to, $imgtype): ?array
                    {
                        if (is_numeric($bill_hist_id)) {
                            $histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`, rate_95th, rate_average FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', [$bill_id, $bill_hist_id]);
                
                
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                NPathComplexity

                Since: 0.1

                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                Example

                class Foo {
                    function bar() {
                        // lots of complicated code
                    }
                }

                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                The method getBitsGraphData() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                Open

                    public static function getBitsGraphData($bill_id, $from, $to, $reducefactor): array
                    {
                        $i = '0';
                        $iter = 0;
                        $first = null;
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                The method getBandwidthGraphData() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
                Open

                    public static function getBandwidthGraphData($bill_id, $bill_hist_id, $from, $to, $imgtype): ?array
                    {
                        if (is_numeric($bill_hist_id)) {
                            $histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`, rate_95th, rate_average FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', [$bill_id, $bill_hist_id]);
                
                
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                Missing class import via use statement (line '407', column '27').
                Open

                                throw new \Exception('Must supply from and to if bill_hist_id is not supplied');
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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 getLastPortCounter uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $return['state'] = 'failed';
                        }
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                The method getBandwidthGraphData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            if (! is_numeric($from) || ! is_numeric($to)) {
                                throw new \Exception('Must supply from and to if bill_hist_id is not supplied');
                            }
                        }
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                The method getLastMeasurement uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $return['state'] = 'failed';
                        }
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                The method getRates uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            if ($data['rate_95th_out'] > $data['rate_95th_in']) {
                                $data['rate_95th'] = $data['rate_95th_out'];
                                $data['dir_95th'] = 'out';
                            } else {
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                The method getRates uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $data['rate_95th'] = $data['rate_95th_in'];
                                $data['dir_95th'] = 'in';
                            }
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                The method getDates uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            // Billing day will happen this month, therefore started last month
                            $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
                            $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
                            date_sub($date_start, date_interval_create_from_date_string('1 month'));
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                The method getBandwidthGraphData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            exit("Unknown graph type $imgtype");
                        }//end if
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                The method getBandwidthGraphData() contains an exit expression.
                Open

                            exit("Unknown graph type $imgtype");
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                ExitExpression

                Since: 0.2

                An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                Example

                class Foo {
                    public function bar($param)  {
                        if ($param === 42) {
                            exit(23);
                        }
                    }
                }

                Source https://phpmd.org/rules/design.html#exitexpression

                Avoid unused parameters such as '$port'.
                Open

                    public static function getValue($host, $port, $id, $inout): int
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    private static function get95thout($bill_id, $datefrom, $dateto): float
                    {
                        $mq_sql = 'SELECT count(delta) FROM bill_data WHERE bill_id = ?';
                        $mq_sql .= ' AND timestamp > ? AND timestamp <= ?';
                        $measurements = dbFetchCell($mq_sql, [$bill_id, $datefrom, $dateto]);
                Severity: Major
                Found in LibreNMS/Billing.php and 2 other locations - About 3 hrs to fix
                LibreNMS/Billing.php on lines 126..139
                LibreNMS/Billing.php on lines 141..154

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 148.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    private static function get95thIn($bill_id, $datefrom, $dateto): float
                    {
                        $mq_sql = 'SELECT count(delta) FROM bill_data WHERE bill_id = ?';
                        $mq_sql .= ' AND timestamp > ? AND timestamp <= ?';
                        $measurements = dbFetchCell($mq_sql, [$bill_id, $datefrom, $dateto]);
                Severity: Major
                Found in LibreNMS/Billing.php and 2 other locations - About 3 hrs to fix
                LibreNMS/Billing.php on lines 126..139
                LibreNMS/Billing.php on lines 156..169

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 148.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    private static function get95thagg($bill_id, $datefrom, $dateto): float
                    {
                        $mq_sql = 'SELECT count(delta) FROM bill_data WHERE bill_id = ?';
                        $mq_sql .= ' AND timestamp > ? AND timestamp <= ?';
                        $measurements = dbFetchCell($mq_sql, [$bill_id, $datefrom, $dateto]);
                Severity: Major
                Found in LibreNMS/Billing.php and 2 other locations - About 3 hrs to fix
                LibreNMS/Billing.php on lines 141..154
                LibreNMS/Billing.php on lines 156..169

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 148.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Avoid variables with short names like $to. Configured minimum length is 3.
                Open

                    public static function getBitsGraphData($bill_id, $from, $to, $reducefactor): array
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                Avoid variables with short names like $y. Configured minimum length is 3.
                Open

                            $y = (12 - $i);
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                Avoid variables with short names like $id. Configured minimum length is 3.
                Open

                    public static function getValue($host, $port, $id, $inout): int
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                Avoid variables with short names like $i. Configured minimum length is 3.
                Open

                        $i = '0';
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                Avoid variables with short names like $i. Configured minimum length is 3.
                Open

                        $i = '0';
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                Avoid variables with short names like $to. Configured minimum length is 3.
                Open

                    public static function getBandwidthGraphData($bill_id, $bill_hist_id, $from, $to, $imgtype): ?array
                Severity: Minor
                Found in LibreNMS/Billing.php by phpmd

                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

                There are no issues that match your filters.

                Category
                Status