|
1 | | -# codehawk-cli |
| 1 | +# Codehawk CLI |
2 | 2 |
|
3 | 3 | Codehawk is a static analysis tool for JavaScript projects. It is intended as a warning system, to identify complex areas of code that need special attention by developers. |
4 | 4 |
|
5 | | -JavaScript, TypeScript and Flow projects are supported for analysis. The CLI tool supports unix and windows filesystems (there is a reasonable amount of Windows compatibility code). It works by traversing a directory and discovering all supported filetypes, runs a static analysis routine on each file, then performs project-wide analysis such as inter-dependency counting and test coverage mapping. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +## Scope |
| 9 | + |
| 10 | +*JavaScript, TypeScript and Flow* projects are supported for analysis. The CLI tool supports unix and windows filesystems (there is a reasonable amount of Windows compatibility code). |
| 11 | + |
| 12 | +It works by traversing a directory and discovering all supported filetypes, runs a static analysis routine on each file, then performs project-wide analysis such as inter-dependency counting and test coverage mapping. |
6 | 13 |
|
7 | 14 | The CLI runs as a Node.js process. Node.js >=12 is recommended, but >=10 should also work. <10 is unsupported. |
8 | 15 |
|
@@ -31,14 +38,23 @@ Also see [an example using Next.js](https://github.com/sgb-io/codehawk-cli-examp |
31 | 38 |
|
32 | 39 | ```markdown |
33 | 40 | Codehawk Static Analysis Results |
34 | | -Top 4 files |
35 | | - |
36 | | -| File | # of Lines | Times Used/Depended On | Maintainability (higher is better) | |
37 | | -| ------------------------------ | ---------- | ---------------------- | ---------------------------------- | |
38 | | -| complex-utils.js | 99 | 1 | 50.76 (Could be better) | |
39 | | -| typescript-sample.ts | 11 | 1 | 70.73 OK | |
40 | | -| index.js | 209 | 1 | 89.94 OK | |
41 | | -| hello.js | 6 | 1 | 91.93 OK | |
| 41 | +Top 14 files |
| 42 | + |
| 43 | +| File | # of Lines | Times Used/Depended On | Maintainability (higher is better) | |
| 44 | +| -------------------------------------------------- | ---------- | ---------------------- | ---------------------------------- | |
| 45 | +| /test/codehawk.test.js | 149 | 1 | 45.3 (Needs improvement) | |
| 46 | +| /src/util.ts | 143 | 4 | 47.26 (Needs improvement) | |
| 47 | +| /src/codehawk.ts | 122 | 2 | 47.94 (Needs improvement) | |
| 48 | +| /src/options.ts | 72 | 2 | 52.64 (Could be better) | |
| 49 | +| /src/analyze.ts | 67 | 3 | 54.04 (Could be better) | |
| 50 | +| /src/cli-util.ts | 63 | 2 | 54.68 (Could be better) | |
| 51 | +| /src/traverseProject.ts | 51 | 2 | 56.91 (Could be better) | |
| 52 | +| /src/reporters/escomplex.ts | 43 | 2 | 57.44 (Could be better) | |
| 53 | +| /src/badge.ts | 45 | 2 | 58.09 (Could be better) | |
| 54 | +| /test/options.test.js | 47 | 1 | 58.55 (Could be better) | |
| 55 | +| /src/dependencies.ts | 40 | 2 | 58.7 (Could be better) | |
| 56 | +| /src/coverage.ts | 21 | 2 | 60.75 OK | |
| 57 | +| /src/index.ts | 20 | 1 | 60.97 OK | |
42 | 58 | ``` |
43 | 59 |
|
44 | 60 | ## Advanced usage |
@@ -99,7 +115,7 @@ To customise your analysis, use the following options, placed in a `codehawk.jso |
99 | 115 | | Option | Description | Default | |
100 | 116 | |----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------| |
101 | 117 | | `enableFlow` | Enable Flow support | `false` | |
102 | | -| `extensions` | File extensions that should be analyzed. The default is always used, but you can add more extensions. Use the `exclude` option to skip any of the default extensions. | `['.js', '.jsx', '.ts', '.tsx']` | |
| 118 | +| `extensions` | File extensions that should be analyzed. The default is always used, but you can add more extensions. You can use the `exclude[...]` options to exclude specific files. | `['.js', '.jsx', '.ts', '.tsx']` | |
103 | 119 | | `excludeFilenames` | Filename matches that should be excluded from analysis. The default is always used, but you can add more matches to be excluded. Note that the matching is exact. The exclude list is taken into consideration after the extension list. | `['.d.ts', '.min.js', '.bundle.js']` | |
104 | 120 | | `excludeDirectories` | Directory matches that should be excluded from analysis. Relative to the root. E.g. `['/fixtures', '/test']` | `['/dist', '/bin', '/build']` | |
105 | 121 | | `skipDirectories` | Directories that should be excluded completely. The defaults will always be skipped. | `['/node_modules', '/flow-typed', '/coverage']` | |
|
0 commit comments