Devreplay
Devreplay is static analysis tool based on your own programming pattern.
How to use
- Install on local
$ npm install devreplay
# or
$ yarn global add
- Put your own programming pattern(
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 pattern 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 pattern file automatically by following command on your git repository
devreplay --init
-
severity
means how this pattern 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"]
}
]
Make patterns by using Regular Expression
{
"before": [
"([a-z]+)-([a-z]+)"
],
"after": [
"$1 $2"
],
"regex": true
}
That will fix
- print("hello-world")
+ print("hello world")
Default rule languages
- c
- cpp
- dart
- cobol
- java
- javaScript
- typeScript
- python
- ruby
- go
- php
Defaulr rule frameworks
- Angular
- chainer2pytouch
- tensorflow
- rails
- vue
Contribution Link
Thanks
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.
License
MIT © 2019 Yuki Ueda [email protected] (ikuyadeu.github.io)