|
1 | | -# FamixDiff: User documentation |
| 1 | +# FamixDiff: User Documentation |
2 | 2 |
|
3 | | -FamixDiff allows one to compute the diff between two Moose models representing two different versions of the same project. It will return a report containing the different kind of changes that happened between those two versions. |
4 | | -To detect entities that got renamed or moved in the project, we are using some heuristics that can be parametrized (See section [Customize the analysis](#customize-the-analysis)). |
| 3 | +FamixDiff allows you to compute the difference between two Moose models representing two different versions of the same project. It returns a report containing the different types of changes that occurred between those two versions. |
| 4 | +To detect entities that have been renamed or moved in the project, we use heuristics that can be parameterized (see section [Customize the Analysis](#customize-the-analysis)). |
5 | 5 |
|
6 | | -- [FamixDiff: User documentation](#famixdiff-user-documentation) |
7 | | - - [Launch an analysis](#launch-an-analysis) |
| 6 | +- [FamixDiff: User Documentation](#famixdiff-user-documentation) |
| 7 | + - [Launch an Analysis](#launch-an-analysis) |
8 | 8 | - [Changes](#changes) |
9 | 9 | - [FamixDiffResult](#famixdiffresult) |
10 | | - - [Customize the analysis](#customize-the-analysis) |
11 | | - - [Possible evolutions](#possible-evolutions) |
| 10 | + - [Customize the Analysis](#customize-the-analysis) |
| 11 | + - [Possible Evolutions](#possible-evolutions) |
12 | 12 |
|
13 | | -## Launch an analysis |
| 13 | +## Launch an Analysis |
14 | 14 |
|
15 | 15 | Running a diff computation is as simple as: |
16 | 16 |
|
17 | 17 | ```st |
18 | 18 | | sourceModel targetModel | |
19 | | -sourceModel := MooseModel root at: 1. |
20 | | -targetModel := MooseModel root at: 2. |
| 19 | +sourceModel := MooseModel root at: 1. |
| 20 | +targetModel := MooseModel root at: 2 |
21 | 21 |
|
22 | | -FXDiff runOnBaseModel: sourceModel targetModel: targetModel |
| 22 | +FXDiff runOnBaseModel: sourceModel targetModel: targetModel. |
23 | 23 | ``` |
24 | 24 |
|
25 | | -This will return a `FamixDiffResult` containing changes. The different kind of changes will be explained in section [Changes](#changes) and the manipulation of the result will be explained in section [FamixDiffResult](#famixdiffresult). |
| 25 | +This will return a `FamixDiffResult` containing changes. The different types of changes are explained in the section [Changes](#changes), and the manipulation of the result is explained in the section [FamixDiffResult](#famixdiffresult). |
26 | 26 |
|
27 | 27 | ## Changes |
28 | 28 |
|
29 | | -FamixDiff will produce different kind of results: |
30 | | -- `FamixUnchangedChange`: This change represent an entity that is present in both the source and the target model with the same name and the same parents. /!\ It does not mean that this entity had no change at all. The source code of this entity might have changed. This is not yet covered by FamixDiff. |
31 | | -- `FamixAddChange`: This represent an entity that is not present in the base model but present in the target model. |
32 | | -- `FamixRemovalChange`: This represent an entity that is present in the base model but not in the target model. |
33 | | -- `FamixMoveChange`: This represent an entity present in both the source and target model, but that have a different parent between both. This means that the entity is still here but has moved. |
34 | | -- `FamixRenameChange`: This represent an entity that is present in both the source and target model but whose name changed. |
| 29 | +FamixDiff produces different types of results: |
| 30 | +- `FamixUnchangedChange`: This change represents an entity that is present in both the source and target models with the same name and the same parent. /!\ This does not mean that this entity has not changed at all. Its source code might have changed, but this is not yet covered by FamixDiff. |
| 31 | +- `FamixAddChange`: This represents an entity that is not present in the base model but is present in the target model. |
| 32 | +- `FamixRemovalChange`: This represents an entity that is present in the base model but not in the target model. |
| 33 | +- `FamixMoveChange`: This represents an entity present in both the source and target models but with a different parent in each. This means that the entity is still present but has moved. |
| 34 | +- `FamixRenameChange`: This represents an entity that is present in both the source and target models but has a different name. |
35 | 35 |
|
36 | 36 | ## FamixDiffResult |
37 | 37 |
|
38 | | -A diff analysis will return a `FamixDiffResult`. This class is a collection of changes. |
| 38 | +A diff analysis returns a `FamixDiffResult`, which is a collection of changes. |
39 | 39 |
|
40 | | -It is possible to act on it as on any other collection. |
| 40 | +It can be manipulated like any other collection. |
41 | 41 |
|
42 | | -For example: |
| 42 | +For example: |
43 | 43 |
|
44 | 44 | ```st |
45 | | -result select: [ :change | change baseEntity name beginsWith: 'A' ]. |
| 45 | +result select: [ :change | change baseEntity name beginsWith: 'A' ] |
46 | 46 | ``` |
47 | 47 |
|
48 | | -But it also provides an API to filter the changes. Each of the methods of this API will return a new `FamixDiffResult` with a subset of the changes. Be careful, this subset does not know its superset, so you might want to keep the original result if you wish to do multiple analysis. |
| 48 | +However, it also provides an API to filter the changes. Each method in this API returns a new `FamixDiffResult` containing a subset of the changes. Be careful: this subset does not retain a reference to its superset, so you may want to keep the original result if you wish to perform multiple analyses. |
49 | 49 |
|
50 | | -It is first possible to filter the changes by kind using: |
| 50 | +It is possible to filter changes by type using: |
51 | 51 | - `#additions` |
52 | 52 | - `#removals` |
53 | 53 | - `#moves` |
54 | 54 | - `#renames` |
55 | 55 | - `#identities` |
56 | 56 |
|
57 | | -It is also possible to ask other filtering such as: |
58 | | -- `#entityChanges`: Will return a result containing only the changes about entities and not about dependencies. |
59 | | -- `#associationChanges`: Will return a result containing only the changes about associations (dependencies) and not about entities. |
60 | | -- `#groupAdditionsAndRemovalsByRoots`: Will return a result removing additions and removals that are themselves into an addition or a removal. For example if a version is adding a package containing classes containing methods, it will only keep the change representing the addition of the package, and not the addition of the classes and methods. |
61 | | -- `#realChanges`: This filters out the unchanged changes. Most of the time, diff analysis is used to analyses entities that changed. This method allows one to concentrate of those and not on the entities that did not change. |
62 | | -- `#withoutStubs`: Filters out the stubs. |
| 57 | +Additional filtering options include: |
| 58 | +- `#entityChanges`: Returns only changes related to entities, excluding dependencies. |
| 59 | +- `#associationChanges`: Returns only changes related to associations (dependencies), excluding entities. |
| 60 | +- `#groupAdditionsAndRemovalsByRoots`: Removes additions and removals that are contained within another addition or removal. For example, if a version adds a package containing classes that contain methods, only the change representing the package addition is retained, not the additions of the classes and methods. |
| 61 | +- `#realChanges`: Filters out unchanged changes. Most of the time, diff analysis focuses on modified entities. This method allows you to concentrate on those and ignore entities that did not change. |
| 62 | +- `#withoutStubs`: Filters out stub entities. |
63 | 63 |
|
64 | 64 | Example: |
65 | 65 |
|
66 | 66 | ```st |
67 | | -result realChanges entityChanges withoutStub groupAdditionsAndRemovalsByRoots |
| 67 | +result realChanges entityChanges withoutStub groupAdditionsAndRemovalsByRoots. |
68 | 68 | ``` |
69 | 69 |
|
70 | | -This will return a result without any stub, without changes about dependencies, without the `unchanged` changes and containing only the roots of the additions and removals. |
| 70 | +This returns a result without stubs, without dependency changes, without `unchanged` changes, and containing only the root additions and removals. |
71 | 71 |
|
72 | | -## Customize the analysis |
| 72 | +## Customize the Analysis |
73 | 73 |
|
74 | | -In order to detect the entities that got renamed or moved, we are comparing their content and their dependencies. For example, in the case of a Pharo class, we are comparing if the variables, methods, incoming dependencies and outgoing dependencies are the same to know if we renamed or moved two classes. But in general when we rename a class or move it, we can also do other changes which means that their children and dependencies will change a little. In order to take that into account we allow an error margin using a ratio of tolerence. |
| 74 | +To detect entities that have been renamed or moved, we compare their content and dependencies. For example, in the case of a Pharo class, we compare variables, methods, incoming dependencies, and outgoing dependencies to determine whether two classes are the same but renamed or moved. However, renaming or moving a class often involves additional modifications, meaning that children and dependencies may change slightly. To account for this, we allow an error margin using a tolerance ratio. |
75 | 75 |
|
76 | | -By default this tolerence is at 0.2. This means that if at least 80% of the children and dependencies are the same, we consider that the entity is the same and just got renamed or moved. |
| 76 | +By default, this tolerance is set to 0.2. This means that if at least 80% of the children and dependencies remain the same, we consider the entity to be the same and only renamed or moved. |
77 | 77 |
|
78 | | -This ratio can by changed: |
| 78 | +This ratio can be adjusted: |
79 | 79 |
|
80 | 80 | ```st |
81 | 81 | (FXDiff baseModel: sourceModel targetModel: targetModel) |
82 | | - tolerence: 0.4; |
| 82 | + tolerance: 0.4; |
83 | 83 | run |
84 | 84 | ``` |
85 | 85 |
|
86 | | -With this snippet of code, we accept 40% of changed children and dependencies. |
| 86 | +With this snippet, we allow 40% of changed children and dependencies. |
87 | 87 |
|
88 | | -## Possible evolutions |
| 88 | +## Possible Evolutions |
| 89 | + |
| 90 | +Some possible future developments for the project include: |
| 91 | +- Taking comments into account |
| 92 | +- Detecting internal changes to entities that are not related to renaming, moving, addition, or removal (e.g., changes in source code). |
89 | 93 |
|
90 | | -Some possible evolutions of the project are: |
91 | | -- Take comments into account |
92 | | -- Detect changes inside entities that are not renaming, moving, addition, removal. For example a change in the source code. |
|
0 commit comments