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
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.
-
Pull Semantic's container.
-
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 passfind
's output as an argument tosemantic
. 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 wholedocker 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.
git clone https://github.com/ch3rn0v/kiss.git
cd kiss
stack build
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"
- 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