Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

devreplay

1.4.1 • Public • Published

Devreplay

Devreplay is static analysis tool based on your own programming pattern.

How to use

  1. Install on local
$ npm install devreplay
# or 
$ yarn global add 
  1. Put your own programming pattern(devreplay.json) on the project like bellow
[
  {
    "condition": [
      "tmp = $1",
      "$1 = $2",
      "$2 = tmp"
    ],
    "consequent": [
      "$1, $2 = $2, $1"
    ]
  }
]
  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
  • Recommend: DevReplay Pattern Generator generate your pattern from .git
  • Step up: Make the pattern description and severity. Also condition can be more abstract
[
  {
    "condition": [
      "$3 = $1",
      "$1 = $2",
      "$2 = $3"
    ],
    "consequent": [
      "$1, $2 = $2, $1"
    ],
    "author": "Yuki Ueda",
    "description": "Value exchanging can be one line",
    "severity": "Information"
  }
]
  • severity means how this pattern is important

    • E: Error
    • W: Warning
    • I: Information
    • H: 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 from two files

devreplay --init targetA.py targetB.py
{
  "condition": [
    "tmp = ${1:source.python}",
    "${1:source.python} = ${2:source.python}",
    "${2:source.python} = tmp"
  ],
  "consequent": [
    "${1:source.python}, ${1:source.python} = ${2:source.python}, ${1:source.python}"
  ],
  "identifiers": [
    "a",
    "b",
  ]
}

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 ueda.yuki.un7@is.naist.jp (ikuyadeu.github.io)

Install

npm i devreplay

DownloadsWeekly Downloads

255

Version

1.4.1

License

MIT

Unpacked Size

93.8 kB

Total Files

72

Last publish

Collaborators

  • avatar