Skip to content

Commit 5ef40f2

Browse files
committed
chore: analysisConfig now only have the git analysis related settings, and the others are used from env injected configs
1 parent 1a9a2b4 commit 5ef40f2

File tree

7 files changed

+18
-100
lines changed

7 files changed

+18
-100
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ tasks.named('checkstyleMain') {
7373
}
7474

7575
tasks.named('pmdMain') {
76-
dependsOn 'jandex'
76+
dependsOn 'jandex', 'compileQuarkusGeneratedSourcesJava'
7777
}
7878

7979
tasks.named('compileTestJava') {

src/main/java/net/explorviz/code/analysis/GitAnalysis.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ public class GitAnalysis { // NOPMD
5454
@ConfigProperty(name = "explorviz.gitanalysis.restrict-analysis-to-folders")
5555
/* default */ Optional<String> restrictAnalysisToFoldersProperty; // NOCS NOPMD
5656

57-
@ConfigProperty(name = "explorviz.gitanalysis.fetch-remote-data", defaultValue = "true")
58-
/* default */ boolean fetchRemoteDataProperty; // NOCS
59-
6057
@ConfigProperty(name = "explorviz.gitanalysis.send-to-remote", defaultValue = "true")
6158
/* default */ boolean sendToRemoteProperty; // NOCS
6259

@@ -69,9 +66,6 @@ public class GitAnalysis { // NOPMD
6966
@ConfigProperty(name = "explorviz.gitanalysis.end-commit-sha1")
7067
/* default */ Optional<String> endCommitProperty; // NOCS
7168

72-
@ConfigProperty(name = "explorviz.gitanalysis.save-crashed_files")
73-
/* default */ boolean saveCrashedFilesProperty; // NOCS
74-
7569
@ConfigProperty(name = "explorviz.landscape.token")
7670
/* default */ String landscapeTokenProperty; // NOCS
7771

@@ -98,12 +92,9 @@ private AnalysisConfig createConfig() {
9892
.branch(repositoryBranchProperty)
9993
.sourceDirectory(sourceDirectoryProperty)
10094
.restrictAnalysisToFolders(restrictAnalysisToFoldersProperty)
101-
.fetchRemoteData(fetchRemoteDataProperty)
102-
.sendToRemote(sendToRemoteProperty)
10395
.calculateMetrics(calculateMetricsProperty)
10496
.startCommit(startCommitProperty)
10597
.endCommit(endCommitProperty)
106-
.saveCrashedFiles(saveCrashedFilesProperty)
10798
.landscapeToken(landscapeTokenProperty)
10899
.applicationName(applicationNameProperty)
109100
.build();

src/main/java/net/explorviz/code/analysis/api/AnalysisRequest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class AnalysisRequest {
2121
private boolean calculateMetrics = true;
2222
private String startCommit;
2323
private String endCommit;
24-
private boolean saveCrashedFiles;
2524
private String landscapeToken = "";
2625
private String applicationName = "";
2726

@@ -100,14 +99,6 @@ public void setEndCommit(final String endCommit) {
10099
this.endCommit = endCommit;
101100
}
102101

103-
public boolean isSaveCrashedFiles() {
104-
return saveCrashedFiles;
105-
}
106-
107-
public void setSaveCrashedFiles(final boolean saveCrashedFiles) {
108-
this.saveCrashedFiles = saveCrashedFiles;
109-
}
110-
111102
public String getLandscapeToken() {
112103
return landscapeToken;
113104
}
@@ -133,18 +124,14 @@ public AnalysisConfig toConfig() {
133124
return new AnalysisConfig.Builder()
134125
.repoPath(Optional.ofNullable(repoPath))
135126
.repoRemoteUrl(Optional.ofNullable(repoRemoteUrl))
136-
.remoteStoragePath(Optional.ofNullable(remoteStoragePath))
137127
.gitUsername(Optional.ofNullable(username))
138128
.gitPassword(Optional.ofNullable(password))
139129
.branch(Optional.ofNullable(branch))
140130
.sourceDirectory(Optional.ofNullable(sourceDirectory))
141131
.restrictAnalysisToFolders(Optional.ofNullable(restrictAnalysisToFolders))
142-
.fetchRemoteData(fetchRemoteData)
143-
.sendToRemote(sendToRemote)
144132
.calculateMetrics(calculateMetrics)
145133
.startCommit(Optional.ofNullable(startCommit))
146134
.endCommit(Optional.ofNullable(endCommit))
147-
.saveCrashedFiles(saveCrashedFiles)
148135
.landscapeToken(landscapeToken != null ? landscapeToken : "")
149136
.applicationName(applicationName != null ? applicationName : "")
150137
.build();

src/main/java/net/explorviz/code/analysis/git/GitRepositoryHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public class GitRepositoryHandler { // NOPMD
6565
private static final String JAVA_PATH_SUFFIX = ".java";
6666
private static String repositoryPath;
6767

68+
@ConfigProperty(name = "explorviz.gitanalysis.remote.storage-path")
69+
/* default */ Optional<String> repoLocalStoragePathProperty; // NOCS
70+
6871
private Git git;
6972

7073
public static String getCurrentRepositoryPath() {
@@ -320,7 +323,7 @@ public Repository getGitRepository(AnalysisConfig config)
320323

321324
return getGitRepository(config.getRepoPath().orElse(""),
322325
new RemoteRepositoryObject(config.getRepoRemoteUrl().orElse(""),
323-
config.getRemoteStoragePath().orElse(""), credentialsProvider,
326+
repoLocalStoragePathProperty.orElse(""), credentialsProvider,
324327
config.getBranch().orElse("")));
325328
}
326329

src/main/java/net/explorviz/code/analysis/service/AnalysisConfig.java

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,41 @@ public class AnalysisConfig {
99

1010
private final Optional<String> repoPath;
1111
private final Optional<String> repoRemoteUrl;
12-
private final Optional<String> localStoragePath;
13-
private final Optional<String> remoteStoragePath;
1412
private final Optional<String> gitUsername;
1513
private final Optional<String> gitPassword;
1614
private final Optional<String> branch;
1715
private final Optional<String> sourceDirectory;
1816
private final Optional<String> restrictAnalysisToFolders;
19-
private final boolean fetchRemoteData;
20-
private final boolean sendToRemote;
2117
private final boolean calculateMetrics;
2218
private final Optional<String> startCommit;
2319
private final Optional<String> endCommit;
24-
private final boolean saveCrashedFiles;
2520
private final String landscapeToken;
2621
private final String applicationName;
2722

2823

2924
public AnalysisConfig(
3025
final Optional<String> repoPath,
3126
final Optional<String> repoRemoteUrl,
32-
final Optional<String> localStoragePath,
33-
final Optional<String> remoteStoragePath,
3427
final Optional<String> gitUsername,
3528
final Optional<String> gitPassword,
3629
final Optional<String> branch,
3730
final Optional<String> sourceDirectory,
3831
final Optional<String> restrictAnalysisToFolders,
39-
final boolean fetchRemoteData,
40-
final boolean sendToRemote,
4132
final boolean calculateMetrics,
4233
final Optional<String> startCommit,
4334
final Optional<String> endCommit,
44-
final boolean saveCrashedFiles,
4535
final String landscapeToken,
4636
final String applicationName) {
4737
this.repoPath = repoPath;
4838
this.repoRemoteUrl = repoRemoteUrl;
49-
this.localStoragePath = localStoragePath;
50-
this.remoteStoragePath = remoteStoragePath;
5139
this.gitUsername = gitUsername;
5240
this.gitPassword = gitPassword;
5341
this.branch = branch;
5442
this.sourceDirectory = sourceDirectory;
5543
this.restrictAnalysisToFolders = restrictAnalysisToFolders;
56-
this.fetchRemoteData = fetchRemoteData;
57-
this.sendToRemote = sendToRemote;
5844
this.calculateMetrics = calculateMetrics;
5945
this.startCommit = startCommit;
6046
this.endCommit = endCommit;
61-
this.saveCrashedFiles = saveCrashedFiles;
6247
this.landscapeToken = landscapeToken;
6348
this.applicationName = applicationName;
6449
}
@@ -71,14 +56,6 @@ public Optional<String> getRepoRemoteUrl() {
7156
return repoRemoteUrl;
7257
}
7358

74-
public Optional<String> getLocalStoragePath() {
75-
return localStoragePath;
76-
}
77-
78-
public Optional<String> getRemoteStoragePath() {
79-
return remoteStoragePath;
80-
}
81-
8259
public Optional<String> getGitUsername() {
8360
return gitUsername;
8461
}
@@ -99,14 +76,6 @@ public Optional<String> getRestrictAnalysisToFolders() {
9976
return restrictAnalysisToFolders;
10077
}
10178

102-
public boolean isFetchRemoteData() {
103-
return fetchRemoteData;
104-
}
105-
106-
public boolean isSendToRemote() {
107-
return sendToRemote;
108-
}
109-
11079
public boolean isCalculateMetrics() {
11180
return calculateMetrics;
11281
}
@@ -119,10 +88,6 @@ public Optional<String> getEndCommit() {
11988
return endCommit;
12089
}
12190

122-
public boolean isSaveCrashedFiles() {
123-
return saveCrashedFiles;
124-
}
125-
12691
public String getLandscapeToken() {
12792
return landscapeToken;
12893
}
@@ -137,19 +102,14 @@ public String getApplicationName() {
137102
public static class Builder {
138103
private Optional<String> repoPath = Optional.empty();
139104
private Optional<String> repoRemoteUrl = Optional.empty();
140-
private Optional<String> localStoragePath = Optional.empty();
141-
private Optional<String> remoteStoragePath = Optional.empty();
142105
private Optional<String> gitUsername = Optional.empty();
143106
private Optional<String> gitPassword = Optional.empty();
144107
private Optional<String> branch = Optional.empty();
145108
private Optional<String> sourceDirectory = Optional.empty();
146109
private Optional<String> restrictAnalysisToFolders = Optional.empty();
147-
private boolean fetchRemoteData = true;
148-
private boolean sendToRemote = true;
149110
private boolean calculateMetrics = true;
150111
private Optional<String> startCommit = Optional.empty();
151112
private Optional<String> endCommit = Optional.empty();
152-
private boolean saveCrashedFiles;
153113
private String landscapeToken = "";
154114
private String applicationName = "";
155115

@@ -162,16 +122,6 @@ public Builder repoRemoteUrl(final Optional<String> repoRemoteUrl) {
162122
this.repoRemoteUrl = repoRemoteUrl;
163123
return this;
164124
}
165-
166-
public Builder localStoragePath(final Optional<String> localStoragePath) {
167-
this.localStoragePath = localStoragePath;
168-
return this;
169-
}
170-
171-
public Builder remoteStoragePath(final Optional<String> remoteStoragePath) {
172-
this.remoteStoragePath = remoteStoragePath;
173-
return this;
174-
}
175125

176126
public Builder gitUsername(final Optional<String> gitUsername) {
177127
this.gitUsername = gitUsername;
@@ -198,16 +148,6 @@ public Builder restrictAnalysisToFolders(final Optional<String> restrictAnalysis
198148
return this;
199149
}
200150

201-
public Builder fetchRemoteData(final boolean fetchRemoteData) {
202-
this.fetchRemoteData = fetchRemoteData;
203-
return this;
204-
}
205-
206-
public Builder sendToRemote(final boolean sendToRemote) {
207-
this.sendToRemote = sendToRemote;
208-
return this;
209-
}
210-
211151
public Builder calculateMetrics(final boolean calculateMetrics) {
212152
this.calculateMetrics = calculateMetrics;
213153
return this;
@@ -223,11 +163,6 @@ public Builder endCommit(final Optional<String> endCommit) {
223163
return this;
224164
}
225165

226-
public Builder saveCrashedFiles(final boolean saveCrashedFiles) {
227-
this.saveCrashedFiles = saveCrashedFiles;
228-
return this;
229-
}
230-
231166
public Builder landscapeToken(final String landscapeToken) {
232167
this.landscapeToken = landscapeToken;
233168
return this;
@@ -242,19 +177,14 @@ public AnalysisConfig build() {
242177
return new AnalysisConfig(
243178
repoPath,
244179
repoRemoteUrl,
245-
localStoragePath,
246-
remoteStoragePath,
247180
gitUsername,
248181
gitPassword,
249182
branch,
250183
sourceDirectory,
251184
restrictAnalysisToFolders,
252-
fetchRemoteData,
253-
sendToRemote,
254185
calculateMetrics,
255186
startCommit,
256187
endCommit,
257-
saveCrashedFiles,
258188
landscapeToken,
259189
applicationName
260190
);

src/main/java/net/explorviz/code/analysis/service/AnalysisService.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.eclipse.jgit.revwalk.RevCommit;
3535
import org.eclipse.jgit.revwalk.RevSort;
3636
import org.eclipse.jgit.revwalk.RevWalk;
37+
import org.eclipse.microprofile.config.inject.ConfigProperty;
3738
import org.slf4j.Logger;
3839
import org.slf4j.LoggerFactory;
3940

@@ -54,6 +55,12 @@ public class AnalysisService { // NOPMD
5455
@Inject
5556
/* package */ CommitReportHandler commitReportHandler; // NOCS
5657

58+
@ConfigProperty(name = "explorviz.gitanalysis.save-crashed_files")
59+
/* default */ boolean saveCrashedFilesProperty; // NOCS
60+
61+
@ConfigProperty(name = "explorviz.gitanalysis.fetch-remote-data", defaultValue = "true")
62+
/* default */ boolean fetchRemoteDataProperty; // NOCS
63+
5764
// only done because checkstyle does not like the duplication of literals
5865
private static String toErrorText(final String position, final String commitId,
5966
final String branchName) {
@@ -81,7 +88,7 @@ public void analyzeAndSendRepo(final AnalysisConfig config, final DataExporter e
8188
// get fetch data from remote
8289
final Optional<String> startCommit = findStartCommit(config, exporter, branch);
8390
final Optional<String> endCommit =
84-
config.isFetchRemoteData() ? Optional.empty() : config.getEndCommit();
91+
fetchRemoteDataProperty ? Optional.empty() : config.getEndCommit();
8592

8693
checkIfCommitsAreReachable(startCommit, endCommit, branch);
8794

@@ -97,12 +104,12 @@ public void analyzeAndSendRepo(final AnalysisConfig config, final DataExporter e
97104
if (!inAnalysisRange) {
98105
if (commit.name().equals(startCommit.get())) {
99106
inAnalysisRange = true;
100-
if (config.isFetchRemoteData()) {
107+
if (fetchRemoteDataProperty) {
101108
lastCheckedCommit = commit;
102109
continue;
103110
}
104111
} else {
105-
if (config.isFetchRemoteData()) {
112+
if (fetchRemoteDataProperty) {
106113
lastCheckedCommit = commit;
107114
}
108115
continue;
@@ -165,7 +172,7 @@ private void checkIfCommitsAreReachable(final Optional<String> startCommit,
165172

166173
private Optional<String> findStartCommit(final AnalysisConfig config,
167174
final DataExporter exporter, final String branch) {
168-
if (config.isFetchRemoteData()) {
175+
if (fetchRemoteDataProperty) {
169176
final StateData remoteState = exporter.requestStateData(
170177
getUnambiguousUpstreamName(config.getRepoRemoteUrl()), branch);
171178
if (remoteState.getCommitID().isEmpty() || remoteState.getCommitID().isBlank()) {
@@ -338,7 +345,7 @@ private FileDataHandler fileAnalysis(final AnalysisConfig config, final Reposito
338345
final FileDataHandler fileDataHandler = parser.parseFileContent(fileContent, file.fileName,
339346
config.isCalculateMetrics(), commitSha); // NOPMD
340347
if (fileDataHandler == null) {
341-
if (config.isSaveCrashedFiles()) {
348+
if (saveCrashedFilesProperty) {
342349
DebugFileWriter.saveDebugFile("/logs/crashedfiles/", fileContent,
343350
file.fileName);
344351
}

src/test/java/net/explorviz/code/analysis/visitor/CyclomaticComplexityVisitorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void cyclomaticComplexityTest() throws FileNotFoundException { // NOCS
4242
.getMetricValue("cyclomatic_complexity")); // NOCS
4343
Assertions.assertEquals("2", fileDataHandler.getClassData("com.easy.life.Nested") // NOCS
4444
.getMethod("com.easy.life.Nested.heavyNested2#1980e")
45-
.getMetricValue("cyclomatic_complexity"));// NOCS
45+
.getMetricValue("cyclomatic_complexity")); // NOCS
4646
Assertions.assertEquals("4", fileDataHandler.getClassData("com.easy.life.Nested") // NOCS
4747
.getMetricValue("cyclomatic_complexity_weighted"));
4848

0 commit comments

Comments
 (0)