You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Unjustified assumptions about methods of superclasses](#unjustified-assumptions-about-methods-of-superclasses)
17
+
-[Direct Access to the Base Class State](#direct-access-to-the-base-class-state)
18
+
-[Violation of the Liskov substitution principle](#violation-of-the-liskov-substitution-principle)
19
+
-[Division by zero](#division-by-zero)
20
+
-[Installation](#installation)
21
+
-[With coursier](#with-coursier)
22
+
-[Using a "fat" jar](#using-a-fat-jar)
23
+
-[Basic usage](#basic)
24
+
-[Running on big projects (hadoop)](#running-on-big-projects-hadoop)
25
+
-[Full Usage Specification](#full)
26
+
-[Notation](#notation)
27
+
-[Input configuration](#input-configuration)
28
+
-[Configuration options](#configuration-options)
29
+
-[Output configuration](#output-configuration)
30
+
-[`polystat list`](#polystat-list)
31
+
-[Other Options](#other-options)
32
+
-[Configuration File](#configuration-file)
33
+
-[Development](#development)
13
34
14
35
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:
15
36
* A precise [specification](#full) for the command-line interface.
@@ -26,10 +47,14 @@ This repository provides an alternative implementation to [Polystat](https://git
26
47
⚠ WARNING ⚠: The tool is still in the early stages of development, so feature suggestions and bug reports are more than welcome!
27
48
28
49
# Defects
50
+
29
51
This section describes the defects that the Polystat CLI can detect by analyzing the EO intermediate representation produced by the translators, such as `j2eo` and `py2eo`.
30
52
31
53
## Unanticipated mutual recursion
32
-
Comes from: [polsytat/odin](https://github.com/polystat/odin#mutual-recursion-analyzer)
54
+
55
+
[(Back to TOC)](#polystat-cli)
56
+
57
+
Comes from: [polystat/odin](https://github.com/polystat/odin#mutual-recursion-analyzer)
33
58
34
59
Unanticipated mutual recursion happens when a subclass redefines some of the methods of the superclass in such a way that one of the methods of the superclass becomes mutually-recursive with one of the redefined methods.
35
60
@@ -270,6 +295,9 @@ class__Derived.new.this:
270
295
```
271
296
272
297
## Unjustified assumptions about methods of superclasses
298
+
299
+
[(Back to TOC)](#polystat-cli)
300
+
273
301
If the superclass contains this defect, this means that the inlining of one its
274
302
the methods is not safe, because doing so may lead to breaking changes in its subclasses.
275
303
@@ -326,7 +354,7 @@ public class Test {
326
354
327
355
<summary>
328
356
329
-
Translation to EO (`j2eo` v0.5.3)</summary>
357
+
Show translation to EO (generated with J2EO v0.5.3)</summary>
330
358
```
331
359
# 2022-06-20T16:48:51.476031558
332
360
# j2eo team
@@ -605,32 +633,131 @@ Inlining calls in method ggg is not safe: doing so may break the behaviour of su
605
633
```
606
634
607
635
## Direct Access to the Base Class State
636
+
637
+
[(Back to TOC)](#polystat-cli)
638
+
608
639
This defect means that the analyzed program contains the parts where the fields of the object are accessed directly. This probably means that the object with such fields breaks the incapsulation by exposing some of its private fields.
609
640
610
641
Comes from: [polystat/odin](https://github.com/polystat/odin#direct-access-to-the-base-class-state-analyzer)
611
642
612
-
__WARNING__: With the current latest version of `j2eo` (v0.5.3), the direct state access defect is not detected. It should work when [j2eo#114](https://github.com/polystat/j2eo/issues/114) is fixed.
643
+
__WARNING__: With the current latest version of `j2eo` (v0.5.3), the direct state access defect is not detected. It should work when [j2eo#114](https://github.com/polystat/j2eo/issues/114) is fixed.
613
644
614
-
Sample input (simplified EO translation):
645
+
__UPDATE__: Odin v0.4.5 introduced a workaround that made the Direct State Access defect detectable in some cases.
646
+
647
+
Sample input (Java):
648
+
649
+
```java
650
+
classA {
651
+
protectedint state =0;
652
+
};
615
653
654
+
classBextendsA {
655
+
publicintn(intx) {
656
+
returnthis.state + x;
657
+
}
658
+
}
616
659
```
617
-
[] > a
618
-
memory > state
619
-
[self new_state] > update_state
620
-
self.state.write new_state > @
621
-
[] > b
622
-
a > @
623
-
[self new_state] > change_state_plus_two
624
-
self.state.write (new_state.add 2) > @
660
+
<details>
661
+
<summary>
662
+
663
+
Show translation to EO (generated with J2EO v0.5.3)</summary>
664
+
```python
665
+
# 2022-07-01T15:16:39.276365661
666
+
# j2eo team
667
+
+alias stdlib.lang.class__Object
668
+
+alias stdlib.primitives.prim__int
669
+
670
+
[] > class__A
671
+
class__Object >super
672
+
super>@
673
+
[] > new
674
+
[] > this
675
+
class__Object.new >super
676
+
super>@
677
+
"class__A"> className
678
+
[this] > init
679
+
seq >@
680
+
d580718781
681
+
[] > d580718781
682
+
this.state.write >@
683
+
i_s1840976765
684
+
[] > i_s1840976765
685
+
l436532993 >@
686
+
[] > l436532993
687
+
prim__int.constructor_2 >@
688
+
prim__int.new
689
+
0
690
+
prim__int.constructor_1 > state
691
+
prim__int.new
692
+
seq >@
693
+
this
694
+
# null :: null -> void
695
+
[this] > constructor
696
+
seq >@
697
+
initialization
698
+
s511717113
699
+
this
700
+
[] > initialization
701
+
this.init >@
702
+
this
703
+
[] > s511717113
704
+
super.constructor >@
705
+
this.super
706
+
707
+
[] > class__B
708
+
class__A >super
709
+
super>@
710
+
[] > new
711
+
[] > this
712
+
class__A.new >super
713
+
super>@
714
+
"class__B"> className
715
+
[this] > init
716
+
seq >@
717
+
TRUE
718
+
# n :: int -> int
719
+
[this x] > n
720
+
seq >@
721
+
s1219161283
722
+
[] > s1219161283
723
+
b1552978964 >@
724
+
[] > b1552978964
725
+
f_a355790875.add >@
726
+
s_r2028017635
727
+
[] > f_a355790875
728
+
t782378927.state >@
729
+
[] > t782378927
730
+
this >@
731
+
[] > s_r2028017635
732
+
x >@
733
+
seq >@
734
+
this
735
+
# null :: null -> void
736
+
[this] > constructor
737
+
seq >@
738
+
initialization
739
+
s454325163
740
+
this
741
+
[] > initialization
742
+
this.init >@
743
+
this
744
+
[] > s454325163
745
+
super.constructor >@
746
+
this.super
625
747
```
748
+
</details>
749
+
626
750
627
751
Analyzer output:
628
752
629
753
```
630
-
Method 'change_state_plus_two' of object 'b' directly accesses state 'state' of base class 'a'
754
+
Method 'n' of object 'class__B.new.this' directly accesses state 'state' of base class 'class__A.new.this'
631
755
```
632
756
633
757
## Violation of the Liskov substitution principle
758
+
759
+
[(Back to TOC)](#polystat-cli)
760
+
634
761
This defect means that some parts of the code violate the [Liskov substitution principle](https://github.com/polystat/odin#liskov-substitution-principle-violation-analyzer).
635
762
636
763
Comes from: [polystat/odin](https://github.com/polystat/odin#liskov-substitution-principle-violation-analyzer)
@@ -665,7 +792,7 @@ public class Test {
665
792
666
793
<summary>
667
794
668
-
Translation to EO (`j2eo` v0.5.3)</summary>
795
+
Show translation to EO (generated with J2EO v0.5.3)</summary>
669
796
```
670
797
# 2022-06-20T16:48:51.463254529
671
798
# j2eo team
@@ -824,6 +951,9 @@ Method g of object this violates the Liskov substitution principle as compared t
824
951
825
952
826
953
## Division by zero
954
+
955
+
[(Back to TOC)](#polystat-cli)
956
+
827
957
The presence of this defect in the program means that some inputs may cause this program to fail with the ArithmeticException.
828
958
829
959
Comes from: [polystat/far](https://github.com/polystat/far)
@@ -849,6 +979,9 @@ Analyzer output:
849
979
```
850
980
851
981
# <aname="installation"></a> Installation
982
+
983
+
[(Back to TOC)](#polystat-cli)
984
+
852
985
## With coursier
853
986
If you have [coursier](https://get-coursier.io/docs/cli-installation) installed, then you can install the latest version of `polystat-cli` by running:
854
987
```
@@ -877,6 +1010,8 @@ More about the arguments you can pass can be found [here](#basic) and [here](#fu
877
1010
878
1011
# <aname="basic"></a> Basic usage
879
1012
1013
+
[(Back to TOC)](#polystat-cli)
1014
+
880
1015
* 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.
@@ -961,6 +1099,9 @@ Executing these commands should create the following files:
961
1099
3.`hadoop.json` should contain the aggregated SARIF output for all the files in the repository. This `.json` file contains a single [`sarifLog`](https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317478) object. This object has a property called [`runs`](https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317482), which is an array of `run` objects. Each [`run`](https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317484) object contains the name of the analyzed file and the [`results`](https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317507) property, which holds the results of all the analyzers that completed successfully.
962
1100
963
1101
# <aname="full"></a> Full Usage Specification
1102
+
1103
+
[(Back to TOC)](#polystat-cli)
1104
+
964
1105
This section covers all the options available in the CLI interface and their meanings.
965
1106
966
1107
## Notation
@@ -1025,6 +1166,8 @@ If it's not present in the current working directory, download one from Maven Ce
1025
1166
*`--config <path>` allows to configure Polystat from the specified HOCON config file. If not specified, reads configs from the file `.polystat.conf` in the current working directory.
1026
1167
1027
1168
# Configuration File
1169
+
[(Back to TOC)](#polystat-cli)
1170
+
1028
1171
This section covers all the keys that can be used in the HOCON configuration files. The most relevant version of the information presented in this section can be printed to console by running:
1029
1172
```
1030
1173
$ polystat list --config
@@ -1050,6 +1193,9 @@ The example of the working config file can be found [here](.polystat.conf).
1050
1193
* `polystat.outputs.files` - a list of files to write aggregated output to.
1051
1194
1052
1195
# Development
1196
+
1197
+
[(Back to TOC)](#polystat-cli)
1198
+
1053
1199
Polystat CLI is an sbt Scala project. In order to build the project you need the following:
0 commit comments