You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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/micromatch
0 commit comments