Replace duplicate String literals
MSALReplaces String literals with a length of 5 or greater repeated a minimum of 3 times. Qualified String literals include final Strings, method invocations, and new class invocations. Adds a new private static final String or uses an existing equivalent class field. A new variable name will be generated based on the literal value if an existing field does not exist. The generated name will append a numeric value to the variable name if a name already exists in the compilation unit. Centralizing repeated string values into constants makes refactoring safer and reduces the risk of inconsistent updates.
org. openrewrite. staticanalysis. ReplaceDuplicateStringLiteralsOptional
Changes only apply to main by default. includeTestSources will apply the recipe to test source files.
mod run . --recipe= org. openrewrite. staticanalysis. ReplaceDuplicateStringLiteralsInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.