Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SHRINKRES-321] Resolve code style issues #185

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static PackagingType of(String typeName) throws IllegalArgumentException
*/
public static PackagingType fromCache(String typeName) throws IllegalArgumentException {

if (typeName == null || typeName.length() == 0) {
if (typeName == null || typeName.isEmpty()) {
throw new IllegalArgumentException("Packaging type must not be null nor empty.");
}
// return from cache if available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public String toString() {
*/
public static ScopeType fromScopeType(String scopeName) throws IllegalArgumentException {

if (scopeName == null || scopeName.length() == 0) {
if (scopeName == null || scopeName.isEmpty()) {
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST, "Empty scope was replaced with default {0}", COMPILE.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ public final String getVersion() {
public final String toCanonicalForm() {

final StringBuilder sb = new StringBuilder(super.toCanonicalForm());
if (version == null || version.length() == 0) {
if (version == null || version.isEmpty()) {
return sb.toString();
}
if (classifier != null && classifier.length() > 0 && packaging != null) {
if (classifier != null && !classifier.isEmpty() && packaging != null) {
sb.append(SEPARATOR_COORDINATE).append(packaging.getId()).append(SEPARATOR_COORDINATE)
.append(classifier).append(SEPARATOR_COORDINATE).append(version);
}
if ((classifier == null || classifier.length() == 0) && packaging != null) {
if ((classifier == null || classifier.isEmpty()) && packaging != null) {
sb.append(SEPARATOR_COORDINATE).append(packaging.getId()).append(SEPARATOR_COORDINATE).append(version);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private MavenCoordinates() {
*/
public static MavenCoordinate createCoordinate(final String canonicalForm) throws IllegalArgumentException,
CoordinateParseException {
if (canonicalForm == null || canonicalForm.length() == 0) {
if (canonicalForm == null || canonicalForm.isEmpty()) {
throw new IllegalArgumentException("canonical form is required");
}
final MavenCoordinateParser parser = MavenCoordinateParser.parse(canonicalForm);
Expand All @@ -71,10 +71,10 @@ public static MavenCoordinate createCoordinate(final String canonicalForm) throw
*/
public static MavenCoordinate createCoordinate(final String groupId, final String artifactId, final String version,
final PackagingType packaging, final String classifier) throws IllegalArgumentException {
if (groupId == null || groupId.length() == 0) {
if (groupId == null || groupId.isEmpty()) {
throw new IllegalArgumentException("groupId is required");
}
if (artifactId == null || artifactId.length() == 0) {
if (artifactId == null || artifactId.isEmpty()) {
throw new IllegalArgumentException("artifactId is required");
}
final MavenCoordinateImpl coordinate = new MavenCoordinateImpl(groupId, artifactId, version, packaging,
Expand Down Expand Up @@ -143,12 +143,12 @@ static MavenCoordinateParser parse(final String coordinates) throws CoordinatePa
parser.version = position3;
break;
case 3:
parser.type = (position3 == null || position3.length() == 0) ? PackagingType.JAR
parser.type = (position3 == null || position3.isEmpty()) ? PackagingType.JAR
: toPackagingType(position3);
parser.version = position4;
break;
default:
parser.type = (position3 == null || position3.length() == 0) ? PackagingType.JAR
parser.type = (position3 == null || position3.isEmpty()) ? PackagingType.JAR
: toPackagingType(position3);
parser.classifier = position4;
parser.version = position5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private MavenDependencies() {
public static MavenDependency createDependency(final String canonicalForm, final ScopeType scope,
final boolean optional, final MavenDependencyExclusion... exclusions) throws IllegalArgumentException,
CoordinateParseException {
if (canonicalForm == null || canonicalForm.length() == 0) {
if (canonicalForm == null || canonicalForm.isEmpty()) {
throw new IllegalArgumentException("canonical form is required");
}
final MavenCoordinate delegate = MavenCoordinates.createCoordinate(canonicalForm);
Expand Down Expand Up @@ -134,7 +134,7 @@ private static MavenDependency newInstance(final MavenCoordinate coordinate, fin
*/
public static MavenDependencyExclusion createExclusion(final String canonicalForm) throws IllegalArgumentException,
CoordinateParseException {
if (canonicalForm == null || canonicalForm.length() == 0) {
if (canonicalForm == null || canonicalForm.isEmpty()) {
throw new IllegalArgumentException("canonical form is required");
}
final StringTokenizer tokenizer = new StringTokenizer(canonicalForm,
Expand Down Expand Up @@ -167,10 +167,10 @@ public static MavenDependencyExclusion createExclusion(final String canonicalFor
*/
public static MavenDependencyExclusion createExclusion(final String groupId, final String artifactId)
throws IllegalArgumentException {
if (groupId == null || groupId.length() == 0) {
if (groupId == null || groupId.isEmpty()) {
throw new IllegalArgumentException("groupId must be specified");
}
if (artifactId == null || artifactId.length() == 0) {
if (artifactId == null || artifactId.isEmpty()) {
throw new IllegalArgumentException("groupId must be specified");
}
final MavenDependencyExclusion exclusion = new MavenDependencyExclusionImpl(groupId, artifactId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class MavenGABaseImpl implements MavenGABase {
MavenGABaseImpl(final String groupId, final String artifactId) {

// Precondition checks
assert groupId != null && groupId.length() > 0 : "groupId is required";
assert artifactId != null && artifactId.length() > 0 : "artifactId is required";
assert groupId != null && !groupId.isEmpty() : "groupId is required";
assert artifactId != null && !artifactId.isEmpty() : "artifactId is required";

// Set properties
this.groupId = groupId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public boolean accepts(final MavenDependency dependency, final List<MavenDepende
}

if (rejectTransitives) {
if (dependencyAncestors != null && dependencyAncestors.size() != 0) {
if (dependencyAncestors != null && !dependencyAncestors.isEmpty()) {
return dependencyAncestors.get(0).equals(dependency);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void properties() {
Assert.assertEquals(version, coordinate.getVersion());
Assert.assertEquals(packaging, coordinate.getPackaging());
Assert.assertEquals(classifier, coordinate.getClassifier());
Assert.assertEquals(groupId + ":" + artifactId + ":" + packaging.toString() + ":" + classifier + ":" + version,
Assert.assertEquals(groupId + ":" + artifactId + ":" + packaging + ":" + classifier + ":" + version,
coordinate.toCanonicalForm());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ public Map<String, String> getAdditionalCompilerArgs() {
Map<String, String> compilerArgumentsAsMap = new HashMap<String, String>(additionalCompilerArguments.size()
+ additionalCompilerArgs.size() + 1);

if (additionalCompilerArgument.length() > 0) {
if (!additionalCompilerArgument.isEmpty()) {
compilerArgumentsAsMap.put(additionalCompilerArgument, null);
}
if (additionalCompilerArguments.size() > 0) {
if (!additionalCompilerArguments.isEmpty()) {
compilerArgumentsAsMap.putAll(additionalCompilerArguments);
}
if (additionalCompilerArgs.size() > 0) {
if (!additionalCompilerArgs.isEmpty()) {
for (String value : additionalCompilerArgs) {
compilerArgumentsAsMap.put(value, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ConfigurationUtils {
static String valueAsString(Map<String, Object> map, Key key, String defaultValue) {
Validate.notNullOrEmpty(key.key, "Key for plugin configuration must be set");
if (map.containsKey(key.key)) {
return map.get(key.key).toString().length() == 0 ? defaultValue : map.get(key.key).toString();
return map.get(key.key).toString().isEmpty() ? defaultValue : map.get(key.key).toString();
}
return defaultValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ ManifestBuilder loadFile() throws MavenImporterException {
}

ManifestBuilder addManifestEntries() {
if (getManifestEntries().size() > 0) {
if (!getManifestEntries().isEmpty()) {
for (Map.Entry<String, String> entry : getManifestEntries().entrySet()) {
addMainAttribute(entry.getKey(), entry.getValue());
}
Expand All @@ -228,7 +228,7 @@ ManifestBuilder addManifestEntries() {
}

ManifestBuilder addManifestSections() {
if (getManifestSections().size() > 0) {
if (!getManifestSections().isEmpty()) {
for (Map.Entry<String, Map<String, String>> entry : getManifestSections().entrySet()) {
for (Map.Entry<String, String> attrs : entry.getValue().entrySet()) {
addSectionAttribute(entry.getKey(), attrs.getKey(), attrs.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void stateNotNull(final Object obj, final String message) throws I
* @throws IllegalArgumentException Thrown if {@code collection} is {@code null} or empty
*/
public static void notEmpty(final Collection<?> collection, final String message) throws IllegalArgumentException {
if (collection == null || collection.size() == 0) {
if (collection == null || collection.isEmpty()) {
throw new IllegalArgumentException(message);
}
}
Expand All @@ -78,7 +78,7 @@ public static void notEmpty(final Collection<?> collection, final String message
* @return {@code true} if specified String is null or empty, {@code false} otherwise
*/
public static boolean isNullOrEmpty(final String string) {
return (string == null || string.length() == 0);
return (string == null || string.isEmpty());
}

/**
Expand All @@ -89,7 +89,7 @@ public static boolean isNullOrEmpty(final String string) {
* @return {@code true} if specified String is null or empty, {@code false} otherwise
*/
public static boolean isNullOrEmptyOrQuestionMark(final String string) {
return (string == null || string.length() == 0 || "?".equals(string));
return (string == null || string.isEmpty() || "?".equals(string));
}

/**
Expand All @@ -100,7 +100,7 @@ public static boolean isNullOrEmptyOrQuestionMark(final String string) {
* @throws IllegalArgumentException Thrown if string is null
*/
public static void notNullOrEmpty(final String string, final String message) throws IllegalArgumentException {
if (string == null || string.length() == 0) {
if (string == null || string.isEmpty()) {
throw new IllegalArgumentException(message);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ private void printStatus(String status) {
for (int i = 0; i < projectPom.length(); i++) {
borders.append("=");
}
System.out.println(borders.toString());
System.out.println(borders);
System.out.println("=== Embedded Maven build " + status + ": " + projectPom + " ===");
System.out.println(borders.toString());
System.out.println(borders);
}

private BuiltProject getBuiltProject(InvocationResult result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected MavenArtifactInfoImpl(final Artifact artifact, final ScopeType scopeTy
final List<DependencyNode> children, boolean optional) {

final PackagingType packaging = PackagingType.of(artifact.getProperty(ArtifactProperties.TYPE, artifact.getExtension()));
final String classifier = artifact.getClassifier().length() == 0 ? packaging.getClassifier() : artifact.getClassifier();
final String classifier = artifact.getClassifier().isEmpty() ? packaging.getClassifier() : artifact.getClassifier();

this.mavenCoordinate = MavenCoordinates.createCoordinate(artifact.getGroupId(), artifact.getArtifactId(),
artifact.getBaseVersion(), packaging, classifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public String toString() {

return "MavenResolvedVersionsImpl[" +
"artifact=" + artifact +
", versions=" + versionsBuilder.toString() +
", versions=" + versionsBuilder +
']';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private RESOLVESTAGETYPE addDependencies(final String... coordinates) throws Coo
throw new IllegalArgumentException("At least one coordinate must be specified");
}
for (final String coordinate : coordinates) {
if (coordinate == null || coordinate.length() == 0) {
if (coordinate == null || coordinate.isEmpty()) {
throw new IllegalArgumentException("null dependency not permitted");
}
final MavenDependency dependency = this.resolveDependency(coordinate);
Expand All @@ -178,7 +178,7 @@ private RESOLVESTAGETYPE addDependencies(final String... coordinates) throws Coo
}

private MavenDependency resolveDependency(final String coordinate) {
assert coordinate != null && coordinate.length() > 0 : "Coordinate is required";
assert coordinate != null && !coordinate.isEmpty() : "Coordinate is required";
final MavenCoordinate newCoordinate = MavenCoordinates.createCoordinate(coordinate);
final MavenDependency declared = MavenDependencies.createDependency(newCoordinate, null, false);
final MavenDependency resolved = this.resolveDependency(declared);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ private SettingsBuildingRequest getDefaultSettingsBuildingRequest() {
request.setGlobalSettingsFile(new File(DEFAULT_GLOBAL_SETTINGS_PATH));
request.setUserSettingsFile(new File(DEFAULT_USER_SETTINGS_PATH));
// set alternate files
if (altUserSettings != null && altUserSettings.length() > 0) {
if (altUserSettings != null && !altUserSettings.isEmpty()) {
request.setUserSettingsFile(new File(altUserSettings));
}

if (altGlobalSettings != null && altGlobalSettings.length() > 0) {
if (altGlobalSettings != null && !altGlobalSettings.isEmpty()) {
request.setGlobalSettingsFile(new File(altGlobalSettings));
}

Expand All @@ -221,15 +221,15 @@ private Settings decryptPasswords(Settings settings) {
String altSecuritySettings = SecurityActions.getProperty(ALT_SECURITY_SETTINGS_XML_LOCATION);

// set alternate file
if (altSecuritySettings != null && altSecuritySettings.length() > 0) {
if (altSecuritySettings != null && !altSecuritySettings.isEmpty()) {
securitySettings = new File(altSecuritySettings);
}

SettingsDecrypter decrypter = new MavenSettingsDecrypter(securitySettings);
SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(settings);
SettingsDecryptionResult result = decrypter.decrypt(request);

if (result.getProblems().size() > 0) {
if (!result.getProblems().isEmpty()) {
StringBuilder sb = new StringBuilder("Found ").append(result.getProblems().size())
.append(" problems while trying to decrypt settings configuration.");

Expand All @@ -251,13 +251,13 @@ private Settings decryptPasswords(Settings settings) {
private Settings enrichWithLocalRepository(Settings settings) {

// set default value if not set at all
if (settings.getLocalRepository() == null || settings.getLocalRepository().length() == 0) {
if (settings.getLocalRepository() == null || settings.getLocalRepository().isEmpty()) {
settings.setLocalRepository(DEFAULT_REPOSITORY_PATH);
}

// override any value with system property based location
String altLocalRepository = SecurityActions.getProperty(ALT_LOCAL_REPOSITORY_LOCATION);
if (altLocalRepository != null && altLocalRepository.length() > 0) {
if (altLocalRepository != null && !altLocalRepository.isEmpty()) {
settings.setLocalRepository(altLocalRepository);
}
return settings;
Expand All @@ -267,7 +267,7 @@ private Settings enrichWithLocalRepository(Settings settings) {
private Settings enrichWithOfflineMode(Settings settings) {

String goOffline = SecurityActions.getProperty(ALT_MAVEN_OFFLINE);
if (goOffline != null && goOffline.length() > 0) {
if (goOffline != null && !goOffline.isEmpty()) {
settings.setOffline(Boolean.valueOf(goOffline));
}

Expand Down
Loading
Loading