ast-grep-cli 0.6.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ast_grep_cli-0.6.7/LICENSE +21 -0
- ast_grep_cli-0.6.7/PKG-INFO +140 -0
- ast_grep_cli-0.6.7/README.md +113 -0
- ast_grep_cli-0.6.7/crates/cli/Cargo.lock +2359 -0
- ast_grep_cli-0.6.7/crates/cli/Cargo.toml +47 -0
- ast_grep_cli-0.6.7/crates/cli/src/bin/ast-grep.rs +9 -0
- ast_grep_cli-0.6.7/crates/cli/src/config.rs +334 -0
- ast_grep_cli-0.6.7/crates/cli/src/error.rs +289 -0
- ast_grep_cli-0.6.7/crates/cli/src/lang.rs +147 -0
- ast_grep_cli-0.6.7/crates/cli/src/lib.rs +179 -0
- ast_grep_cli-0.6.7/crates/cli/src/lsp.rs +37 -0
- ast_grep_cli-0.6.7/crates/cli/src/main.rs +6 -0
- ast_grep_cli-0.6.7/crates/cli/src/new.rs +348 -0
- ast_grep_cli-0.6.7/crates/cli/src/print/colored_print.rs +750 -0
- ast_grep_cli-0.6.7/crates/cli/src/print/interactive_print.rs +265 -0
- ast_grep_cli-0.6.7/crates/cli/src/print/json_print.rs +359 -0
- ast_grep_cli-0.6.7/crates/cli/src/print/mod.rs +113 -0
- ast_grep_cli-0.6.7/crates/cli/src/run.rs +268 -0
- ast_grep_cli-0.6.7/crates/cli/src/scan.rs +283 -0
- ast_grep_cli-0.6.7/crates/cli/src/utils.rs +217 -0
- ast_grep_cli-0.6.7/crates/cli/src/verify.rs +892 -0
- ast_grep_cli-0.6.7/crates/cli/tests/common/mod.rs +21 -0
- ast_grep_cli-0.6.7/crates/cli/tests/run_test.rs +33 -0
- ast_grep_cli-0.6.7/crates/cli/tests/verify_test.rs +59 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/Cargo.toml +25 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/constraints.rs +228 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/deserialize_env.rs +260 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/lib.rs +199 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/maybe.rs +109 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/referent_rule.rs +235 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/relational_rule/mod.rs +578 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/relational_rule/stop_by.rs +167 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/rule.rs +433 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/rule_collection.rs +259 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/rule_config.rs +381 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-config/src/transform.rs +281 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/Cargo.toml +23 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/language.rs +78 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/lib.rs +157 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/match_tree.rs +511 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/matcher/kind.rs +138 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/matcher/node_match.rs +147 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/matcher/pattern.rs +356 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/matcher/text.rs +45 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/matcher.rs +244 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/meta_var.rs +389 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/node.rs +566 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/ops.rs +611 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/pinned.rs +137 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/replacer/indent.rs +403 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/replacer/structural.rs +220 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/replacer/template.rs +334 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/replacer.rs +102 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/source.rs +264 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-core/src/traversal.rs +578 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-dynamic/Cargo.toml +20 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-dynamic/src/lib.rs +263 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-language/Cargo.toml +55 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-language/src/cpp.rs +62 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-language/src/csharp.rs +58 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-language/src/css.rs +57 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-language/src/go.rs +90 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-language/src/lib.rs +313 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-language/src/parsers.rs +103 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-language/src/python.rs +139 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-language/src/rust.rs +115 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-lsp/Cargo.toml +20 -0
- ast_grep_cli-0.6.7/local_dependencies/ast-grep-lsp/src/lib.rs +384 -0
- ast_grep_cli-0.6.7/pyproject.toml +43 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Herrington Darkholme
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ast-grep-cli
|
|
3
|
+
Version: 0.6.7
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Environment :: Console
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Rust
|
|
10
|
+
Classifier: Topic :: Security
|
|
11
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
12
|
+
Classifier: Topic :: Software Development
|
|
13
|
+
Classifier: Topic :: Text Processing
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Summary: Structural Search and Rewrite code at large scale using precise AST pattern.
|
|
16
|
+
Keywords: ast,pattern,codemod,structural search,rewrite
|
|
17
|
+
Home-Page: https://ast-grep.github.io/
|
|
18
|
+
Author: Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>
|
|
19
|
+
Author-email: Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>
|
|
20
|
+
Maintainer-email: Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>
|
|
21
|
+
License: MIT
|
|
22
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
23
|
+
Project-URL: Repository, https://github.com/ast-grep/ast-grep
|
|
24
|
+
Project-URL: Documentation, https://ast-grep.github.io/
|
|
25
|
+
Project-URL: Changelog, https://github.com/ast-grep/ast-grep/blob/main/CHANGELOG.md
|
|
26
|
+
|
|
27
|
+
<p align=center>
|
|
28
|
+
<img src="https://ast-grep.github.io/logo.svg" alt="ast-grep"/>
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<img src="https://github.com/ast-grep/ast-grep/actions/workflows/coverage.yaml/badge.svg" alt="coverage badge"/>
|
|
33
|
+
<a href="https://app.codecov.io/gh/ast-grep/ast-grep"><img src="https://codecov.io/gh/ast-grep/ast-grep/branch/main/graph/badge.svg?token=37VX8H2EWV"/></a>
|
|
34
|
+
<a href="https://discord.gg/4YZjf6htSQ" target="_blank"><img alt="Discord" src="https://img.shields.io/discord/1107749847722889217?label=Discord"></a>
|
|
35
|
+
<img src="https://img.shields.io/github/stars/ast-grep/ast-grep?style=social" alt="Badge"/>
|
|
36
|
+
<img src="https://img.shields.io/github/forks/ast-grep/ast-grep?style=social" alt="Badge"/>
|
|
37
|
+
<img alt="GitHub Sponsors" src="https://img.shields.io/github/sponsors/HerringtonDarkholme?style=social">
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## ast-grep(sg)
|
|
42
|
+
|
|
43
|
+
ast-grep(sg) is a fast and polyglot tool for code structural search, lint and rewriting at large scale..
|
|
44
|
+
|
|
45
|
+
## Introduction
|
|
46
|
+
ast-grep is a AST-based tool to search code by pattern code. Think it as your old-friend `grep` but it matches AST nodes instead of text.
|
|
47
|
+
You can write patterns as if you are writing ordinary code. It will match all code that has the same syntactical structure.
|
|
48
|
+
You can use `$` sign + upper case letters as wildcard, e.g. `$MATCH`, to match any single AST node. Think it as REGEX dot `.`, except it is not textual.
|
|
49
|
+
|
|
50
|
+
Try the [online playground](https://ast-grep.github.io/playground.html) for a taste!
|
|
51
|
+
|
|
52
|
+
## Demo
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
You can install it from [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), [cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html), [homebrew](https://brew.sh/) or [scoop](https://scoop.sh/)!
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# install via npm
|
|
61
|
+
npm install --global @ast-grep/cli
|
|
62
|
+
|
|
63
|
+
# install via cargo
|
|
64
|
+
cargo install ast-grep
|
|
65
|
+
|
|
66
|
+
# install via homebrew, thank @henryhchchc
|
|
67
|
+
brew install ast-grep
|
|
68
|
+
|
|
69
|
+
# install via scoop, thank @brian6932
|
|
70
|
+
scoop install main/ast-grep
|
|
71
|
+
```
|
|
72
|
+
Or you can build ast-grep from source. You need install rustup, clone the repository and then
|
|
73
|
+
```bash
|
|
74
|
+
cargo install --path ./crates/cli
|
|
75
|
+
```
|
|
76
|
+
[Packages](https://repology.org/project/ast-grep/versions) are available on other platforms too.
|
|
77
|
+
|
|
78
|
+
## Command line usage example
|
|
79
|
+
|
|
80
|
+
ast-grep has following form.
|
|
81
|
+
```
|
|
82
|
+
sg --pattern 'var code = $PATTERN' --rewrite 'let code = new $PATTERN' --lang ts
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Example
|
|
86
|
+
|
|
87
|
+
* [Rewrite code in null coalescing operator](https://twitter.com/Hchan_mgn/status/1547061516993699841?s=20&t=ldDoj4U2nq-FRKQkU5GWXA)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
sg -p '$A && $A()' -l ts -r '$A?.()'
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
* [Rewrite](https://twitter.com/Hchan_mgn/status/1561802312846278657) [Zodios](https://github.com/ecyrbe/zodios#migrate-to-v8)
|
|
94
|
+
```bash
|
|
95
|
+
sg -p 'new Zodios($URL, $CONF as const,)' -l ts -r 'new Zodios($URL, $CONF)' -i
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
* [Implement eslint rule using YAML.](https://twitter.com/Hchan_mgn/status/1560108625460355073)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## Sponsor
|
|
102
|
+

|
|
103
|
+
|
|
104
|
+
If you find ast-grep interesting and useful for your work, please [buy me a coffee](https://github.com/sponsors/HerringtonDarkholme)
|
|
105
|
+
so I can spend more time on the project!
|
|
106
|
+
|
|
107
|
+
## Feature Highlight
|
|
108
|
+
|
|
109
|
+
ast-grep's core is an algorithm to search and replace code based on abstract syntax tree produced by tree-sitter.
|
|
110
|
+
It can help you to do lightweight static analysis and massive scale code manipulation in an intuitive way.
|
|
111
|
+
|
|
112
|
+
Key highlights:
|
|
113
|
+
|
|
114
|
+
* An intuitive pattern to find and replace AST.
|
|
115
|
+
ast-grep's pattern looks like ordinary code you would write every day. (You can call the pattern is isomorphic to code).
|
|
116
|
+
|
|
117
|
+
* jQuery like API for AST traversal and manipulation.
|
|
118
|
+
|
|
119
|
+
* YAML configuration to write new linting rules or code modification.
|
|
120
|
+
|
|
121
|
+
* Written in compiled language, with tree-sitter based parsing and utilizing multiple cores.
|
|
122
|
+
|
|
123
|
+
* Beautiful command line interface :)
|
|
124
|
+
|
|
125
|
+
ast-grep's vision is to democratize abstract syntax tree magic and to liberate one from cumbersome AST programming!
|
|
126
|
+
|
|
127
|
+
* If you are an open source library author, ast-grep can help your library users adopt breaking changes more easily.
|
|
128
|
+
* if you are a tech lead in your team, ast-grep can help you enforce code best practice tailored to your business need.
|
|
129
|
+
* If you are a security researcher, ast-grep can help you write rules much faster.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## CLI Screenshot
|
|
133
|
+
|
|
134
|
+
### Search
|
|
135
|
+
| Feature | Command | Screenshot |
|
|
136
|
+
| ------- | ------- | ---------- |
|
|
137
|
+
| Search | `sg -p 'Some($A)' -l rs` |  |
|
|
138
|
+
| Rewrite | `sg -p '$F && $F($$$ARGS)' -r '$F?.($$$ARGS)' -l ts` | |
|
|
139
|
+
| Report | `sg scan` |  |
|
|
140
|
+
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<p align=center>
|
|
2
|
+
<img src="https://ast-grep.github.io/logo.svg" alt="ast-grep"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://github.com/ast-grep/ast-grep/actions/workflows/coverage.yaml/badge.svg" alt="coverage badge"/>
|
|
7
|
+
<a href="https://app.codecov.io/gh/ast-grep/ast-grep"><img src="https://codecov.io/gh/ast-grep/ast-grep/branch/main/graph/badge.svg?token=37VX8H2EWV"/></a>
|
|
8
|
+
<a href="https://discord.gg/4YZjf6htSQ" target="_blank"><img alt="Discord" src="https://img.shields.io/discord/1107749847722889217?label=Discord"></a>
|
|
9
|
+
<img src="https://img.shields.io/github/stars/ast-grep/ast-grep?style=social" alt="Badge"/>
|
|
10
|
+
<img src="https://img.shields.io/github/forks/ast-grep/ast-grep?style=social" alt="Badge"/>
|
|
11
|
+
<img alt="GitHub Sponsors" src="https://img.shields.io/github/sponsors/HerringtonDarkholme?style=social">
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## ast-grep(sg)
|
|
16
|
+
|
|
17
|
+
ast-grep(sg) is a fast and polyglot tool for code structural search, lint and rewriting at large scale..
|
|
18
|
+
|
|
19
|
+
## Introduction
|
|
20
|
+
ast-grep is a AST-based tool to search code by pattern code. Think it as your old-friend `grep` but it matches AST nodes instead of text.
|
|
21
|
+
You can write patterns as if you are writing ordinary code. It will match all code that has the same syntactical structure.
|
|
22
|
+
You can use `$` sign + upper case letters as wildcard, e.g. `$MATCH`, to match any single AST node. Think it as REGEX dot `.`, except it is not textual.
|
|
23
|
+
|
|
24
|
+
Try the [online playground](https://ast-grep.github.io/playground.html) for a taste!
|
|
25
|
+
|
|
26
|
+
## Demo
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
You can install it from [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), [cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html), [homebrew](https://brew.sh/) or [scoop](https://scoop.sh/)!
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# install via npm
|
|
35
|
+
npm install --global @ast-grep/cli
|
|
36
|
+
|
|
37
|
+
# install via cargo
|
|
38
|
+
cargo install ast-grep
|
|
39
|
+
|
|
40
|
+
# install via homebrew, thank @henryhchchc
|
|
41
|
+
brew install ast-grep
|
|
42
|
+
|
|
43
|
+
# install via scoop, thank @brian6932
|
|
44
|
+
scoop install main/ast-grep
|
|
45
|
+
```
|
|
46
|
+
Or you can build ast-grep from source. You need install rustup, clone the repository and then
|
|
47
|
+
```bash
|
|
48
|
+
cargo install --path ./crates/cli
|
|
49
|
+
```
|
|
50
|
+
[Packages](https://repology.org/project/ast-grep/versions) are available on other platforms too.
|
|
51
|
+
|
|
52
|
+
## Command line usage example
|
|
53
|
+
|
|
54
|
+
ast-grep has following form.
|
|
55
|
+
```
|
|
56
|
+
sg --pattern 'var code = $PATTERN' --rewrite 'let code = new $PATTERN' --lang ts
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Example
|
|
60
|
+
|
|
61
|
+
* [Rewrite code in null coalescing operator](https://twitter.com/Hchan_mgn/status/1547061516993699841?s=20&t=ldDoj4U2nq-FRKQkU5GWXA)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
sg -p '$A && $A()' -l ts -r '$A?.()'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
* [Rewrite](https://twitter.com/Hchan_mgn/status/1561802312846278657) [Zodios](https://github.com/ecyrbe/zodios#migrate-to-v8)
|
|
68
|
+
```bash
|
|
69
|
+
sg -p 'new Zodios($URL, $CONF as const,)' -l ts -r 'new Zodios($URL, $CONF)' -i
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
* [Implement eslint rule using YAML.](https://twitter.com/Hchan_mgn/status/1560108625460355073)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## Sponsor
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
If you find ast-grep interesting and useful for your work, please [buy me a coffee](https://github.com/sponsors/HerringtonDarkholme)
|
|
79
|
+
so I can spend more time on the project!
|
|
80
|
+
|
|
81
|
+
## Feature Highlight
|
|
82
|
+
|
|
83
|
+
ast-grep's core is an algorithm to search and replace code based on abstract syntax tree produced by tree-sitter.
|
|
84
|
+
It can help you to do lightweight static analysis and massive scale code manipulation in an intuitive way.
|
|
85
|
+
|
|
86
|
+
Key highlights:
|
|
87
|
+
|
|
88
|
+
* An intuitive pattern to find and replace AST.
|
|
89
|
+
ast-grep's pattern looks like ordinary code you would write every day. (You can call the pattern is isomorphic to code).
|
|
90
|
+
|
|
91
|
+
* jQuery like API for AST traversal and manipulation.
|
|
92
|
+
|
|
93
|
+
* YAML configuration to write new linting rules or code modification.
|
|
94
|
+
|
|
95
|
+
* Written in compiled language, with tree-sitter based parsing and utilizing multiple cores.
|
|
96
|
+
|
|
97
|
+
* Beautiful command line interface :)
|
|
98
|
+
|
|
99
|
+
ast-grep's vision is to democratize abstract syntax tree magic and to liberate one from cumbersome AST programming!
|
|
100
|
+
|
|
101
|
+
* If you are an open source library author, ast-grep can help your library users adopt breaking changes more easily.
|
|
102
|
+
* if you are a tech lead in your team, ast-grep can help you enforce code best practice tailored to your business need.
|
|
103
|
+
* If you are a security researcher, ast-grep can help you write rules much faster.
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## CLI Screenshot
|
|
107
|
+
|
|
108
|
+
### Search
|
|
109
|
+
| Feature | Command | Screenshot |
|
|
110
|
+
| ------- | ------- | ---------- |
|
|
111
|
+
| Search | `sg -p 'Some($A)' -l rs` |  |
|
|
112
|
+
| Rewrite | `sg -p '$F && $F($$$ARGS)' -r '$F?.($$$ARGS)' -l ts` | |
|
|
113
|
+
| Report | `sg scan` |  |
|