Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 1817756

Browse files
Merge pull request #6 from codiga/feat/analyze-command
analyze command
2 parents 22aaf33 + abe48c0 commit 1817756

27 files changed

Lines changed: 1372 additions & 712 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
coverage
33
.vscode
4-
codiga-cli*.tgz
4+
codiga-cli*.tgz
5+
.DS_store

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,62 @@ If you know what rulesets you want to add, you can pass their names into the com
7070
codiga ruleset-add my-public-ruleset my-private-ruleset
7171
```
7272

73+
### Analyze and report issues for a file or directory
74+
75+
#### Single File
76+
77+
To analyze a single file named `file.js` you can could run the following commands. The first command would analyze `file.js` for violations with the rules found in `foo-ruleset` and the second command would include the rules from `bar-ruleset` too.
78+
79+
```bash
80+
codiga analyze file.js --ruleset foo-ruleset
81+
```
82+
83+
```bash
84+
codiga analyze file.js --ruleset foo-ruleset --ruleset bar-ruleset
85+
```
86+
87+
> When analyzing a single file, a valid ruleset must be set using the `--ruleset` option.
88+
89+
#### Directory
90+
91+
To analyze a directory and all the files within, you could run any of the following commands to target the directory `foo`.
92+
93+
```bash
94+
codiga analyze foo
95+
```
96+
97+
```bash
98+
codiga analyze ./foo
99+
```
100+
101+
```bash
102+
codiga analyze /Users/cool-name/foo
103+
```
104+
105+
When analyzing a directory it isn't necessary to specify a ruleset using `--ruleset`, **if** you have a `codiga.yml` file in the targeted directory. If there isn't a `codiga.yml` and you haven't specified rulesets in the command, the analyze will exit.
106+
107+
> You can find rulesets to use on the [Codiga Hub](https://app.codiga.io/hub/rulesets) or you can use a command introduced above `codiga ruleset-add` to create a `codiga.yml` quickly.
108+
109+
#### Options
110+
111+
- `-r/--ruleset`
112+
- Specify the rulesets you want your analysis done with
113+
- **Required:** when analyzing a single file or when there isn't a `codiga.yml` in the root targeted directory
114+
- **Default:** `codiga.yml`
115+
- **Notes:** if set, will override a `codiga.yml`
116+
- `-f/--format`
117+
- Specify the format you want your analysis reported in
118+
- **Options:** `text`, `json`, `csv`
119+
- **Default:** `text`
120+
- `-o/--output`
121+
- Specify where you want your analysis reported to
122+
- **Default:** `stdout`
123+
- **Examples:** `results.csv`, `violations.json`, `analysis.text`
124+
- **Notes:** If there are no violations, no file will be created.
125+
- `--follow-symlinks`
126+
- Specify if you want to follow and analyze symbolic links
127+
- **Default:** false
128+
73129
### Analysis and report issues between two commits
74130

75131
Use the command below to detect any violations between your two commits.

codiga.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
rulesets:
2+
- jestjs
3+
- javascript-client-security
4+
- javascript-inclusive
5+
- javascript-best-practices

jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
*/
55

66
module.exports = {
7+
moduleNameMapper: {
8+
"^csv-stringify/dist/esm/sync":
9+
"<rootDir>/node_modules/csv-stringify/dist/cjs/sync",
10+
},
711
// All imported modules in your tests should be mocked automatically
812
// automock: false,
913

0 commit comments

Comments
 (0)