From b0991ca80530bc6f73fd92ad5e183f434d26da1a Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 9 Oct 2018 15:56:55 -0700 Subject: [PATCH] Format @NonNull on return value as method annotation For example, instead of using public @NonNull String getMyFavoriteString() { ... } use @NonNull public String getMyFavoriteString() { ... } This makes the style more consistent (the existing JGit code base tends to lean toward the second style) and makes the source code better reflect how the annotation is parsed, as a METHOD annotation. Longer term, we should switch to a TYPE_USE annotation and switch to the first style. Noticed using a style checker that follows https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations Change-Id: I9b9fa08035d805ca660520f812a84d2f47eff507 Reported-by: Ivan Frade Signed-off-by: Jonathan Nieder --- .../org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java | 3 ++- .../org/eclipse/jgit/events/WorkingTreeModifiedEvent.java | 6 ++++-- .../src/org/eclipse/jgit/gitrepo/ManifestParser.java | 3 ++- .../src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java index 955eca0c3..feb8b4ae5 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java @@ -227,7 +227,8 @@ private static Protocol.ExpiringAction getSshAuthentication( * @throws IOException * in case of any error. */ - public static @NonNull HttpConnection getLfsContentConnection( + @NonNull + public static HttpConnection getLfsContentConnection( Repository repo, Protocol.Action action, String method) throws IOException { URL contentUrl = new URL(action.href); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/events/WorkingTreeModifiedEvent.java b/org.eclipse.jgit/src/org/eclipse/jgit/events/WorkingTreeModifiedEvent.java index 9fbcc4dd5..afd7889f8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/events/WorkingTreeModifiedEvent.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/events/WorkingTreeModifiedEvent.java @@ -94,7 +94,8 @@ public boolean isEmpty() { * * @return the set */ - public @NonNull Collection getModified() { + @NonNull + public Collection getModified() { Collection result = modified; if (result == null) { result = Collections.emptyList(); @@ -109,7 +110,8 @@ public boolean isEmpty() { * * @return the set */ - public @NonNull Collection getDeleted() { + @NonNull + public Collection getDeleted() { Collection result = deleted; if (result == null) { result = Collections.emptyList(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java index 26e783ddd..8e463415b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java @@ -358,7 +358,8 @@ public List getProjects() { * * @return filtered projects list reference, never null */ - public @NonNull List getFilteredProjects() { + @NonNull + public List getFilteredProjects() { return filteredProjects; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java index 891c7f23b..6a66cf682 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java @@ -293,7 +293,8 @@ private static IllegalArgumentException notTimeUnit(String section, /** {@inheritDoc} */ @Override - public @NonNull List getRefSpecs(Config config, String section, + @NonNull + public List getRefSpecs(Config config, String section, String subsection, String name) { String[] values = config.getStringList(section, subsection, name); List result = new ArrayList<>(values.length);