diff --git a/build.gradle b/build.gradle index a0df046b073..4bf16a16552 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ plugins { id 'idea' - id("org.openrewrite.rewrite") version("5.40.6") + id("org.openrewrite.rewrite") version("6.0.0") } // Enable following for debugging @@ -221,7 +221,9 @@ dependencies { xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2' xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '3.0.2' - rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:1.19.4")) + rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.0.0")) + rewrite("org.openrewrite.recipe:rewrite-logging-frameworks") + rewrite("org.openrewrite.recipe:rewrite-static-analysis") } clean { diff --git a/rewrite.yml b/rewrite.yml index 1c47907a588..23f9575c404 100644 --- a/rewrite.yml +++ b/rewrite.yml @@ -3,176 +3,171 @@ type: specs.openrewrite.org/v1beta/recipe name: org.jabref.config.rewrite.cleanup recipeList: # generated by - # find . -type f -name "*.java" -exec basename {} .java \; | awk '{print " - org.openrewrite.java.cleanup." $1}' | grep -v "Visitor" | grep -v "package-info" + # find . -type f -name "*.java" -exec basename {} .java \; | awk '{print " - org.openrewrite.staticanalysis." $1}' | grep -v "Visitor" | grep -v "package-info" # in rewrites source folder /rewrite-java/src/main/java/org/openrewrite/java/cleanup # Then, following to are removed: # Sometimes fails to produce correct results - # - org.openrewrite.java.cleanup.FinalizePrivateFields + # - org.openrewrite.staticanalysis.FinalizePrivateFields # Creates constructor at the end of the class which violates JabRef's code style - # - org.openrewrite.java.cleanup.HideUtilityClassConstructor + # - org.openrewrite.staticanalysis.HideUtilityClassConstructor # We are not relying on serialization, thus we do not want to maintain the serialVersionUID manually - # - org.openrewrite.java.cleanup.AddSerialVersionUidToSerializable + # - org.openrewrite.staticanalysis.AddSerialVersionUidToSerializable # Leads to "if (Boolean.TRUE.equals(proxyPrefs.shouldUseProxy())) {", which reads strange - # - org.openrewrite.java.cleanup.AvoidBoxedBooleanExpressions + # - org.openrewrite.staticanalysis.AvoidBoxedBooleanExpressions # Leads to exception - # - org.openrewrite.java.cleanup.CombineSemanticallyEqualCatchBlocks + # - org.openrewrite.staticanalysis.CombineSemanticallyEqualCatchBlocks # Unreable code # .ifPresent((Path selectedDirectory) -> { - # - org.openrewrite.java.cleanup.ExplicitLambdaArgumentTypes + # - org.openrewrite.staticanalysis.ExplicitLambdaArgumentTypes # Unreable code (e.g., public final class BindingsHelper) - # - org.openrewrite.java.cleanup.FinalClass + # - org.openrewrite.staticanalysis.FinalClass # Unreable code - # - org.openrewrite.java.cleanup.FinalizeLocalVariables + # - org.openrewrite.staticanalysis.FinalizeLocalVariables # Unreadable code - # - org.openrewrite.java.cleanup.FinalizeMethodArguments + # - org.openrewrite.staticanalysis.FinalizeMethodArguments # Not sure about the consequences (LibraryTab). - # - org.openrewrite.java.cleanup.FixStringFormatExpressions + # - org.openrewrite.staticanalysis.FixStringFormatExpressions # Leads to unreadable code (this.shouldAutoComplete.set(shouldAutoComplete1);) - # - org.openrewrite.java.cleanup.HiddenField + # - org.openrewrite.staticanalysis.HiddenField # Leads to unreadable code - # - org.openrewrite.java.cleanup.InlineVariable + # - org.openrewrite.staticanalysis.InlineVariable # Leads to unreadable code - # - org.openrewrite.java.cleanup.LambdaBlockToExpression + # - org.openrewrite.staticanalysis.LambdaBlockToExpression # Works on case-senstive file systems only - # - org.openrewrite.java.cleanup.LowercasePackage + # - org.openrewrite.staticanalysis.LowercasePackage # Needs manual intervention (not fixable at existing code) - # - org.openrewrite.java.cleanup.MethodNameCasing + # - org.openrewrite.staticanalysis.MethodNameCasing # Needs manual intervention (not fixable at existing code) - # - org.openrewrite.java.cleanup.MinimumSwitchCases + # - org.openrewrite.staticanalysis.MinimumSwitchCases # Leads to unreadable code - # - org.openrewrite.java.cleanup.NoFinalizedLocalVariables + # - org.openrewrite.staticanalysis.NoFinalizedLocalVariables # Contraticts JabRef's checkstyle - # - org.openrewrite.java.cleanup.NoWhitespaceAfter + # - org.openrewrite.staticanalysis.NoWhitespaceAfter # We sometimes need == instead of equals - # - org.openrewrite.java.cleanup.ReferentialEqualityToObjectEquals + # - org.openrewrite.staticanalysis.ReferentialEqualityToObjectEquals # AuthorListTest uses System.gc - # - org.openrewrite.java.cleanup.RemoveCallsToSystemGc + # - org.openrewrite.staticanalysis.RemoveCallsToSystemGc # Crashes with NPE - # - org.openrewrite.java.cleanup.RemoveInstanceOfPatternMatch + # - org.openrewrite.staticanalysis.RemoveInstanceOfPatternMatch # We need that for our CLI - # - org.openrewrite.java.cleanup.RemoveSystemOutPrintln + # - org.openrewrite.staticanalysis.RemoveSystemOutPrintln # Removes a field - and that wrong - # - org.openrewrite.java.cleanup.RemoveUnusedPrivateMethods + # - org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods # Crashes - # - org.openrewrite.java.cleanup.RenameExceptionInEmptyCatch + # - org.openrewrite.staticanalysis.RenameExceptionInEmptyCatch # Also renames private static final varialbes (e.g., LOGGER, ALL_ENTRIES_GROUP_DEFAULT_ICON, ...) - # - org.openrewrite.java.cleanup.RenamePrivateFieldsToCamelCase + # - org.openrewrite.staticanalysis.RenamePrivateFieldsToCamelCase # Does something else (deleting a field in TreeNode) - # - org.openrewrite.java.cleanup.ReplaceDeprecatedRuntimeExecMethods + # - org.openrewrite.staticanalysis.ReplaceDeprecatedRuntimeExecMethods # Leads to compile errors - # - org.openrewrite.java.cleanup.ReplaceDuplicateStringLiterals + # - org.openrewrite.staticanalysis.ReplaceDuplicateStringLiterals # Not everything correctly transformed - # - org.openrewrite.java.cleanup.ReplaceLambdaWithMethodReference + # - org.openrewrite.staticanalysis.ReplaceLambdaWithMethodReference # Crashes - # - org.openrewrite.java.cleanup.ReplaceStackWithDeque + # - org.openrewrite.staticanalysis.ReplaceStackWithDeque # We want to keep JDK16 (and not downgrade to JDK11) - # - org.openrewrite.java.cleanup.ReplaceStreamToListWithCollect + # - org.openrewrite.staticanalysis.ReplaceStreamToListWithCollect # Changes one item only - # - org.openrewrite.java.cleanup.ReplaceStringBuilderWithString + # - org.openrewrite.staticanalysis.ReplaceStringBuilderWithString # We like text blocks - # - org.openrewrite.java.cleanup.ReplaceTextBlockWithString + # - org.openrewrite.staticanalysis.ReplaceTextBlockWithString # Hangs - # - org.openrewrite.java.cleanup.ReplaceValidateNotNullHavingVarargsWithObjectsRequireNonNull + # - org.openrewrite.staticanalysis.ReplaceValidateNotNullHavingVarargsWithObjectsRequireNonNull # We need that in OOBibStyleTest - # - org.openrewrite.java.cleanup.SimplifyConstantIfBranchExecution + # - org.openrewrite.staticanalysis.SimplifyConstantIfBranchExecution # We log and wrap the exceptions - # - org.openrewrite.java.cleanup.UnnecessaryCatch + # - org.openrewrite.staticanalysis.UnnecessaryCatch # Does not work - # - org.openrewrite.java.cleanup.UnnecessaryCloseInTryWithResources + # - org.openrewrite.staticanalysis.UnnecessaryCloseInTryWithResources # Does not work - # - org.openrewrite.java.cleanup.UnnecessaryExplicitTypeArguments + # - org.openrewrite.staticanalysis.UnnecessaryExplicitTypeArguments # Does not work - # - org.openrewrite.java.cleanup.UnnecessaryPrimitiveAnnotations + # - org.openrewrite.staticanalysis.UnnecessaryPrimitiveAnnotations # Removes too much throws - # - org.openrewrite.java.cleanup.UnnecessaryThrows + # - org.openrewrite.staticanalysis.UnnecessaryThrows # Crashes - # - org.openrewrite.java.cleanup.UseAsBuilder + # - org.openrewrite.staticanalysis.UseAsBuilder # "Upgradeds" too much, deletss fields - # - org.openrewrite.java.cleanup.UseCollectionInterfaces + # - org.openrewrite.staticanalysis.UseCollectionInterfaces # Does not work at TreeNode - # - org.openrewrite.java.cleanup.UseDiamondOperator + # - org.openrewrite.staticanalysis.UseDiamondOperator # States that it gains performance, but the code is more unreable - # - org.openrewrite.java.cleanup.UseForEachRemoveInsteadOfSetRemoveAll + # - org.openrewrite.staticanalysis.UseForEachRemoveInsteadOfSetRemoveAll # We voted against it - # - org.openrewrite.java.cleanup.ExplicitInitialization + # - org.openrewrite.staticanalysis.ExplicitInitialization - - org.openrewrite.java.cleanup.AtomicPrimitiveEqualsUsesGet - - org.openrewrite.java.cleanup.BigDecimalRoundingConstantsToEnums - - org.openrewrite.java.cleanup.BooleanChecksNotInverted - - org.openrewrite.java.cleanup.CaseInsensitiveComparisonsDoNotChangeCase - - org.openrewrite.java.cleanup.CatchClauseOnlyRethrows - - org.openrewrite.java.cleanup.ChainStringBuilderAppendCalls + - org.openrewrite.staticanalysis.AtomicPrimitiveEqualsUsesGet + - org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums + - org.openrewrite.staticanalysis.BooleanChecksNotInverted + - org.openrewrite.staticanalysis.CaseInsensitiveComparisonsDoNotChangeCase + - org.openrewrite.staticanalysis.CatchClauseOnlyRethrows + - org.openrewrite.staticanalysis.ChainStringBuilderAppendCalls # Might need manual intervention, because negations are not treated properly - - org.openrewrite.java.cleanup.CompareEnumsWithEqualityOperator - - org.openrewrite.java.cleanup.ControlFlowIndentation - - org.openrewrite.java.cleanup.CovariantEquals - - org.openrewrite.java.cleanup.DeclarationSiteTypeVariance + - org.openrewrite.staticanalysis.CompareEnumsWithEqualityOperator + - org.openrewrite.staticanalysis.ControlFlowIndentation + - org.openrewrite.staticanalysis.CovariantEquals + - org.openrewrite.staticanalysis.DeclarationSiteTypeVariance # Needs manual intervention -# - org.openrewrite.java.cleanup.DefaultComesLast - - org.openrewrite.java.cleanup.EmptyBlock - - org.openrewrite.java.cleanup.EqualsAvoidsNull +# - org.openrewrite.staticanalysis.DefaultComesLast + - org.openrewrite.staticanalysis.EmptyBlock + - org.openrewrite.staticanalysis.EqualsAvoidsNull # Needs manual intervention -# - org.openrewrite.java.cleanup.ExplicitCharsetOnStringGetBytes - - org.openrewrite.java.cleanup.ExternalizableHasNoArgsConstructor - - org.openrewrite.java.cleanup.FallThrough -# - org.openrewrite.java.cleanup.ForLoopControlVariablePostfixOperators - - org.openrewrite.java.cleanup.ForLoopIncrementInUpdate - - org.openrewrite.java.cleanup.IndexOfChecksShouldUseAStartPosition - - org.openrewrite.java.cleanup.IndexOfReplaceableByContains -# - org.openrewrite.java.cleanup.IndexOfShouldNotCompareGreaterThanZero - - org.openrewrite.java.cleanup.InstanceOfPatternMatch -# - org.openrewrite.java.cleanup.IsEmptyCallOnCollections - - org.openrewrite.java.cleanup.MethodParamPad -# - org.openrewrite.java.cleanup.MissingOverrideAnnotation -# - org.openrewrite.java.cleanup.ModifierOrder - - org.openrewrite.java.cleanup.MultipleVariableDeclarations - - org.openrewrite.java.cleanup.NeedBraces - - org.openrewrite.java.cleanup.NestedEnumsAreNotStatic - - org.openrewrite.java.cleanup.NewStringBuilderBufferWithCharArgument - - org.openrewrite.java.cleanup.NoDoubleBraceInitialization -# - org.openrewrite.java.cleanup.NoEmptyCollectionWithRawType - - org.openrewrite.java.cleanup.NoEqualityInForCondition - - org.openrewrite.java.cleanup.NoFinalizer -# - org.openrewrite.java.cleanup.NoPrimitiveWrappersForToStringOrCompareTo -# - org.openrewrite.java.cleanup.NoRedundantJumpStatements - - org.openrewrite.java.cleanup.NoToStringOnStringType - - org.openrewrite.java.cleanup.NoValueOfOnStringType -# - org.openrewrite.java.cleanup.NoWhitespaceBefore - - org.openrewrite.java.cleanup.ObjectFinalizeCallsSuper -# - org.openrewrite.java.cleanup.OperatorWrap - - org.openrewrite.java.cleanup.PadEmptyForLoopComponents - - org.openrewrite.java.cleanup.PrimitiveWrapperClassConstructorToValueOf - - org.openrewrite.java.cleanup.RedundantFileCreation - - org.openrewrite.java.cleanup.RemoveCallsToObjectFinalize - - org.openrewrite.java.cleanup.RemoveEmptyJavaDocParameters - - org.openrewrite.java.cleanup.RemoveExtraSemicolons - - org.openrewrite.java.cleanup.RemoveJavaDocAuthorTag - - org.openrewrite.java.cleanup.RemoveRedundantTypeCast - - org.openrewrite.java.cleanup.RemoveUnneededAssertion - - org.openrewrite.java.cleanup.RemoveUnneededBlock -# - org.openrewrite.java.cleanup.RemoveUnusedLocalVariables -# - org.openrewrite.java.cleanup.RemoveUnusedPrivateFields -# - org.openrewrite.java.cleanup.RenameLocalVariablesToCamelCase - - org.openrewrite.java.cleanup.RenameMethodsNamedHashcodeEqualOrTostring - - org.openrewrite.java.cleanup.ReplaceRedundantFormatWithPrintf -# - org.openrewrite.java.cleanup.ShortenFullyQualifiedTypeReferences - - org.openrewrite.java.cleanup.SimplifyBooleanExpression - - org.openrewrite.java.cleanup.SimplifyBooleanReturn -# - org.openrewrite.java.cleanup.SimplifyConsecutiveAssignments -# - org.openrewrite.java.cleanup.SimplifyCompoundStatement - - org.openrewrite.java.cleanup.SimplifyDurationCreationUnits -# - org.openrewrite.java.cleanup.StaticMethodNotFinal - - org.openrewrite.java.cleanup.StringLiteralEquality - - org.openrewrite.java.cleanup.TypecastParenPad - - org.openrewrite.java.cleanup.UnnecessaryParentheses - - org.openrewrite.java.cleanup.UnwrapRepeatableAnnotations - - org.openrewrite.java.cleanup.UpperCaseLiteralSuffixes -# - org.openrewrite.java.cleanup.UseJavaStyleArrayDeclarations - - org.openrewrite.java.cleanup.UseLambdaForFunctionalInterface -# - org.openrewrite.java.cleanup.UseListSort - - org.openrewrite.java.cleanup.UseObjectNotifyAll - - org.openrewrite.java.cleanup.UseStandardCharset -# - org.openrewrite.java.cleanup.UseStringReplace - - org.openrewrite.java.cleanup.UseSystemLineSeparator - - org.openrewrite.java.cleanup.WhileInsteadOfFor -# - org.openrewrite.java.cleanup.WriteOctalValuesAsDecimal +# - org.openrewrite.staticanalysis.ExplicitCharsetOnStringGetBytes + - org.openrewrite.staticanalysis.ExternalizableHasNoArgsConstructor + - org.openrewrite.staticanalysis.FallThrough +# - org.openrewrite.staticanalysis.ForLoopControlVariablePostfixOperators + - org.openrewrite.staticanalysis.ForLoopIncrementInUpdate + - org.openrewrite.staticanalysis.IndexOfChecksShouldUseAStartPosition + - org.openrewrite.staticanalysis.IndexOfReplaceableByContains +# - org.openrewrite.staticanalysis.IndexOfShouldNotCompareGreaterThanZero + - org.openrewrite.staticanalysis.InstanceOfPatternMatch +# - org.openrewrite.staticanalysis.IsEmptyCallOnCollections +# - org.openrewrite.staticanalysis.MissingOverrideAnnotation +# - org.openrewrite.staticanalysis.ModifierOrder + - org.openrewrite.staticanalysis.MultipleVariableDeclarations + - org.openrewrite.staticanalysis.NeedBraces + - org.openrewrite.staticanalysis.NestedEnumsAreNotStatic + - org.openrewrite.staticanalysis.NewStringBuilderBufferWithCharArgument + - org.openrewrite.staticanalysis.NoDoubleBraceInitialization +# - org.openrewrite.staticanalysis.NoEmptyCollectionWithRawType + - org.openrewrite.staticanalysis.NoEqualityInForCondition + - org.openrewrite.staticanalysis.NoFinalizer +# - org.openrewrite.staticanalysis.NoPrimitiveWrappersForToStringOrCompareTo +# - org.openrewrite.staticanalysis.NoRedundantJumpStatements + - org.openrewrite.staticanalysis.NoToStringOnStringType + - org.openrewrite.staticanalysis.NoValueOfOnStringType +# - org.openrewrite.staticanalysis.NoWhitespaceBefore + - org.openrewrite.staticanalysis.ObjectFinalizeCallsSuper +# - org.openrewrite.staticanalysis.OperatorWrap + - org.openrewrite.staticanalysis.PrimitiveWrapperClassConstructorToValueOf + - org.openrewrite.staticanalysis.RedundantFileCreation + - org.openrewrite.staticanalysis.RemoveCallsToObjectFinalize + - org.openrewrite.staticanalysis.RemoveEmptyJavaDocParameters + - org.openrewrite.staticanalysis.RemoveExtraSemicolons + - org.openrewrite.staticanalysis.RemoveJavaDocAuthorTag + - org.openrewrite.staticanalysis.RemoveRedundantTypeCast + - org.openrewrite.staticanalysis.RemoveUnneededAssertion + - org.openrewrite.staticanalysis.RemoveUnneededBlock +# - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables +# - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields +# - org.openrewrite.staticanalysis.RenameLocalVariablesToCamelCase + - org.openrewrite.staticanalysis.RenameMethodsNamedHashcodeEqualOrTostring + - org.openrewrite.staticanalysis.ReplaceRedundantFormatWithPrintf +# - org.openrewrite.staticanalysis.ShortenFullyQualifiedTypeReferences +# - org.openrewrite.staticanalysis.SimplifyConsecutiveAssignments +# - org.openrewrite.staticanalysis.SimplifyCompoundStatement + - org.openrewrite.staticanalysis.SimplifyDurationCreationUnits +# - org.openrewrite.staticanalysis.StaticMethodNotFinal + - org.openrewrite.staticanalysis.StringLiteralEquality + - org.openrewrite.staticanalysis.TypecastParenPad + - org.openrewrite.staticanalysis.UnwrapRepeatableAnnotations + - org.openrewrite.staticanalysis.UpperCaseLiteralSuffixes +# - org.openrewrite.staticanalysis.UseJavaStyleArrayDeclarations + - org.openrewrite.staticanalysis.UseLambdaForFunctionalInterface +# - org.openrewrite.staticanalysis.UseListSort + - org.openrewrite.staticanalysis.UseObjectNotifyAll + - org.openrewrite.staticanalysis.UseStandardCharset +# - org.openrewrite.staticanalysis.UseStringReplace + - org.openrewrite.staticanalysis.UseSystemLineSeparator + - org.openrewrite.staticanalysis.WhileInsteadOfFor +# - org.openrewrite.staticanalysis.WriteOctalValuesAsDecimal