Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhpMetrics v2.4.1 PHP Warning: Division by zero #379

Closed
muhagunghidayat opened this issue Aug 28, 2019 · 4 comments
Closed

PhpMetrics v2.4.1 PHP Warning: Division by zero #379

muhagunghidayat opened this issue Aug 28, 2019 · 4 comments
Assignees

Comments

@muhagunghidayat
Copy link

Hi,

Thank you for taking the time to report this bug 馃憤

Run phpmetrics --version to get the version of PhpMetrics.

The latest version of PhpMetrics is v2.4.1. Please try to update PhpMetrics and check if the bug persist before submitting new issue.

Here is a template for your issue. Please replace the words between braces with the right informations.


Hi,

I've installed PhpMetrics {version} {with composer | as phar archive}.

PhpMetrics v2.4.1 http://www.phpmetrics.org
by Jean-Fran莽ois L茅pine https://twitter.com/Halleck45

When I run this command:

php ./bin/phpmetrics --report-html=./myreport7 ./src/82files

I get this output:

Executing system analyzes...

PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 137
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 138
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 139
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 140
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 141
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 142
LOC
    Lines of code                               0
    Logical lines of code                       0
    Comment lines of code                       0
    Average volume                              0
    Average comment weight                      0
    Average intelligent content                 0
    Logical lines of code by class              0
    Logical lines of code by method             0

Object oriented programming
    Classes                                     0
    Interface                                   0
    Methods                                     0
    Methods by class                            0
    Lack of cohesion of methods                 0
    
Coupling
    Average afferent coupling                   0
    Average efferent coupling                   0
    Average instability                         0
    Depth of Inheritance Tree                   0
    
Package
    Packages                                    0
    Average classes per package                 NAN
    Average distance                            NAN
    Average incoming class dependencies         NAN
    Average outgoing class dependencies         NAN
    Average incoming package dependencies       NAN
    Average outgoing package dependencies       NAN

Complexity
    Average Cyclomatic complexity by class      0
    Average Weighted method count by class      0
    Average Relative system complexity          0
    Average Difficulty                          0
    
Bugs
    Average bugs by class                       0
    Average defects by class (Kan)              0

Violations
    Critical                                    0
    Error                                       0
    Warning                                     0
    Information                                 0


PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 137
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 138
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 139
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 140
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 141
PHP Warning:  Division by zero in /home/agung/phpmetrics/vendor/phpmetrics/phpmetrics/src/Hal/Metric/Consolidated.php on line 142

HTML report generated in "./myreport7" directory

Done

I don't know why phpmetrics cannot analyze my files

Thanks

@niconoe-
Copy link
Contributor

With my fix (only in PR), there is no more warnings, but I tried to parse an empty folder to reproduice. If your problem is actually PhpMetrics being unable to read your files, could you please share your "src/82files" content?

Otherwise, assuming this will be fixed.

Thanks a lot.
Regards,

@muhagunghidayat
Copy link
Author

muhagunghidayat commented Dec 24, 2019

@niconoe-
Copy link
Contributor

I can see that your project only contains PHP snippets without any classes nor any OOP objects. PhpMetrics is intended for projects with usages of packages, namespaces, classes, interfaces, and other structures like that.
The only metrics we could fetch from your project is the number of lines of code (total, logical and comments), but as they are not in classes, they will not be included in the reports.

If this is still a metrics you want to know about your project, I recommend you to use instead phploc from Sebastian Bergmann as it does the exact same thing PhpMetrics can offer you, as long as you don't use classes.

If you will to use classes, everything will be fine with PhpMetrics, as the following example shows you:

class F019
{
    public function __construct()
    {
        //[Your content of the file in "019" folder here]
    }
}

Results:

LOC
    Lines of code                               56
    Logical lines of code                       15
    Comment lines of code                       41
    Average volume                              105.49
    Average comment weight                      48.5
    Average intelligent content                 48.5
    Logical lines of code by class              15
    Logical lines of code by method             15

Object oriented programming
    Classes                                     1
    Interface                                   0
    Methods                                     1
    Methods by class                            1
    Lack of cohesion of methods                 1
    
Coupling
    Average afferent coupling                   0
    Average efferent coupling                   0
    Average instability                         0
    Depth of Inheritance Tree                   1
    
Package
    Packages                                    1
    Average classes per package                 1
    Average distance                            0
    Average incoming class dependencies         0
    Average outgoing class dependencies         0
    Average incoming package dependencies       0
    Average outgoing package dependencies       0

Complexity
    Average Cyclomatic complexity by class      1
    Average Weighted method count by class      1
    Average Relative system complexity          9
    Average Difficulty                          0.79
    
Bugs
    Average bugs by class                       0.04
    Average defects by class (Kan)              0.15

Violations
    Critical                                    0
    Error                                       0
    Warning                                     0
    Information                                 0

I hope this is clearer for you now 馃槂

Have a nice day.
Regards,

@Halleck45
Copy link
Collaborator

@muhagunghidayat I close this issue. Feel free to reopen it if you need more informations :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants