Devreplay is static analysis tool based on your own programming rule.
- Install on local
$ npm install devreplay
# or
$ yarn global add
- Put your own programming rule(
.devreplay.json
) on the project like bellow
[
{
"before": [
"tmp = $1",
"$1 = $2",
"$2 = tmp"
],
"after": [
"$1, $2 = $2, $1"
]
}
]
- Run the devreplay
$ devreplay yourfile.py
W:yourfile.py:15:$3 = $1$1 = $2$2 = $3 should be $2, $1 = $1, $2
or get fixed code
$ devreplay --fix yourfile.py
The target source code file will be
- tmp = a
- a = b
- b = a
+ a, b = b, a
- Step up: Make the rule message and severity. Also
after
can be more abstract
[
{
"before": [
"$3 = $1",
"$1 = $2",
"$2 = $3"
],
"after": [
"$1, $2 = $2, $1"
],
"author": "Yuki Ueda",
"message": "Value exchanging can be one line",
"severity": "Information"
}
]
- Recommend: Also you can generate rule file automatically by following command on your git repository
devreplay --init
-
severity
means how this rule is importantE
: ErrorW
: WarningI
: InformationH
: Hint
-
Run devreplay again
$ devreplay yourfile.py
I:yourfile.py:15:Value exchanging can be one line by Yuki Ueda
Also, you can use default rules by extends some rules such as
[
{
"extends": ["typescript", "react", "vscode"]
}
]
{
"before": [
"([a-z]+)-([a-z]+)"
],
"after": [
"$1 $2"
],
"isRegex": true
}
That will fix
- print("hello-world")
+ print("hello world")
- c
- cpp
- dart
- cobol
- java
- javaScript
- typeScript
- python
- ruby
- go
- php
- Angular
- chainer2pytouch
- tensorflow
- rails
- vue
This package is made based on
DevReplay is supported by 2019 Exploratory IT Human Resources Project The MITOU Program, JSPS KAKENHI Grant Numbers JP17H00731, JP15H02683, JP18H03221, and JP18KT0013.
MIT © 2019 Yuki Ueda [email protected] (ikuyadeu.github.io)