From 7b955048eb86e1c12114554beacb27b329252b15 Mon Sep 17 00:00:00 2001
From: Antoine Musso
Date: Wed, 31 May 2023 17:57:28 +0200
Subject: Fix all Javadoc warnings and fail on them
This fixes all the javadoc warnings, stops ignoring doclint 'missing'
category and fails the build on javadoc warnings for public and
protected classes and class members.
Since javadoc doesn't allow access specifiers when specifying doclint
configuration we cannot set `-Xdoclint:all,-missing/private`
hence there is no simple way to skip private elements from doclint.
Therefore we check javadoc using the Eclipse Java compiler
(which is used by default) and javadoc configuration in
`.settings/org.eclipse.jdt.core.prefs` files.
This allows more fine grained configuration.
We can reconsider this when javadoc starts supporting access specifiers
in the doclint configuration.
Below are detailled explanations for most modifications.
@inheritDoc
===========
doclint complains about explicits `{@inheritDoc}` when the parent does
not have any documentation. As far as I can tell, javadoc defaults to
inherit comments and should only be used when one wants to append extra
documentation from the parent. Given the parent has no documentation,
remove those usages which doclint complains about.
In some case I have moved up the documentation from the concrete class
up to the abstract class.
Remove `{@inheritDoc}` on overriden methods which don't add additional
documentation since javadoc defaults to inherit javadoc of overridden
methods.
@value to @link
===============
In PackConfig, DEFAULT_SEARCH_FOR_REUSE_TIMEOUT and similar are forged
from Integer.MAX_VALUE and are thus not considered constants (I guess
cause the value would depends on the platform). Replace it with a link
to `Integer.MAX_VALUE`.
In `StringUtils.toBoolean`, @value was used to refer to the
`stringValue` parameter. I have replaced it with `{@code stringValue}`.
{@link } to
====================
@link does not support being given an external URL. Replaces them with
HTML ``.
@since: being invalid
=====================
org.eclipse.jgit/src/org/eclipse/jgit/util/Equality.java has an invalid
tag `@since: ` due to the extra `:`. Javadoc does not complain about it
with version 11.0.18+10 but does with 11.0.19.7. It is invalid
regardless.
invalid HTML syntax
===================
- javadoc doesn't allow
, and
anymore, use
and
instead
- replace code by {@code code}
-
tags don't allow summary attribute, specify caption as
caption to fix this
doclint visibility issue
========================
In the private abstract classes `BaseDirCacheEditor` and
`BasePackConnection` links to other methods in the abstract class are
inherited in the public subclasses but doclint gets confused and
considers them unreachable. The HTML documentation for the sub classes
shows the relative links in the sub classes, so it is all correct. It
must be a bug somewhere in javadoc.
Mute those warnings with: @SuppressWarnings("doclint:missing")
Misc
====
Replace `<` and `>` with HTML encoded entities (`< and `>`).
In `SshConstants` I went enclosing a serie of -> arrows in @literal.
Additional tags
===============
Configure maven-javad0c-plugin to allow the following additional tags
defined in https://openjdk.org/jeps/8068562:
- apiNote
- implSpec
- implNote
Missing javadoc
===============
Add missing @params and descriptions
Change-Id: I840056389aa59135cfb360da0d5e40463ce35bd0
Also-By: Matthias Sohn
---
.../org/eclipse/jgit/junit/RepositoryTestCase.java | 53 ++++++++++++++++++++--
1 file changed, 48 insertions(+), 5 deletions(-)
(limited to 'org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java')
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
index 04988f6289..3a283ce10d 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
@@ -62,8 +62,11 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Copy a file
*
* @param src
+ * file to copy
* @param dst
+ * destination of the copy
* @throws IOException
+ * if an IO error occurred
*/
protected static void copyFile(File src, File dst)
throws IOException {
@@ -81,9 +84,12 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Write a trash file
*
* @param name
+ * file name
* @param data
+ * file content
* @return the trash file
* @throws IOException
+ * if an IO error occurred
*/
protected File writeTrashFile(String name, String data)
throws IOException {
@@ -99,6 +105,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* the target of the symbolic link
* @return the path to the symbolic link
* @throws Exception
+ * if an error occurred
* @since 4.2
*/
protected Path writeLink(String link, String target)
@@ -110,10 +117,14 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Write a trash file
*
* @param subdir
+ * in working tree
* @param name
+ * file name
* @param data
+ * file content
* @return the trash file
* @throws IOException
+ * if an IO error occurred
*/
protected File writeTrashFile(final String subdir, final String name,
final String data)
@@ -125,8 +136,10 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Read content of a file
*
* @param name
+ * file name
* @return the file's content
* @throws IOException
+ * if an IO error occurred
*/
protected String read(String name) throws IOException {
return JGitTestUtil.read(db, name);
@@ -149,6 +162,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* @param name
* file name
* @throws IOException
+ * if an IO error occurred
*/
protected void deleteTrashFile(String name) throws IOException {
JGitTestUtil.deleteTrashFile(db, name);
@@ -158,9 +172,11 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Check content of a file.
*
* @param f
+ * file
* @param checkData
* expected content
* @throws IOException
+ * if an IO error occurred
*/
protected static void checkFile(File f, String checkData)
throws IOException {
@@ -181,7 +197,6 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
/** Working directory of {@link #db}. */
protected File trash;
- /** {@inheritDoc} */
@Override
@Before
public void setUp() throws Exception {
@@ -229,11 +244,11 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* {@link #CONTENT} controlling which info is present in the
* resulting string.
* @return a string encoding the index state
- * @throws IllegalStateException
* @throws IOException
+ * if an IO error occurred
*/
public String indexState(int includedOptions)
- throws IllegalStateException, IOException {
+ throws IOException {
return indexState(db, includedOptions);
}
@@ -251,7 +266,9 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* a {@link org.eclipse.jgit.treewalk.FileTreeIterator} which
* determines which files should go into the new index
* @throws FileNotFoundException
+ * file was not found
* @throws IOException
+ * if an IO error occurred
*/
protected void resetIndex(FileTreeIterator treeItr)
throws FileNotFoundException, IOException {
@@ -339,7 +356,9 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* @return return the last measured value of the filesystem timer which is
* greater than then the lastmodification time of lastfile.
* @throws InterruptedException
+ * if thread was interrupted
* @throws IOException
+ * if an IO error occurred
* @since 5.1.9
*/
public static Instant fsTick(File lastFile)
@@ -378,8 +397,11 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Create a branch
*
* @param objectId
+ * new value to create the branch on
* @param branchName
+ * branch name
* @throws IOException
+ * if an IO error occurred
*/
protected void createBranch(ObjectId objectId, String branchName)
throws IOException {
@@ -393,6 +415,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
*
* @return list of refs
* @throws IOException
+ * if an IO error occurred
*/
public List[ getRefs() throws IOException {
return db.getRefDatabase().getRefs();
@@ -402,11 +425,12 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Checkout a branch
*
* @param branchName
- * @throws IllegalStateException
+ * branch name
* @throws IOException
+ * if an IO error occurred
*/
protected void checkoutBranch(String branchName)
- throws IllegalStateException, IOException {
+ throws IOException {
try (RevWalk walk = new RevWalk(db)) {
RevCommit head = walk.parseCommit(db.resolve(Constants.HEAD));
RevCommit branch = walk.parseCommit(db.resolve(branchName));
@@ -436,7 +460,9 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* the contents which should be written into the files
* @return the File object associated to the last written file.
* @throws IOException
+ * if an IO error occurred
* @throws InterruptedException
+ * if thread was interrupted
*/
protected File writeTrashFiles(boolean ensureDistinctTimestamps,
String... contents)
@@ -459,8 +485,11 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* one.
*
* @param filename
+ * file name
* @param contents
+ * file content
* @param branch
+ * branch name
* @return the created commit
*/
protected RevCommit commitFile(String filename, String contents, String branch) {
@@ -494,7 +523,9 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Create ]DirCacheEntry
*
* @param path
+ * file path
* @param mode
+ * file mode
* @return the DirCacheEntry
*/
protected DirCacheEntry createEntry(String path, FileMode mode) {
@@ -505,8 +536,11 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Create DirCacheEntry
*
* @param path
+ * file path
* @param mode
+ * file mode
* @param content
+ * file content
* @return the DirCacheEntry
*/
protected DirCacheEntry createEntry(final String path, final FileMode mode,
@@ -518,9 +552,13 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Create DirCacheEntry
*
* @param path
+ * file path
* @param mode
+ * file mode
* @param stage
+ * stage index of the new entry
* @param content
+ * file content
* @return the DirCacheEntry
*/
protected DirCacheEntry createEntry(final String path, final FileMode mode,
@@ -538,7 +576,9 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Create DirCacheEntry
*
* @param path
+ * file path
* @param objectId
+ * of the entry
* @return the DirCacheEntry
*/
protected DirCacheEntry createGitLink(String path, AnyObjectId objectId) {
@@ -553,8 +593,11 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* Assert files are equal
*
* @param expected
+ * expected file
* @param actual
+ * actual file
* @throws IOException
+ * if an IO error occurred
*/
public static void assertEqualsFile(File expected, File actual)
throws IOException {
--
cgit v1.2.3