Skip to content

Commit cc1d446

Browse files
committed
- Reduce JGit memory use #82
Simply deleted two unused functions - PDF link about Prioritizing Design Debt Investment Opportunities presentation is broken #103 Added the PDF and updated the link in the `README` file Also, made some minor tweaks to the README
1 parent 8e2d35a commit cc1d446

File tree

3 files changed

+30
-75
lines changed

3 files changed

+30
-75
lines changed
Binary file not shown.

README.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ It scans your Git repository generates a single page application by runing:
1212
- PMD's Coupling Between Objects
1313

1414
Code map viewers are powered by [3D Force Graph](https://vasturiano.github.io/3d-force-graph), [sigma.js](https://www.sigmajs.org/), and [GraphViz DOT](https://graphviz.org/docs/layouts/dot/)
15-
<br>If there are more than 4000 classes + relationships, a simplified 3D viewer will be used to avoid slowdowns. Features will be toggleable in the 3D UI in a future release.
15+
<br>If there are more than 4,000 classes + relationships, a simplified 3D viewer will be used to avoid slowdowns. Features will be toggleable in the 3D UI in a future release.
1616

1717
Take a look at the [Spring Petclinic REST project sample report](https://rawcdn.githack.com/refactorfirst/RefactorFirst/c46d26211a91ffbe08d4089e04a85ff31eb093c0/spring-petclinic-rest-report.html)!
1818

@@ -29,12 +29,13 @@ If you use an old JDK release of your chosen Java version, you may encounter iss
2929
## There are several ways to run the analysis on your codebase:
3030

3131
### From The Command Line As an HTML Report
32-
Run the following command from the root of your project (the source code does not need to be built):
32+
Run the following command from the root of your project (the source code does not need to be built), or simply by clicking on the Play icon (a green triangle) in the gutter of IntelliJ IDEA (if you are looking at the source of the README):
3333

3434
```bash
3535
mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.7.1:htmlReport
3636
```
37-
View the report at ```target/site/refactor-first-report.html```
37+
38+
View the report [here](target/site/refactor-first-report.html)
3839

3940
### [As Part of GitHub Actions Output](https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries/)
4041
This will generate a simplified HTML report (no graphs or images) as the output of a GitHub Action step
@@ -53,7 +54,7 @@ Add the following to your project in the build section. **showDetails** will sh
5354
<plugin>
5455
<groupId>org.hjug.refactorfirst.plugin</groupId>
5556
<artifactId>refactor-first-maven-plugin</artifactId>
56-
<version>0.7.1</version>
57+
<version>0.7.1</version>
5758
<!-- optional -->
5859
<configuration>
5960
<showDetails>false</showDetails>
@@ -74,14 +75,14 @@ A RefactorFirst report will show up in the site report when you run ```mvn site`
7475
<plugin>
7576
<groupId>org.hjug.refactorfirst.plugin</groupId>
7677
<artifactId>refactor-first-maven-plugin</artifactId>
77-
<version>0.7.1</version>
78+
<version>0.7.1</version>
7879
</plugin>
7980
...
8081
</plugins>
8182
</reporting>
8283
```
8384

84-
## Configuraiton Options
85+
## Configuration Options
8586
Care has been taken to use sensible defaults, though if you wish to override these defaults you can specify the following parameters.
8687
Specify with -D if running on the command line. e.g. ```-DbackEdgeAnalysisCount=0 `DanalyzeCycles=false``` or in the configuration section (as in the above examples) if including in a Maven build.
8788

@@ -100,40 +101,44 @@ Specify with -D if running on the command line. e.g. ```-DbackEdgeAnalysisCount
100101

101102
### Seeing Errors?
102103

104+
#### Maven Site
103105
If you see an error similar to
104106
```
105107
Execution default-site of goal org.apache.maven.plugins:maven-site-plugin:3.3:site failed: A required class was missing while executing org.apache.maven.plugins:maven-site-plugin:3.3:site: org/apache/maven/doxia/siterenderer/DocumentContent
106108
```
107109
you will need to add the following to your pom.xml:
108110
```xml
109111
<build>
110-
<plugins>
111-
<plugin>
112-
<groupId>org.apache.maven.plugins</groupId>
113-
<artifactId>maven-site-plugin</artifactId>
114-
<version>3.12.1</version>
115-
</plugin>
116-
<plugin>
117-
<groupId>org.apache.maven.plugins</groupId>
118-
<artifactId>maven-project-info-reports-plugin</artifactId>
119-
<version>3.4.5</version>
120-
</plugin>
112+
<plugins>
113+
<plugin>
114+
<groupId>org.apache.maven.plugins</groupId>
115+
<artifactId>maven-site-plugin</artifactId>
116+
<version>3.12.1</version>
117+
</plugin>
118+
<plugin>
119+
<groupId>org.apache.maven.plugins</groupId>
120+
<artifactId>maven-project-info-reports-plugin</artifactId>
121+
<version>3.4.5</version>
122+
</plugin>
121123
</plugins>
122-
</build>
124+
</build>
123125
```
124126

127+
#### Lombok
128+
129+
You _may_ see errors during the build process if you haven't installed (and enabled) the Lombok plugin. Make sure to also enable Java Annotation Processing.
125130

126131
## But I'm using Gradle / my project layout isn't typical!
127132
I would like to create a Gradle plugin and (possibly) support non-conventional projects in the future, but in the meantime you can create a dummy POM file in the same directory as your .git directory:
128133

129134
```xml
130135
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
131-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
132-
<modelVersion>4.0.0</modelVersion>
133-
134-
<groupId>com.mycompany.app</groupId>
135-
<artifactId>my-app</artifactId>
136-
<version>1.0-SNAPSHOT</version>
136+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
137+
<modelVersion>4.0.0</modelVersion>
138+
139+
<groupId>com.mycompany.app</groupId>
140+
<artifactId>my-app</artifactId>
141+
<version>1.0-SNAPSHOT</version>
137142
</project>
138143
```
139144
and then (assuming Maven is installed) run
@@ -155,7 +160,7 @@ If you have IntelliJ Ultimate, you can install the [Method Reference Diagram](ht
155160
## Additional Details
156161
This plugin will work on both single module and multi-module Maven projects that have a typical Maven project layout.
157162

158-
This tool is based on the paper **[Prioritizing Design Debt Investment Opportunities](https://dl.acm.org/doi/10.1145/1985362.1985372)** by Nico Zazworka, Carolyn Seaman, and Forrest Shull. The presentation based on the paper is available at https://resources.sei.cmu.edu/asset_files/Presentation/2011_017_001_516911.pdf
163+
This tool is based on the paper **[Prioritizing Design Debt Investment Opportunities](https://dl.acm.org/doi/10.1145/1985362.1985372)** by Nico Zazworka, Carolyn Seaman, and Forrest Shull. The presentation based on the paper is available [here](07-Investigating the Impact of Design Debt on Software Quality.pdf).
159164

160165
## Limitations
161166
* My time. This is a passion project and is developed in my spare time.

change-proneness-ranker/src/main/java/org/hjug/git/GitLogReader.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -48,61 +48,11 @@ public void close() throws Exception {
4848
git.close();
4949
}
5050

51-
// Based on
52-
// https://github.com/Cosium/git-code-format-maven-plugin/blob/master/src/main/java/com/cosium/code/format/AbstractMavenGitCodeFormatMojo.java
53-
// MIT License
54-
// Move to a provider?
55-
public Repository gitRepository(File basedir) throws IOException {
56-
Repository gitRepository;
57-
FileRepositoryBuilder repositoryBuilder = new FileRepositoryBuilder().findGitDir(basedir);
58-
String gitIndexFileEnvVariable = System.getenv("GIT_INDEX_FILE");
59-
if (Objects.nonNull(gitIndexFileEnvVariable)
60-
&& !gitIndexFileEnvVariable.trim().isEmpty()) {
61-
log.debug("Setting Index File based on Env Variable GIT_INDEX_FILE {}", gitIndexFileEnvVariable);
62-
repositoryBuilder = repositoryBuilder.setIndexFile(new File(gitIndexFileEnvVariable));
63-
}
64-
gitRepository = repositoryBuilder.build();
65-
66-
return gitRepository;
67-
}
68-
6951
public File getGitDir(File basedir) {
7052
FileRepositoryBuilder repositoryBuilder = new FileRepositoryBuilder().findGitDir(basedir);
7153
return repositoryBuilder.getGitDir();
7254
}
7355

74-
// https://stackoverflow.com/a/19950970/346247
75-
// and
76-
// https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ReadFileFromCommit.java
77-
public Map<String, ByteArrayOutputStream> listRepositoryContentsAtHEAD(Repository repository) throws IOException {
78-
Ref head = repository.exactRef("HEAD");
79-
// a RevWalk allows us to walk over commits based on some filtering that is defined
80-
RevWalk walk = new RevWalk(repository);
81-
RevCommit commit = walk.parseCommit(head.getObjectId());
82-
RevTree tree = commit.getTree();
83-
84-
TreeWalk treeWalk = new TreeWalk(repository);
85-
treeWalk.addTree(tree);
86-
treeWalk.setRecursive(false);
87-
88-
// TODO: extract rest of this method to test it
89-
Map<String, ByteArrayOutputStream> fileContentsCollection = new HashMap<>();
90-
while (treeWalk.next()) {
91-
if (treeWalk.isSubtree()) {
92-
treeWalk.enterSubtree();
93-
} else {
94-
if (treeWalk.getPathString().endsWith(JAVA_FILE_TYPE)) {
95-
ObjectId objectId = treeWalk.getObjectId(0);
96-
ObjectLoader loader = repository.open(objectId);
97-
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
98-
loader.copyTo(outputStream);
99-
fileContentsCollection.put(treeWalk.getPathString(), outputStream);
100-
}
101-
}
102-
}
103-
return fileContentsCollection;
104-
}
105-
10656
// log --follow implementation may be worth adopting in the future
10757
// https://github.com/spearce/jgit/blob/master/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java
10858

0 commit comments

Comments
 (0)