Skip to content

Commit 57dd139

Browse files
committed
Merge develop into thesis_bm
2 parents 2c6a8f9 + dfe439a commit 57dd139

159 files changed

Lines changed: 1552 additions & 802 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
push:
88
branches: [ "main", "develop" ]
99
pull_request:
10-
branches: [ "main", "develop" ]
10+
branches:
1111

1212
jobs:
1313
build:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<component name="ProjectRunConfigurationManager">
2-
<configuration default="false" name="Validation" type="Application" factoryName="Application" nameIsGenerated="true">
3-
<option name="MAIN_CLASS_NAME" value="org.variantsync.diffdetective.AnalysisRunner" />
2+
<configuration default="false" name="EditClassValidation" type="Application" factoryName="Application" nameIsGenerated="true">
3+
<option name="MAIN_CLASS_NAME" value="org.variantsync.diffdetective.validation.EditClassValidation" />
44
<module name="diffdetective" />
55
<method v="2">
66
<option name="Make" enabled="true" />

pom.xml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<plugin>
2121
<groupId>org.apache.maven.plugins</groupId>
2222
<artifactId>maven-javadoc-plugin</artifactId>
23-
<version>3.4.0</version>
23+
<version>3.4.1</version>
2424
<configuration>
2525
<reportOutputDirectory>docs</reportOutputDirectory>
2626
<destDir>javadoc</destDir>
@@ -30,7 +30,7 @@
3030
<plugin>
3131
<groupId>org.apache.maven.plugins</groupId>
3232
<artifactId>maven-compiler-plugin</artifactId>
33-
<version>3.8.1</version>
33+
<version>3.10.1</version>
3434
<configuration>
3535
<source>16</source>
3636
<target>16</target>
@@ -40,7 +40,7 @@
4040
<plugin>
4141
<groupId>org.apache.maven.plugins</groupId>
4242
<artifactId>maven-surefire-plugin</artifactId>
43-
<version>3.0.0-M7</version>
43+
<version>3.0.0-M8</version>
4444
<configuration>
4545
<includes>
4646
<include>**/*.java</include>
@@ -50,7 +50,9 @@
5050

5151
<!-- To build jar with dependencies-->
5252
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
5354
<artifactId>maven-assembly-plugin</artifactId>
55+
<version>3.4.2</version>
5456
<executions>
5557
<execution>
5658
<phase>package</phase>
@@ -114,13 +116,13 @@
114116
<dependency>
115117
<groupId>net.lingala.zip4j</groupId>
116118
<artifactId>zip4j</artifactId>
117-
<version>2.10.0</version>
119+
<version>2.11.5</version>
118120
</dependency>
119121

120122
<dependency>
121123
<groupId>org.eclipse.jgit</groupId>
122124
<artifactId>org.eclipse.jgit</artifactId>
123-
<version>5.11.1.202105131744-r</version>
125+
<version>6.4.0.202211300538-r</version>
124126
</dependency>
125127

126128
<dependency>
@@ -132,30 +134,30 @@
132134
<dependency>
133135
<groupId>org.tinylog</groupId>
134136
<artifactId>tinylog-api</artifactId>
135-
<version>2.4.1</version>
137+
<version>2.6.1</version>
136138
</dependency>
137139
<dependency>
138140
<groupId>org.tinylog</groupId>
139141
<artifactId>tinylog-impl</artifactId>
140-
<version>2.4.1</version>
142+
<version>2.6.1</version>
141143
</dependency>
142144

143145
<dependency>
144146
<groupId>org.apache.maven.plugins</groupId>
145147
<artifactId>maven-compiler-plugin</artifactId>
146-
<version>3.8.1</version>
148+
<version>3.11.0</version>
147149
</dependency>
148150

149151
<dependency>
150152
<groupId>org.junit.jupiter</groupId>
151153
<artifactId>junit-jupiter-engine</artifactId>
152-
<version>5.9.1</version>
154+
<version>5.9.2</version>
153155
<scope>test</scope>
154156
</dependency>
155157
<dependency>
156158
<groupId>org.junit.jupiter</groupId>
157159
<artifactId>junit-jupiter</artifactId>
158-
<version>5.9.1</version>
160+
<version>5.9.2</version>
159161
<scope>test</scope>
160162
</dependency>
161163
</dependencies>

src/main/java/org/variantsync/diffdetective/AnalysisRunner.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public class AnalysisRunner {
3030
* those copies will be used.
3131
* @param outputDirectory The directory to which any output data of the analysis should be written to.
3232
* @param datasetsFile Path to a markdown file containing a table of git repositories to analyze.
33-
* @param diffStoragePolicy Policy that decides whether and how the text-based diffs from git should
34-
* be stored in any parsed DiffTrees during the analyses. The default is
35-
* {@link ParseOptions.DiffStoragePolicy#DO_NOT_REMEMBER} as storing all
36-
* the text-diffs as strings can cause a big memory footprint that can be
37-
* avoided when the text-diffs are not used anyway.
33+
* @param getParseOptionsForRepo Determines which {@link PatchDiffParseOptions} to use per repository.
34+
* Each repository is by default, already equipped with options.
35+
* If you wish no changes, just return {@link Repository#getParseOptions()} here.
3836
* @param getFilterForRepo Determines which filter to use for parsing diffs in given repository that is about to be analyzed.
37+
* Each repository is by default, already equipped with a filter.
38+
* If you wish no changes, just return {@link Repository#getDiffFilter()} here.
3939
* @param preloadReposBeforeAnalysis Decides whether all repositories should be cloned once before the analysis.
4040
* If a repository does not have a local clone in {@link #repositoriesDirectory}
4141
* it will be cloned before the analysis if preloadReposBeforeAnalysis is set to
@@ -48,7 +48,7 @@ public record Options(
4848
Path repositoriesDirectory,
4949
Path outputDirectory,
5050
Path datasetsFile,
51-
ParseOptions.DiffStoragePolicy diffStoragePolicy,
51+
Function<Repository, PatchDiffParseOptions> getParseOptionsForRepo,
5252
Function<Repository, DiffFilter> getFilterForRepo,
5353
boolean preloadReposBeforeAnalysis,
5454
/* Determines whether all analyzed repositories should be updated
@@ -71,8 +71,8 @@ public static Options DEFAULT(final String[] args) {
7171
Paths.get("..", "DiffDetectiveMining"),
7272
Paths.get("results", "validation", "current"),
7373
datasetsFile,
74-
ParseOptions.DiffStoragePolicy.DO_NOT_REMEMBER,
75-
repo -> DatasetFactory.getDefaultDiffFilterFor(repo.getRepositoryName()),
74+
Repository::getParseOptions,
75+
Repository::getDiffFilter,
7676
true,
7777
false
7878
);
@@ -107,7 +107,7 @@ public static void run(Options options, BiConsumer<Repository, Path> validation)
107107

108108
Logger.info("Performing validation on the following repositories:");
109109
for (final Repository repo : repos) {
110-
repo.setParseOptions(repo.getParseOptions().withDiffStoragePolicy(options.diffStoragePolicy()));
110+
repo.setParseOptions(options.getParseOptionsForRepo().apply(repo));
111111
repo.setDiffFilter(options.getFilterForRepo().apply(repo));
112112
Logger.info(" - {} from {}", repo.getRepositoryName(), repo.getRemoteURI());
113113
}

src/main/java/org/variantsync/diffdetective/datasets/DatasetFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class DatasetFactory {
4141
public static final DiffFilter DEFAULT_DIFF_FILTER =
4242
new DiffFilter.Builder()
4343
.allowMerge(false)
44+
.allowCommitsWithoutParents(false)
4445
.allowedChangeTypes(DiffEntry.ChangeType.MODIFY)
4546
.allowedFileExtensions("h", "hpp", "c", "cpp")
4647
.build();
@@ -78,11 +79,11 @@ public static DiffFilter getDefaultDiffFilterFor(final String repositoryName) {
7879
* Returns the default parse options for the repository with the given name.
7980
* For Marlin, uses the {@link Marlin#ANNOTATION_PARSER}.
8081
*/
81-
private static ParseOptions getParseOptionsFor(final String repositoryName) {
82+
private static PatchDiffParseOptions getParseOptionsFor(final String repositoryName) {
8283
if (repositoryName.equalsIgnoreCase(MARLIN)) {
83-
return new ParseOptions(Marlin.ANNOTATION_PARSER);
84+
return PatchDiffParseOptions.Default.withAnnotationParser(Marlin.ANNOTATION_PARSER);
8485
}
85-
return ParseOptions.Default;
86+
return PatchDiffParseOptions.Default;
8687
}
8788

8889
/**
@@ -94,7 +95,7 @@ private static ParseOptions getParseOptionsFor(final String repositoryName) {
9495
*/
9596
public Repository create(final DatasetDescription dataset) {
9697
final DiffFilter diffFilter = getDefaultDiffFilterFor(dataset.name());
97-
final ParseOptions parseOptions = getParseOptionsFor(dataset.name());
98+
final PatchDiffParseOptions parseOptions = getParseOptionsFor(dataset.name());
9899

99100
final Repository repo = Repository.tryFromRemote(
100101
cloneDirectory,

src/main/java/org/variantsync/diffdetective/datasets/ParseOptions.java

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.variantsync.diffdetective.datasets;
2+
3+
import org.variantsync.diffdetective.feature.CPPAnnotationParser;
4+
import org.variantsync.diffdetective.variation.diff.parse.DiffTreeParseOptions;
5+
6+
/**
7+
* Parse options that should be used when parsing commits and patches within a commit history.
8+
* @param diffStoragePolicy Decides if and how unix diffs should be remembered in a parsed
9+
* {@link org.variantsync.diffdetective.diff.git.PatchDiff} when parsing commits.
10+
* @param diffTreeParseOptions Options for parsing a patch to a {@link org.variantsync.diffdetective.variation.diff.DiffTree}.
11+
* For more information, see {@link DiffTreeParseOptions}.
12+
* @author Paul Bittner
13+
*/
14+
public record PatchDiffParseOptions(
15+
DiffStoragePolicy diffStoragePolicy,
16+
DiffTreeParseOptions diffTreeParseOptions
17+
) {
18+
public enum DiffStoragePolicy {
19+
REMEMBER_DIFF,
20+
REMEMBER_STRIPPED_DIFF,
21+
REMEMBER_FULL_DIFF,
22+
DO_NOT_REMEMBER,
23+
}
24+
25+
/**
26+
* Creates PatchDiffParseOptions with the given annotation parser.
27+
*/
28+
public PatchDiffParseOptions withAnnotationParser(CPPAnnotationParser annotationParser) {
29+
return new PatchDiffParseOptions(
30+
this.diffStoragePolicy(),
31+
this.diffTreeParseOptions().withAnnotationParser(annotationParser)
32+
);
33+
}
34+
35+
/**
36+
* Creates PatchDiffParseOptions with the given policy for storing diffs.
37+
*/
38+
public PatchDiffParseOptions withDiffStoragePolicy(DiffStoragePolicy diffStoragePolicy) {
39+
return new PatchDiffParseOptions(
40+
diffStoragePolicy,
41+
this.diffTreeParseOptions()
42+
);
43+
}
44+
45+
/**
46+
* Default value for PatchDiffParseOptions that does not remember parsed unix diffs
47+
* and uses the default value for the parsing DiffTrees ({@link DiffTreeParseOptions#Default}).
48+
*/
49+
public static final PatchDiffParseOptions Default = new PatchDiffParseOptions(
50+
DiffStoragePolicy.DO_NOT_REMEMBER,
51+
DiffTreeParseOptions.Default
52+
);
53+
}

src/main/java/org/variantsync/diffdetective/datasets/Repository.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class Repository {
4747
/**
4848
* Options to configure parsing and memory consumption (e.g., by not keeping full diffs in memory).
4949
*/
50-
private ParseOptions parseOptions;
50+
private PatchDiffParseOptions parseOptions;
5151

5252
private final Lazy<Git> git = Lazy.of(this::load);
5353

@@ -66,7 +66,7 @@ public Repository(
6666
final Path localPath,
6767
final URI remote,
6868
final String repositoryName,
69-
final ParseOptions parseOptions,
69+
final PatchDiffParseOptions parseOptions,
7070
final DiffFilter diffFilter) {
7171
this.repoLocation = repoLocation;
7272
this.localPath = localPath;
@@ -86,7 +86,7 @@ public Repository(
8686
final URI remote,
8787
final String repositoryName) {
8888
this(repoLocation, localPath, remote, repositoryName,
89-
ParseOptions.Default, DiffFilter.ALLOW_ALL);
89+
PatchDiffParseOptions.Default, DiffFilter.ALLOW_ALL);
9090
}
9191

9292
/**
@@ -189,7 +189,7 @@ public String getRepositoryName() {
189189
* @param parseOptions Options for parsing the evolution history.
190190
* @return this
191191
*/
192-
public Repository setParseOptions(ParseOptions parseOptions) {
192+
public Repository setParseOptions(PatchDiffParseOptions parseOptions) {
193193
this.parseOptions = parseOptions;
194194
return this;
195195
}
@@ -216,7 +216,7 @@ public DiffFilter getDiffFilter() {
216216
/**
217217
* Options that should be used when parsing the evolution history.
218218
*/
219-
public ParseOptions getParseOptions() {
219+
public PatchDiffParseOptions getParseOptions() {
220220
return parseOptions;
221221
}
222222

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package org.variantsync.diffdetective.datasets.predefined;
22

33
import org.eclipse.jgit.diff.DiffEntry;
4-
import org.variantsync.diffdetective.datasets.Repository;
54
import org.variantsync.diffdetective.diff.git.DiffFilter;
6-
import org.variantsync.diffdetective.variation.diff.DiffNode;
7-
8-
import java.nio.file.Path;
95

106
/**
117
* Default repository for the Linux Kernel.
@@ -21,27 +17,4 @@ public class LinuxKernel {
2117
.allowedChangeTypes(DiffEntry.ChangeType.MODIFY)
2218
.allowedFileExtensions("c", "h")
2319
.build();
24-
25-
/**
26-
* This may cause bugs.
27-
*/
28-
@Deprecated
29-
public static boolean isFeature(DiffNode node) {
30-
return node.getLabel().contains("CONFIG_");
31-
}
32-
33-
/**
34-
* Clones Linux from Github.
35-
* @param localDir Directory to clone the repository to.
36-
* @return Linux repository
37-
*/
38-
@Deprecated
39-
public static Repository cloneFromGithubTo(Path localDir) {
40-
return Repository
41-
.tryFromRemote(localDir, "https://github.com/torvalds/linux", "Linux")
42-
.orElseThrow()
43-
.setDiffFilter(DIFF_FILTER)
44-
// .setFeatureAnnotationFilter(LinuxKernel::isFeature)
45-
;
46-
}
4720
}

src/main/java/org/variantsync/diffdetective/datasets/predefined/Marlin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.variantsync.diffdetective.datasets.predefined;
22

3-
import org.variantsync.diffdetective.datasets.ParseOptions;
3+
import org.variantsync.diffdetective.datasets.PatchDiffParseOptions;
44
import org.variantsync.diffdetective.datasets.Repository;
55
import org.variantsync.diffdetective.feature.CPPAnnotationParser;
66
import org.variantsync.diffdetective.feature.PropositionalFormulaParser;
@@ -29,6 +29,6 @@ public static Repository cloneFromGithubTo(Path localDir) {
2929
.tryFromRemote(localDir, "https://github.com/MarlinFirmware/Marlin.git", "Marlin")
3030
.orElseThrow()
3131
.setDiffFilter(StanciulescuMarlin.DIFF_FILTER)
32-
.setParseOptions(new ParseOptions(ANNOTATION_PARSER));
32+
.setParseOptions(PatchDiffParseOptions.Default.withAnnotationParser(ANNOTATION_PARSER));
3333
}
3434
}

0 commit comments

Comments
 (0)