Skip to content
/ kiss Public

The tool calculates arity, depth, and statement count for every function in a given project. The result is output as a .csv file.

License

Notifications You must be signed in to change notification settings

ch3rn0v/kiss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KISS

The tool calculates arity and statement count for every function in a given project. The result is output as a .csv file with the following columns:

Identifier, Arity, Max Depth, Statements Count, File Path

The tool makes use of Semantic's json output. (Because as of now, Semantic isn't published to hackage yet).

It supports all the languages that Semantic supports

How to Build AST in JSON

Before one can run KISS, it's required to first have an AST to analyze. KISS expects one in particular json format, the one that Semantic outputs.

  1. Pull Semantic's container.

  2. Run it, passing a command like this:

docker run -v /root/path/to/a/project:/r --entrypoint sh semantic -c "/usr/local/bin/semantic -- parse --json \`find /r/internal/path -name *.js\`" | tail -n 1 > /path/to/output.json

Where:

  • /root/path/to/a/project is the root path to the directory of the project one wants to analyze.
  • /r is its root path within Docker's container.
  • find /r/internal/path -name *.js is the command to find all files that have extension ".js" and reside in /root/path/to/a/project/internal/path. Notice that the command is wrapped in escaped backticks. Sematic accepts a list of filepaths to be parsed as an argument. find returns them, and backticks are required in order to pass find's output as an argument to semantic. Finally, the backticks have to be escaped in order to make the command run within Docker's container (as opposed to the shell where the whole docker run ... command is invoked).

Alternatively, one can provide the root path to a source file to be analyzed, or a number of them. find is only used to enumerate them automatically.

How to Build KISS

  1. git clone https://github.com/ch3rn0v/kiss.git
  2. cd kiss
  3. stack build

How to Execute KISS

stack exec kiss-exe <path_to_the_json_file> <path_to_the_output_csv_file>

Where:

  • <path_to_the_json_file> is an absolute path in double quotes
  • <path_to_the_output_csv_file> is an absolute path in double quotes

Example:

stack exec kiss-exe "/home/user/**/dev/parsed.json" "/home/user/**/dev/analysis/results.csv"

Example of KISS Output's Visualization

KISS output's visualization KISS output's visualization KISS output's visualization KISS output's visualization KISS output's visualization KISS output's visualization

Acknowledgements

  • This tool wouldn't have been possible without awesome Haskell community, @haskellru in particular.
  • Semantic's staff members helped a lot to run their tool.
  • And a great thank you to @python273 who sped up the process by helping with Docker.

You can find the list of libraries used in package.yaml

About

The tool calculates arity, depth, and statement count for every function in a given project. The result is output as a .csv file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published