Commit 3ea9d49
Simon Renoult
feat: v4.0.0
With the addition of the `json` format, I chose to make the default
output
cleaner. It is way easier to read this way! \o/
Note that this format is also available using the `--format=table` flag.
It looks like this:
```shell script
$ npx code-complexity . --sort=ratio --limit=3
┌──────────────────────────────┬────────────┬───────┬───────┐
│ file │ complexity │ churn │ ratio │
├──────────────────────────────┼────────────┼───────┼───────┤
│ src/cli.ts │ 103 │ 8 │ 824 │
├──────────────────────────────┼────────────┼───────┼───────┤
│ test/code-complexity.test.ts │ 107 │ 7 │ 749 │
├──────────────────────────────┼────────────┼───────┼───────┤
│ .idea/workspace.xml │ 123 │ 6 │ 738 │
└──────────────────────────────┴────────────┴───────┴───────┘
```
While handy, this solution was a rather naive approach to filtering.
I've removed them in favor of a `--filter` flag supporting globs. The
implementation is using [micromatch][1].
Example:
```shell script
$ npx code-complexity . --filter='!test/**','src/*.ts'
```
While interesting, these flags were not adding much value since you
usually want
to list the highest ratio/churn/complexity values. A combination of
`--sort=ratio` and `--limit=5` would usually do the trick.
They'd be interesting if min/max could be targeted on a metric (eg:
`ratio`,
`churn` or `complexity`). But since they were only targeting `ratios`, I
don't
see them adding much value. And they add more code to maintain.
I'll add an issue about adding them back and wait to see if it gets
traction.
The new `table` stdout is clearer to read and already show these
information
so we don't need these flags anymore. Yay, less code to maintain!
Using `--first-parent` was causing problems where `git log` would not
output
all the files. Using `no-first-parent` is now the default.
With the addition of the `json` support, I chose to make the `text`
output
a bit more opinionated. Metrics like `complexity`, `churn` and `ratio`
will
always be shown from now on.
See `--format`.
I've added this flag to support more output format. It currently allows
`table`
and `json`.
The `table` format is the default one.
The `json` format will ease integration with other softwares.
Example with `--format=table`:
```shell script
$ npx code-complexity . --sort=ratio --limit=3
┌──────────────────────────────┬────────────┬───────┬───────┐
│ file │ complexity │ churn │ ratio │
├──────────────────────────────┼────────────┼───────┼───────┤
│ src/cli.ts │ 103 │ 8 │ 824 │
├──────────────────────────────┼────────────┼───────┼───────┤
│ test/code-complexity.test.ts │ 107 │ 7 │ 749 │
├──────────────────────────────┼────────────┼───────┼───────┤
│ .idea/workspace.xml │ 123 │ 6 │ 738 │
└──────────────────────────────┴────────────┴───────┴───────┘
```
Example with `--format=json`:
```sh
$ npx code-complexity . --format=json --limit=3
[{"path":"bin/code-complexity.ts","churn":1,"complexity":6,"ratio":6},{"path":".eslintignore","churn":1,"complexity":1,"ratio":1},{"path":".eslintrc.js","churn":1,"complexity":19,"ratio":19}]
```
I'm also thinking about an `html` format in order to display a
complexity/churn
graph but it's a bit of work so I'm not sure when that will lend.
As mentioned above, it replaces both `--excludes` and `--includes` whil
adding
glob support using [micromatch][1]. Good job me!
If you're interested in metrics and what's going on without having to
look at the
source code, you can use the `DEBUG=*` environment variable.
[1]: https://www.npmjs.com/package/micromatch1 parent df98adc commit 3ea9d49
File tree
23 files changed
+1217
-822
lines changed- bin
- src
- io
- lib
- services
- test
- lib
23 files changed
+1217
-822
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
41 | 35 | | |
42 | 36 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
49 | 40 | | |
50 | 41 | | |
51 | 42 | | |
52 | 43 | | |
53 | 44 | | |
54 | | - | |
| 45 | + | |
55 | 46 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
63 | 56 | | |
64 | 57 | | |
65 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments