From 61d832026aa25004d752b7117e614501c57e9d9a Mon Sep 17 00:00:00 2001 From: Lewis John McGibbney Date: Tue, 15 Oct 2019 22:41:23 -0700 Subject: [PATCH 1/6] ANY23-445 Review spotbugs issues --- .../apache/any23/configuration/DefaultConfiguration.java | 8 +++----- api/src/main/java/org/apache/any23/vocab/HCard.java | 7 +++---- api/src/main/java/org/apache/any23/vocab/HEntry.java | 4 ++-- api/src/main/java/org/apache/any23/vocab/HItem.java | 2 +- api/src/main/java/org/apache/any23/vocab/HRecipe.java | 8 ++++---- api/src/main/java/org/apache/any23/vocab/HResume.java | 3 +-- api/src/main/java/org/apache/any23/vocab/OGP.java | 5 ----- api/src/main/java/org/apache/any23/vocab/OGPArticle.java | 5 ----- api/src/main/java/org/apache/any23/vocab/OGPBook.java | 5 ----- api/src/main/java/org/apache/any23/vocab/OGPMusic.java | 5 ----- api/src/main/java/org/apache/any23/vocab/OGPProfile.java | 5 ----- api/src/main/java/org/apache/any23/vocab/OGPVideo.java | 5 ----- api/src/main/java/org/apache/any23/vocab/SINDICE.java | 5 ----- api/src/main/java/org/apache/any23/vocab/Vocabulary.java | 6 +++--- 14 files changed, 17 insertions(+), 56 deletions(-) diff --git a/api/src/main/java/org/apache/any23/configuration/DefaultConfiguration.java b/api/src/main/java/org/apache/any23/configuration/DefaultConfiguration.java index ce346b592..e83bbab61 100644 --- a/api/src/main/java/org/apache/any23/configuration/DefaultConfiguration.java +++ b/api/src/main/java/org/apache/any23/configuration/DefaultConfiguration.java @@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; +import java.io.InputStream; import java.util.Properties; /** @@ -74,8 +75,8 @@ public static synchronized ModifiableConfiguration copy() { private static Properties loadDefaultProperties() { final Properties properties = new Properties(); - try { - properties.load( DefaultConfiguration.class.getResourceAsStream(DEFAULT_CONFIG_FILE) ); + try(InputStream is = DefaultConfiguration.class.getResourceAsStream(DEFAULT_CONFIG_FILE)) { + properties.load(is); } catch (IOException ioe) { throw new IllegalStateException("Error while loading default configuration.", ioe); } @@ -129,9 +130,6 @@ public synchronized int getPropertyIntOrFail(String propertyName) { @Override public synchronized boolean getFlagProperty(final String propertyName) { final String value = getPropertyOrFail(propertyName); - if(value == null) { - return false; - } if(FLAG_PROPERTY_ON.equals(value)) { return true; } diff --git a/api/src/main/java/org/apache/any23/vocab/HCard.java b/api/src/main/java/org/apache/any23/vocab/HCard.java index 75ba514f6..eebbec1be 100644 --- a/api/src/main/java/org/apache/any23/vocab/HCard.java +++ b/api/src/main/java/org/apache/any23/vocab/HCard.java @@ -36,10 +36,9 @@ public static HCard getInstance() { return instance; } - public IRI Card = createClass(NS, "Card"); - public IRI Address = createClass(NS, "Address"); - public IRI Geo = createClass(NS, "Geo"); - + public IRI card = createClass(NS, "Card"); + public IRI address = createClass(NS, "Address"); + public IRI _Geo = createClass(NS, "Geo"); public IRI name = createProperty(NS, "name"); public IRI honorific_prefix = createProperty(NS, "honorific-prefix"); diff --git a/api/src/main/java/org/apache/any23/vocab/HEntry.java b/api/src/main/java/org/apache/any23/vocab/HEntry.java index a5e6db954..a410d58cb 100644 --- a/api/src/main/java/org/apache/any23/vocab/HEntry.java +++ b/api/src/main/java/org/apache/any23/vocab/HEntry.java @@ -37,7 +37,7 @@ public static HEntry getInstance() { return instance; } - public IRI Entry = createClass(NS, "Entry"); + public IRI entry = createClass(NS, "Entry"); public IRI author = createClass(NS, "author"); public IRI location = createClass(NS, "location"); @@ -51,7 +51,7 @@ public static HEntry getInstance() { public IRI url = createProperty(NS, "url"); public IRI uid = createProperty(NS, "uid"); public IRI syndication = createProperty(NS, "syndication"); - public IRI in_reply_to = createProperty(NS, "in-reply-to"); + public IRI inReplyTo = createProperty(NS, "in-reply-to"); private HEntry() { super(NS); diff --git a/api/src/main/java/org/apache/any23/vocab/HItem.java b/api/src/main/java/org/apache/any23/vocab/HItem.java index 0843eaddb..f68595f82 100644 --- a/api/src/main/java/org/apache/any23/vocab/HItem.java +++ b/api/src/main/java/org/apache/any23/vocab/HItem.java @@ -37,7 +37,7 @@ public static HItem getInstance() { return instance; } - public IRI Item = createClass(NS, "Item"); + public IRI item = createClass(NS, "Item"); public IRI name = createProperty(NS, "name"); public IRI url = createProperty(NS, "url"); public IRI photo = createProperty(NS, "photo"); diff --git a/api/src/main/java/org/apache/any23/vocab/HRecipe.java b/api/src/main/java/org/apache/any23/vocab/HRecipe.java index 0124a5463..e3dabd5f6 100644 --- a/api/src/main/java/org/apache/any23/vocab/HRecipe.java +++ b/api/src/main/java/org/apache/any23/vocab/HRecipe.java @@ -38,10 +38,10 @@ public static HRecipe getInstance() { } // Resources. - public IRI Recipe = createClass(NS, "Recipe"); - public IRI Duration = createClass(NS, "Duration"); - public IRI Ingredient = createClass(NS, "Ingredient"); - public IRI Nutrition = createClass(NS, "Nutrition"); + public IRI recipe = createClass(NS, "Recipe"); + public IRI _Duration = createClass(NS, "Duration"); + public IRI _Ingredient = createClass(NS, "Ingredient"); + public IRI _Nutrition = createClass(NS, "Nutrition"); // Properties. public IRI fn = createProperty(NS, "fn"); diff --git a/api/src/main/java/org/apache/any23/vocab/HResume.java b/api/src/main/java/org/apache/any23/vocab/HResume.java index f8ee68e7d..41c748013 100644 --- a/api/src/main/java/org/apache/any23/vocab/HResume.java +++ b/api/src/main/java/org/apache/any23/vocab/HResume.java @@ -36,13 +36,12 @@ public static HResume getInstance() { return instance; } - public IRI Resume = createClass(NS, "Resume"); + public IRI resume = createClass(NS, "Resume"); public IRI education = createClass(NS, "education"); public IRI experience = createClass(NS, "experience"); public IRI contact = createClass(NS, "contact"); public IRI affiliation = createClass(NS, "affiliation"); - public IRI name = createProperty(NS, "name"); public IRI summary = createProperty(NS, "summary"); public IRI skill = createProperty(NS, "skill"); diff --git a/api/src/main/java/org/apache/any23/vocab/OGP.java b/api/src/main/java/org/apache/any23/vocab/OGP.java index 5ee0e927f..9276555c5 100644 --- a/api/src/main/java/org/apache/any23/vocab/OGP.java +++ b/api/src/main/java/org/apache/any23/vocab/OGP.java @@ -172,11 +172,6 @@ public static OGP getInstance() { public final IRI audioType = createProperty(AUDIO__TYPE); public final IRI audioAlt = createProperty(AUDIO__ALT); - @SuppressWarnings("unused") - private IRI createClass(String localName) { - return createClass(NS, localName); - } - private IRI createProperty(String localName) { return createProperty(NS, localName); } diff --git a/api/src/main/java/org/apache/any23/vocab/OGPArticle.java b/api/src/main/java/org/apache/any23/vocab/OGPArticle.java index 0381bd470..d1ffb8b74 100644 --- a/api/src/main/java/org/apache/any23/vocab/OGPArticle.java +++ b/api/src/main/java/org/apache/any23/vocab/OGPArticle.java @@ -71,11 +71,6 @@ public static OGPArticle getInstance() { public final IRI articleSection = createProperty(ARTICLE__SECTION); public final IRI articleTag = createProperty(ARTICLE__TAG); - @SuppressWarnings("unused") - private IRI createClass(String localName) { - return createClass(NS, localName); - } - private IRI createProperty(String localName) { return createProperty(NS, localName); } diff --git a/api/src/main/java/org/apache/any23/vocab/OGPBook.java b/api/src/main/java/org/apache/any23/vocab/OGPBook.java index 2f2debc31..7f50ec564 100644 --- a/api/src/main/java/org/apache/any23/vocab/OGPBook.java +++ b/api/src/main/java/org/apache/any23/vocab/OGPBook.java @@ -63,11 +63,6 @@ public static OGPBook getInstance() { public final IRI bookReleaseDate = createProperty(BOOK__RELEASE_DATE); public final IRI bookTag = createProperty(BOOK__TAG); - @SuppressWarnings("unused") - private IRI createClass(String localName) { - return createClass(NS, localName); - } - private IRI createProperty(String localName) { return createProperty(NS, localName); } diff --git a/api/src/main/java/org/apache/any23/vocab/OGPMusic.java b/api/src/main/java/org/apache/any23/vocab/OGPMusic.java index 405b85eb3..ae2ceb19a 100644 --- a/api/src/main/java/org/apache/any23/vocab/OGPMusic.java +++ b/api/src/main/java/org/apache/any23/vocab/OGPMusic.java @@ -99,11 +99,6 @@ public static OGPMusic getInstance() { public final IRI musicCreator = createProperty(MUSIC__CREATOR); - @SuppressWarnings("unused") - private IRI createClass(String localName) { - return createClass(NS, localName); - } - private IRI createProperty(String localName) { return createProperty(NS, localName); } diff --git a/api/src/main/java/org/apache/any23/vocab/OGPProfile.java b/api/src/main/java/org/apache/any23/vocab/OGPProfile.java index 48b0b3be5..419c42a13 100644 --- a/api/src/main/java/org/apache/any23/vocab/OGPProfile.java +++ b/api/src/main/java/org/apache/any23/vocab/OGPProfile.java @@ -63,11 +63,6 @@ public static OGPProfile getInstance() { public final IRI profileUsername = createProperty(PROFILE__USERNAME); public final IRI profileGender = createProperty(PROFILE__GENDER); - @SuppressWarnings("unused") - private IRI createClass(String localName) { - return createClass(NS, localName); - } - private IRI createProperty(String localName) { return createProperty(NS, localName); } diff --git a/api/src/main/java/org/apache/any23/vocab/OGPVideo.java b/api/src/main/java/org/apache/any23/vocab/OGPVideo.java index 774c7fd9d..ee241cf7b 100644 --- a/api/src/main/java/org/apache/any23/vocab/OGPVideo.java +++ b/api/src/main/java/org/apache/any23/vocab/OGPVideo.java @@ -78,11 +78,6 @@ public static OGPVideo getInstance() { public final IRI videoTag = createProperty(VIDEO__TAG); public final IRI videoSeries = createProperty(VIDEO__SERIES); - @SuppressWarnings("unused") - private IRI createClass(String localName) { - return createClass(NS, localName); - } - private IRI createProperty(String localName) { return createProperty(NS, localName); } diff --git a/api/src/main/java/org/apache/any23/vocab/SINDICE.java b/api/src/main/java/org/apache/any23/vocab/SINDICE.java index 287f04cd3..76000c912 100644 --- a/api/src/main/java/org/apache/any23/vocab/SINDICE.java +++ b/api/src/main/java/org/apache/any23/vocab/SINDICE.java @@ -93,11 +93,6 @@ public static SINDICE getInstance() { */ public final IRI date = createProperty(DATE); - - private IRI createClass(String localName) { - return createClass(NS, localName); - } - private IRI createProperty(String localName) { return createProperty(NS, localName); } diff --git a/api/src/main/java/org/apache/any23/vocab/Vocabulary.java b/api/src/main/java/org/apache/any23/vocab/Vocabulary.java index 7e4de653d..57807023f 100644 --- a/api/src/main/java/org/apache/any23/vocab/Vocabulary.java +++ b/api/src/main/java/org/apache/any23/vocab/Vocabulary.java @@ -142,12 +142,12 @@ public IRI getProperty(String name, IRI defaultValue) { */ public IRI getPropertyCamelCase(String property) { String[] names = property.split("\\W"); - String camelCase = names[0]; + StringBuffer camelCase = new StringBuffer().append(names[0]); for (int i = 1; i < names.length; i++) { String tmp = names[i]; - camelCase += tmp.replaceFirst("(.)", tmp.substring(0, 1).toUpperCase(java.util.Locale.ROOT)); + camelCase.append(tmp.replaceFirst("(.)", tmp.substring(0, 1).toUpperCase(java.util.Locale.ROOT))); } - return getProperty(camelCase); + return getProperty(camelCase.toString()); } /** From cde327754b9afccfbb594de955495fdb4958aacf Mon Sep 17 00:00:00 2001 From: Lewis John McGibbney Date: Wed, 16 Oct 2019 07:42:03 -0700 Subject: [PATCH 2/6] ANY23-445 Review spotbugs issues --- api/src/main/java/org/apache/any23/vocab/Vocabulary.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/org/apache/any23/vocab/Vocabulary.java b/api/src/main/java/org/apache/any23/vocab/Vocabulary.java index 57807023f..b226d12a3 100644 --- a/api/src/main/java/org/apache/any23/vocab/Vocabulary.java +++ b/api/src/main/java/org/apache/any23/vocab/Vocabulary.java @@ -142,7 +142,7 @@ public IRI getProperty(String name, IRI defaultValue) { */ public IRI getPropertyCamelCase(String property) { String[] names = property.split("\\W"); - StringBuffer camelCase = new StringBuffer().append(names[0]); + StringBuilder camelCase = new StringBuilder(property.length()).append(names[0]); for (int i = 1; i < names.length; i++) { String tmp = names[i]; camelCase.append(tmp.replaceFirst("(.)", tmp.substring(0, 1).toUpperCase(java.util.Locale.ROOT))); From dcef1b43a7904268882746996b05b535903ece48 Mon Sep 17 00:00:00 2001 From: Lewis John McGibbney Date: Wed, 16 Oct 2019 19:52:29 -0700 Subject: [PATCH 3/6] ANY23-445 Review spotbugs issues --- api/pom.xml | 12 +++++++++++- api/src/main/java/org/apache/any23/vocab/HCard.java | 6 +++--- api/src/main/java/org/apache/any23/vocab/HEntry.java | 4 ++-- api/src/main/java/org/apache/any23/vocab/HItem.java | 2 +- .../main/java/org/apache/any23/vocab/HRecipe.java | 8 ++++---- .../main/java/org/apache/any23/vocab/HResume.java | 2 +- pom.xml | 6 +++--- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index 18ea19b01..b25d53077 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -28,7 +28,7 @@ apache-any23-api Apache Any23 :: Base API - Any23 library external API. + Any23 library external API @@ -89,6 +89,16 @@ + + + com.github.spotbugs + spotbugs-maven-plugin + ${maven-spotbugs-plugin.version} + + UnreadFields,Naming + + + diff --git a/api/src/main/java/org/apache/any23/vocab/HCard.java b/api/src/main/java/org/apache/any23/vocab/HCard.java index eebbec1be..24e49e89f 100644 --- a/api/src/main/java/org/apache/any23/vocab/HCard.java +++ b/api/src/main/java/org/apache/any23/vocab/HCard.java @@ -36,9 +36,9 @@ public static HCard getInstance() { return instance; } - public IRI card = createClass(NS, "Card"); - public IRI address = createClass(NS, "Address"); - public IRI _Geo = createClass(NS, "Geo"); + public IRI Card = createClass(NS, "Card"); + public IRI Address = createClass(NS, "Address"); + public IRI Geo = createClass(NS, "Geo"); public IRI name = createProperty(NS, "name"); public IRI honorific_prefix = createProperty(NS, "honorific-prefix"); diff --git a/api/src/main/java/org/apache/any23/vocab/HEntry.java b/api/src/main/java/org/apache/any23/vocab/HEntry.java index a410d58cb..a5e6db954 100644 --- a/api/src/main/java/org/apache/any23/vocab/HEntry.java +++ b/api/src/main/java/org/apache/any23/vocab/HEntry.java @@ -37,7 +37,7 @@ public static HEntry getInstance() { return instance; } - public IRI entry = createClass(NS, "Entry"); + public IRI Entry = createClass(NS, "Entry"); public IRI author = createClass(NS, "author"); public IRI location = createClass(NS, "location"); @@ -51,7 +51,7 @@ public static HEntry getInstance() { public IRI url = createProperty(NS, "url"); public IRI uid = createProperty(NS, "uid"); public IRI syndication = createProperty(NS, "syndication"); - public IRI inReplyTo = createProperty(NS, "in-reply-to"); + public IRI in_reply_to = createProperty(NS, "in-reply-to"); private HEntry() { super(NS); diff --git a/api/src/main/java/org/apache/any23/vocab/HItem.java b/api/src/main/java/org/apache/any23/vocab/HItem.java index f68595f82..0843eaddb 100644 --- a/api/src/main/java/org/apache/any23/vocab/HItem.java +++ b/api/src/main/java/org/apache/any23/vocab/HItem.java @@ -37,7 +37,7 @@ public static HItem getInstance() { return instance; } - public IRI item = createClass(NS, "Item"); + public IRI Item = createClass(NS, "Item"); public IRI name = createProperty(NS, "name"); public IRI url = createProperty(NS, "url"); public IRI photo = createProperty(NS, "photo"); diff --git a/api/src/main/java/org/apache/any23/vocab/HRecipe.java b/api/src/main/java/org/apache/any23/vocab/HRecipe.java index e3dabd5f6..0124a5463 100644 --- a/api/src/main/java/org/apache/any23/vocab/HRecipe.java +++ b/api/src/main/java/org/apache/any23/vocab/HRecipe.java @@ -38,10 +38,10 @@ public static HRecipe getInstance() { } // Resources. - public IRI recipe = createClass(NS, "Recipe"); - public IRI _Duration = createClass(NS, "Duration"); - public IRI _Ingredient = createClass(NS, "Ingredient"); - public IRI _Nutrition = createClass(NS, "Nutrition"); + public IRI Recipe = createClass(NS, "Recipe"); + public IRI Duration = createClass(NS, "Duration"); + public IRI Ingredient = createClass(NS, "Ingredient"); + public IRI Nutrition = createClass(NS, "Nutrition"); // Properties. public IRI fn = createProperty(NS, "fn"); diff --git a/api/src/main/java/org/apache/any23/vocab/HResume.java b/api/src/main/java/org/apache/any23/vocab/HResume.java index 41c748013..6e3ce325f 100644 --- a/api/src/main/java/org/apache/any23/vocab/HResume.java +++ b/api/src/main/java/org/apache/any23/vocab/HResume.java @@ -36,7 +36,7 @@ public static HResume getInstance() { return instance; } - public IRI resume = createClass(NS, "Resume"); + public IRI Resume = createClass(NS, "Resume"); public IRI education = createClass(NS, "education"); public IRI experience = createClass(NS, "experience"); public IRI contact = createClass(NS, "contact"); diff --git a/pom.xml b/pom.xml index 577b5fdc7..9b1cce0be 100644 --- a/pom.xml +++ b/pom.xml @@ -311,7 +311,7 @@ 1.6 3.2.3 3.2.1 - 3.1.12.2 + 3.1.12.2 2.6 From 842d3f62a5bad4bb8b77d92d40f00559cc9ba2a2 Mon Sep 17 00:00:00 2001 From: Lewis John McGibbney Date: Wed, 16 Oct 2019 20:41:30 -0700 Subject: [PATCH 4/6] ANY23-445 Review spotbugs issues --- api/pom.xml | 2 +- .../main/java/org/apache/any23/extractor/ExtractorGroup.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index b25d53077..ae368594f 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -95,7 +95,7 @@ spotbugs-maven-plugin ${maven-spotbugs-plugin.version} - UnreadFields,Naming + UnreadFields,Naming,FindUnrelatedTypesInGenericContainer diff --git a/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java b/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java index 4e77690ea..07ed2fb41 100644 --- a/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java +++ b/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java @@ -78,6 +78,7 @@ public boolean allExtractorsSupportAllContentTypes() { return true; } + @SuppressWarnings("unlikely-arg-type") private boolean supportsAllContentTypes(ExtractorFactory factory) { return factory.getSupportedMIMETypes().contains("*/*"); } From ff3ce3722529787f766725258db42d9659819d5c Mon Sep 17 00:00:00 2001 From: Lewis John McGibbney Date: Thu, 17 Oct 2019 08:37:29 -0700 Subject: [PATCH 5/6] ANY23-445 Review spotbugs issues --- .../main/java/org/apache/any23/extractor/ExtractorGroup.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java b/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java index 07ed2fb41..32d619b60 100644 --- a/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java +++ b/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java @@ -78,8 +78,7 @@ public boolean allExtractorsSupportAllContentTypes() { return true; } - @SuppressWarnings("unlikely-arg-type") - private boolean supportsAllContentTypes(ExtractorFactory factory) { + private boolean supportsAllContentTypes(ExtractorFactory factory) { return factory.getSupportedMIMETypes().contains("*/*"); } From ead2757a9f6059e9e85e127737ce03c85992c451 Mon Sep 17 00:00:00 2001 From: Lewis John McGibbney Date: Thu, 17 Oct 2019 08:46:37 -0700 Subject: [PATCH 6/6] ANY23-445 Review spotbugs issues --- .../java/org/apache/any23/extractor/ExtractorFactory.java | 2 +- .../java/org/apache/any23/extractor/ExtractorGroup.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/org/apache/any23/extractor/ExtractorFactory.java b/api/src/main/java/org/apache/any23/extractor/ExtractorFactory.java index 67464904f..3ed0f7abf 100644 --- a/api/src/main/java/org/apache/any23/extractor/ExtractorFactory.java +++ b/api/src/main/java/org/apache/any23/extractor/ExtractorFactory.java @@ -37,7 +37,7 @@ public interface ExtractorFactory> extends ExtractorDescr /** * Supports wildcards, e.g. "*/*" for blind extractors that merely call a web service. - * @return a {@link java.util.Collection} of supported mimetypes. + * @return a {@link java.util.Collection} of supported {@link org.apache.any23.mime.MIMEType}'s. */ Collection getSupportedMIMETypes(); diff --git a/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java b/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java index 32d619b60..be6923f95 100644 --- a/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java +++ b/api/src/main/java/org/apache/any23/extractor/ExtractorGroup.java @@ -24,8 +24,8 @@ import java.util.Iterator; /** - * It simple models a group of {@link ExtractorFactory} providing - * simple accessing methods. + * Models a group of {@link ExtractorFactory} objcts providing + * simple accessor methods. */ public class ExtractorGroup implements Iterable> { @@ -78,7 +78,7 @@ public boolean allExtractorsSupportAllContentTypes() { return true; } - private boolean supportsAllContentTypes(ExtractorFactory factory) { + private boolean supportsAllContentTypes(ExtractorFactory factory) { return factory.getSupportedMIMETypes().contains("*/*"); }