Giter VIP home page Giter VIP logo

synt's Introduction

synt Circle CI Windows Build status npm version

Find similar functions and classes in your JavaScript/TypeScript code.

demo image

Supported Languages

System Requirements

Installation & Usage

npm i synt

CLI

install

npm i -g synt

help

synt -h

example

git clone https://github.com/brentlintner/synt.git
cd synt
synt analyze src

Library

example

const synt = require("synt")

const files = [ "a.js", "b.ts" ]

const { js, ts } = synt.compare(files, {
  similarity: 80,
  ngram: 1,
  minLength: 20,
  sourceType: "module",
  ecmaVersion: 6
})

synt.print(js)

synt.print(ts)

Licensing

This project is licensed under the MPL-2.0 license.

Any contributions made to this project are made under the current license.

Contributing

Any contributions are welcome and appreciated!

Please see CONTRIBUTING.md for more info.

Versioning

This project ascribes to semantic versioning.

Name

synt is short for synteny, and is an (attempted) play on comparing code evolution to genetic (evolution).

synt's People

Contributors

brentlintner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

synt's Issues

Fails with really large files.

Ex:

Compare minor jQuery versions to each other, and runs out of memory.

Need to either finish, then port to a faster lang, or incorporate some sort of piece by piece (file storage) method, or something I don't know about.

[Ruby] [ShellJS] Double logging issue?

~/src$ synt -c synt/ruby/lib/synt/similar/tanimoto.rb -t synt/ruby/lib/synt/similar/jaccard.rb -l rb -n all
Inputs are %45.24 similar.
Inputs are %45.24 similar.
~/src$ sudo npm uninstall -g synt
Password:
unbuild [email protected]
~/src$ sudo npm install -g synt
/usr/local/bin/synt -> /usr/local/lib/node_modules/synt/bin/cli

> [email protected] postinstall /usr/local/lib/node_modules/synt
> npm run compile && bin/bundle-rb-gems


> [email protected] compile /usr/local/lib/node_modules/synt
> bin/compile

Using manowar 0.0.1
Using slop 3.6.0
Using bundler 1.7.4
Your bundle is complete!
Gems in the group development were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
You are replacing the current local value of without, which is currently "development"
[email protected] /usr/local/lib/node_modules/synt
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected])
~/src$ synt -c synt/ruby/lib/synt/similar/tanimoto.rb -t synt/ruby/lib/synt/similar/jaccard.rb -l rb -n all
Inputs are %45.24 similar.
~/src$ synt -c synt/ruby/lib/synt/similar/tanimoto.rb -t synt/ruby/lib/synt/similar/jaccard.rb -l rb -n all
Inputs are %45.24 similar.
Inputs are %45.24 similar.

v1.x.x

  • Stable and fully tested code bases
  • Website and Docs are sufficient
  • API is set in stone
  • Support for Tree structure comparison (vs single dimensional arrays)? (convenient)

Post as a Client lib.

  • Put up on various registries. Bower?
  • Make sure all works client side, and are wrapped as AMD/CommonJS modules.

Add CoffeeScript support?

  • Is this really needed?
  • Is not comparing the compiled JavaScript the same (or close)?
  • Else, generate a CS tokenized list or ast graph
  • Set appropriate syntax weights (if applicable)

Latin language matching?

Lol, a sort of side, but:

You could score against words, sentences. I.e. -l natural

Probably a fun exercise rather than helpful.

What to do ultimately about Ruby and Test Coverage.

Ruby support is currently slower.

Might as well just write it in Ruby for that support. Not that much, and testing and coverage all works, and no overhead between shelljs.

Stuff like HTML/CSS could be done in CS, but even Haskell could be done in itself.

That way, a Gem can be made, etc.

Note: Perhaps the CS library can still be the go to, and bridge to gem, etc, yet recommend those in favour if you are strictly dealing in that language. (or even just keep one-to-one CLIs/libs and map through a sh script?).

[NPM] Install without Bundler shows a Ruby Exception.

This may be a UX issue, and make users think the package did not successfully install, when in fact it does:

~/src/manowar(master)$ sudo npm install -g synt
/usr/local/bin/synt -> /usr/local/lib/node_modules/synt/bin/cli

> [email protected] postinstall /usr/local/lib/node_modules/synt
> npm run compile && (cd ruby && (bundle --without development && bundle config --local without '') || true) && cd ../


> [email protected] compile /usr/local/lib/node_modules/synt
> bin/compile

/Users/brent/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'bundler' (>= 0) among 13 total gem(s) (Gem::LoadError)
    from /Users/brent/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
    from /Users/brent/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
    from /Users/brent/.rvm/gems/ruby-2.1.2/bin/bundle:22:in `<main>'
    from /Users/brent/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/brent/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
[email protected] /usr/local/lib/node_modules/synt
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected])

Workaround: (in README) use: rvmsudo npm install -g synt

Finish tests.

  • Add system tests for perf.
  • Add code coverage.
  • Add any other necessary tests.

Should JS files be committed?

Pros:

  • Speeds up install (no compiling of CoffeeScript).
  • Removes CoffeeScript as a runtime dependency.

Cons:

  • Compiled files could mistakenly be slightly dated (ex: during rebase and you don't compile to fix a trivial thing)
  • Adds duplicate bloat to the repo, and could be confusing.

Compromise?

  • Create a deploy script that either compiles and fails to publish if git changes, or compiles, commits JS files alongside package.json update.

This still sucks as JS files won't match CS files until a release..

Windows Support

A lot of setup/compile scripts presume shell/bash/sudo exists.

Might not be the case for Windows (out of the box).

Need to look into this more, maybe switch to Gulp or something.

Testing sort of sucks right now.

We need a lot more integration/unit focused tests, and also system level tests for the CLI portion of the app (including shelling out to rb/hs ports).

Currently the coverage is a false positive, since some modules are not included.

Haskell support on OSX Yosemite fails.

Having issues. Need to look into more.

~/src/synt/haskell(haskell)$ cabal install
Resolving dependencies...
Configuring haskell-src-exts-1.16.0.1...
cabal: The program 'happy' version >=1.17 is required but the version of
/Users/brent/src/synt/haskell/.cabal-sandbox/bin/happy could not be
determined.
Failed to install haskell-src-exts-1.16.0.1
cabal: Error: some packages failed to install:
haskell-src-exts-1.16.0.1 failed during the configure step. The exception was:
ExitFailure 1
synt-0.1.0 depends on haskell-src-exts-1.16.0.1 which failed to install.

Which, apparently you can get around with installing it globally:

Linking dist/build/happy/happy ...
ld: warning: ignoring file /Users/brent/.cabal/lib/transformers-0.4.1.0/ghc-7.8.3/libHStransformers-0.4.1.0.a, file was built for archive which is not the architecture being linked (x86_64): /Users/brent/.cabal/lib/transformers-0.4.1.0/ghc-7.8.3/libHStransformers-0.4.1.0.a
Installing executable(s) in /Users/brent/.cabal/bin
BFD: unable to read unknown load command 0x2a
BFD: unable to read unknown load command 0x28
BFD: unable to read unknown load command 0x29
BFD: unable to read unknown load command 0x2b
Installed happy-1.19.4

Then:

~/src/synt(haskell)$ happy
bash: /Users/brent/.cabal/bin/happy: Bad CPU type in executable

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.