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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nikic/php-parser to make counter reliable, make use of lines-of-code #26

Merged
merged 12 commits into from
Aug 4, 2023
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,101 @@ composer require tomasvotruba/lines --dev
vendor/bin/lines measure src
```

For short output:

```bash
vendor/bin/lines measure src --short
```

For json output, just add `--json`:

```bash
vendor/bin/lines measure src --json
```

## The Measured Items

For the text output, you'll get data like these:

```bash
------------------------------ ---------------------
Metric Count
------------------------------ ---------------------
Directories 9
Files 14
------------------------------ ---------------------

------------------------------ ---------- ----------
Lines of code Count Relative
------------------------------ ---------- ----------
Code 1 059 95.8 %
Comments 46 4.2 %
Total 1 105 100 %
------------------------------ ---------- ----------

------------------------------ ---------------------
Structure Count
------------------------------ ---------------------
Namespaces 10
Classes 13
* Constants 0
* Methods 78
Interfaces 1
Traits 0
Enums 0
Functions 3
Global constants 3
------------------------------ ---------------------

------------------------------ ---------- ----------
Methods Count Relative
------------------------------ ---------- ----------
Non-static 74 94.9 %
Static 4 5.1 %
------------------------------ ---------- ----------
Public 60 76.9 %
Protected 4 5.1 %
Private 14 17.9 %
------------------------------ ---------- ----------
```

Or in a json format:

```json
{
"filesystem": {
"directories": 9,
"files": 14
},
"lines_of_code": {
"code": 1059,
"code_relative": 95.8,
"comments": 46,
"comments_relative": 4.2,
"total": 1105
},
"structure": {
"namespaces": 10,
"classes": 13,
"class_methods": 78,
"class_constants": 0,
"interfaces": 1,
"traits": 0,
"enums": 0,
"functions": 3,
"global_constants": 3
},
"methods": {
"non_static": 74,
"non_static_relative": 94.9,
"static": 4,
"static_relative": 5.1,
"public": 60,
"public_relative": 76.9,
"protected": 4,
"protected_relative": 5.1,
"private": 14,
"private_relative": 17.9
}
}
```
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"symfony/finder": "^6.3",
"illuminate/container": "^10.16",
"webmozart/assert": "^1.11",
"nikic/php-parser": "^4.16"
"nikic/php-parser": "^4.16",
"sebastian/lines-of-code": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^10.2",
Expand Down
Loading