Skip to content

Commit b5f85f3

Browse files
committed
updated README.md
1 parent aa09c36 commit b5f85f3

File tree

1 file changed

+62
-30
lines changed

1 file changed

+62
-30
lines changed

README.md

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,84 @@
11
# Polystat CLI
2-
This repository provides an alternative implementation to [Polystat](https://github.com/polystat/polystat).
2+
This repository provides an alternative implementation to [Polystat](https://github.com/polystat/polystat). This tool's objective is to extend the functionality of the original implementation. These extensions include:
3+
* A precise [specification](#full) for the command-line interface.
4+
* A configuration file that is not tied to the command-line interface.
5+
* A setup-free and customizable integration with the existing source-to-EO translators (specifically [j2eo](https://github.com/polystat/j2eo) and [py2eo](https://github.com/polystat/py2eo)). The following features are implemented for the `j2eo` translator:
6+
* Automatic downloading of the specified version from Maven Central
7+
* If you have `j2eo` installed locally, you can provide a path to it via a configuration option.
8+
* The [SARIF](https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html) output of the analyzers can be produced in the following two forms:
9+
* A **directory** with the `.sarif.json` files, where each SARIF file corresponds to the file in the input directory.
10+
* An **single file** where the outputs of the analyzers for all the analyzed files are aggregated in a single SARIF JSON object.
11+
12+
...and many minor quality-of-life improvements.
313

414
# Installation
5-
The CLI is distributed as a fat jar, so that you can run without any prerequisites other than the JRE. To run it, just execute:
15+
The CLI is distributed as a fat jar (can be downloaded from [Github Releases](https://github.com/polystat/polystat-cli/releases)), so you can run without any prerequisites other than the [JRE](https://ru.wikipedia.org/wiki/Java_Runtime_Environment). If you have it installed, you can run `polystat-cli` by just executing:
616
```
7-
java -jar polystat.jar <args>
17+
$ java -jar polystat.jar <args>
818
```
9-
It may be helpful to define an alias (the following works in Unix/MacOs):
19+
It may be helpful to define an alias (the following works in most Linux and macos):
1020
```
11-
alias polystat="java -jar /path/to/polystat.jar"
21+
$ alias polystat="java -jar /path/to/polystat.jar"
1222
```
1323
And then simply run it like:
1424
```
15-
polystat <args>
25+
$ polystat <args>
1626
```
1727
More about the arguments you can pass can be found [here](#basic) and [here](#full).
1828

1929

2030
# <a name="basic"></a> Basic usage
2131

22-
> `polystat`
32+
* If no arguments are provided to `polystat`, it will read the configuration from the [HOCON](https://github.com/lightbend/config/blob/main/HOCON.md) config file in the current working directory. The default name for this file is `.polystat.conf` in the current working directory.
2333

24-
If no arguments are provided to `polystat`, it will read the configuration from the [HOCON](https://github.com/lightbend/config/blob/main/HOCON.md) config file in the current working directory. The default name for this file is `.polystat.conf` in the current working directory. If you want to read the configuration from the file located elsewhere, the following command can be used:
34+
```
35+
$ polystat
36+
```
37+
38+
* If you want to read the configuration from the file located elsewhere, the following command can be used:
2539

2640
```
27-
polystat --config path/to/hocon/config.conf
41+
$ polystat --config path/to/hocon/config.conf
2842
```
2943

30-
> `polystat list -c`
3144

32-
Prints all the available config keys.
33-
> `polystat list`
45+
* Print all the available configuration keys that can be used in the config file.
3446

35-
Prints the rule IDs for all the available analyzers. By default, all of them are enabled, however you can exclude some / include only the ones you want using the following commands:
47+
```
48+
$ polystat list -c
49+
```
3650

37-
> `polystat eo --in tmp --exclude mutualrec --sarif`
51+
* Print the rule IDs for all the available analyzers.
3852

39-
All the rules BUT the `mutualrec` will be executed.
53+
```
54+
$ polystat list
55+
```
4056

57+
* Don't execute some rules during the analysis. This option is repeatable, so you can add any number of `--exclude rule` arguments to exclude all the specified rules. In the example below all the rules **but** `mutualrec` and `long` will be executed.
58+
```
59+
$ polystat eo --in tmp --exclude mutualrec --exclude long --sarif
60+
```
4161

42-
> `polystat eo --in tmp --include mutualrec --include liskov --sarif`
62+
* Execute _only_ the given rules during the analysis. This option is also repeatable.
63+
In the example below **only** `mutualrec` and `liskov` rules will be executed.
4364

44-
Only `mutualrec` and `liskov` rules will be executed.
65+
```
66+
$ polystat eo --in tmp --include mutualrec --include liskov --sarif
67+
```
4568

69+
* Get the plain text console output from analyzing Java files located in the directory `src/main/java`.
4670

47-
> `polystat java --in src/main/java --console`
71+
```
72+
$ polystat java --in src/main/java --console
73+
```
4874

49-
Get the plain text console output from analyzing Java files. The Java files are in the directory `src/main/java`.
75+
* Write the SARIF JSON files to `polystat_out/sarif` from analysing the `tmp` directory with `.eo` files.
5076

51-
> `polystat eo --in tmp --sarif --to dir=polystat_out`
5277

53-
Write the [SARIF](https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html) JSON files to `polystat_out/sarif` from analysing the `tmp` directory with `.eo` files.
78+
```
79+
$ polystat eo --in tmp --sarif --to dir=polystat_out
80+
```
81+
5482

5583

5684
# <a name="full"></a> Full Usage Specification
@@ -85,7 +113,7 @@ polystat list [--config | -c]
85113
* The temporary files produced by analyzers are to be stored in `--tmp` directory. If `--tmp` is not specified, temporary files will be stored in the OS-created tempdir. Each target language may have a different structure of the files in the temporary directory. It is assumed that the `path` supplied by `--tmp` points to an empty directory. If not, the contents of the `path` will be purged. If the `--tmp` option is specified but the directory it points to does not exist, it will be created.
86114

87115
## Configuration options
88-
* `--include` and `--exclude` respectively define which rules should be included/excluded from the analysis run. These options are mutually exclusive, so specifying both should not be valid. If neither option is specified, all the available analyzers will be run. The list of available rule specifiers can be found via `polystat list` command.
116+
* <a name="inex"></a>`--include` and `--exclude` respectively define which rules should be included/excluded from the analysis run. These options are mutually exclusive, so specifying both should not be valid. If neither option is specified, all the available analyzers will be run. The list of available rule specifiers can be found via `polystat list` command.
89117
* `--j2eo` option allows users to specify the path to the j2eo executable jar. If it's not specified, it looks for one in the current working diretory.
90118
If it's not present in the current working directory, download one from Maven Central (for now, the version is hardcoded to be 0.4.0).
91119
* `--j2eo-version` option allows users to specify which version of `j2eo` should be downloaded.
@@ -115,24 +143,28 @@ If it's not present in the current working directory, download one from Maven Ce
115143
# Development
116144
## Setup
117145
This is an sbt Scala project. In order to build the project you need the following:
118-
* JDK 8+
119-
* sbt 1.6.2
146+
* [JDK](https://ru.wikipedia.org/wiki/Java_Development_Kit) 8+
147+
* [sbt](https://www.scala-sbt.org/) 1.6.2
120148

121149
Both can be easily fetched via [coursier](https://get-coursier.io/docs/overview).
122150

123151
## Running the CLI
124-
> `sbt run`
152+
```
153+
$ sbt run
154+
```
125155

126156
It's best to run this command in the interactive mode, because you can specify the cmdline args there.
127157
However, for better turnaround time, it's better to tailor the `.polystat.conf` in the repository root for your needs and just run `run`.
128158
If you want to change the command-line arguments, edit the `.polystat.conf` in the repository root.
129159

130160
## Generating the fat JAR
131-
> `sbt assembly`
161+
```
162+
$ sbt assembly
163+
```
132164

133-
The jar can be then found at `target/scala-3.1.2/polystat.jar`.
165+
The generated jar can be then found at `target/scala-3.1.2/polystat.jar`.
134166

135167
## Running the tests
136-
> `sbt test`
137-
138-
168+
```
169+
$ sbt test
170+
```

0 commit comments

Comments
 (0)