Scanning Recipes
This doc contains all scanning recipes.
rewrite-ai-search
- Find method invocations that resemble a pattern - This recipe uses two phase AI approach to find a method invocation that resembles a search string.
- Get recommendations - This recipe calls an AI model to get recommendations for modernizing the code base by looking at a sample of method declarations.
rewrite-all
- Find duplicate source files - Record the presence of LSTs with duplicate paths, indicating that the same file was parsed more than once.
- Language composition report - Counts the number of lines of the various kinds of source code and data formats parsed by OpenRewrite. Comments are not included in line counts. This recipe emits its results as two data tables, making no changes to any source file. One data table is per-file, the other is per-repository.
rewrite-analysis
- Finds flow between two methods - Takes two patterns for the start/end methods to find flow between.
rewrite-azul
- Eliminate unused classes - Deprecate and later delete classes that are unused, as detected by Azul Intelligence Cloud.
- Find reachable methods - Find all methods defined in the repository's source code that are reachable.
rewrite-codemods
- Applies a codemod to all source files - Applies a codemod represented by an NPM package to all source files.
- Biome recommendations - Run Biome recommended settings on your projects.
- Lint UI5 projects with UI5 linter - Runs the UI5 Linter, a static code analysis tool for UI5 projects. It checks JavaScript, TypeScript, XML, JSON, and other files in your project and reports findings.
- Lint source code with ESLint - Run ESLint across the code to fix common static analysis issues in the code. This requires the code to have an existing ESLint configuration.
- Run Putout - Run Putout on your projects.
rewrite-codemods-ng
- Upgrade Angular versions - Run
ng update
to upgrade Angular CLI and Angular Core to the specified version.
rewrite-comprehension
- Search for a class that uses the given design technique - Search for a class that uses the given design technique.
- Update README - Generate a README file for the project, containing information about the project inferred from its knowledge graph.
rewrite-concourse
- Change Concourse value - Change every value matching the key pattern.
rewrite-core
- Append to text file - Appends or replaces content of an existing plain text file, or creates a new one if it doesn't already exist. Please note that this recipes requires existing plain text files' format to be successfully parsable by OpenRewrite. If a file is left unchanged, it might be parsed as a
Quark
rather than plain text. In such case, use theplainTextMask
option. See the Gradle or Maven plugin configuration page. - Create text file - Creates a new plain text file.
- Find LST provenance - Produces a data table showing what versions of OpenRewrite/Moderne tooling was used to produce a given LST.
- Find colliding source files - Finds source files which share a path with another source file. There should always be exactly one source file per path within a repository. This is a diagnostic for finding problems in OpenRewrite parsers/build plugins.
- Find committers on repositories - List the committers on a repository.
- List runtime classpath - A diagnostic utility which emits the runtime classpath to a data table.
- Remove ignoral of files or directories from .gitignore - This recipe will remove a file or directory from the .gitignore file. If the file or directory is already in the .gitignore file, it will be removed or negated. If the file or directory is not in the .gitignore file, no action will be taken.
- Repository contains file - Intended to be used primarily as a precondition for other recipes, this recipe checks if a repository contains a specific file or files matching a pattern. If present all files in the repository are marked with a
SearchResult
marker. If you want to get only the matching file as a search result, useFindSourceFiles
instead. - Show Git source control metadata - List out the contents of each unique
GitProvenance
marker in the set of source files. When everything is working correctly, exactly one such marker should be printed as all source files are expected to come from the same repository / branch / commit hash.
rewrite-csharp
- A class that provides Equals(T) should implement IEquatable<T> - __
- A readonly DependencyProperty must be set with DependencyPropertyKey - A readonly DependencyProperty must be set with DependencyPropertyKey.
- Abstract type should not have public constructors - __
- Abstract types should not have public constructors - Constructors on abstract types can be called only by derived types. Because public constructors create instances of a type, and you cannot create instances of an abstract type, an abstract type that has a public constructor is incorrectly designed.
- Abstract types should not have public or internal constructors - __
- Access modifier should be declared - The access modifier for a C# element has not been explicitly defined.
- Accessible fields should begin with upper-case letter - The name of a public or internal field in C# does not begin with an upper-case letter.
- Accessor method for attached property should have standard documentation text - Accessor method for attached property should have standard documentation text.
- Add 'param' element to documentation comment - __
- Add 'static' modifier to all partial class declarations - __
- Add 'typeparam' element to documentation comment - __
- Add MarkupExtensionReturnType attribute - Add MarkupExtensionReturnType attribute.
- Add StructLayoutAttribute - __
- Add ValueConversion attribute - Add ValueConversion attribute.
- Add ValueConversion attribute (unknown types) - Add ValueConversion attribute (unknown types).
- Add [AttachedPropertyBrowsableForType] - Add [AttachedPropertyBrowsableForType].
- Add [ConstructorArgument] - Add [ConstructorArgument] for the property.
- Add [TemplatePart] to the type - Add [TemplatePart] to the type.
- Add a comma after the last value - __
- Add braces - __
- Add braces (when expression spans over multiple lines) - __
- Add braces to if-else - __
- Add braces to if-else (when expression spans over multiple lines) - __
- Add braces to switch section with multiple statements - __
- Add default field to converter - Add default field to converter.
- Add exception to documentation comment - __
- Add or remove region name - __
- Add paragraph to documentation comment - __
- Add parameter name to improve readability - __
- Add parentheses when necessary - __
- Add summary element to documentation comment - __
- Add/remove 'ConfigureAwait(false)' call - __
- Add/remove accessibility modifiers - __
- Add/remove parentheses from condition in conditional operator - __
- Add/remove trailing comma - __
- All accessors should be single-line or multi-line - Within a C# property, indexer or event, at least one of the child accessors is written on a single line, and at least one of the child accessors is written across multiple lines.
- All members declared in parent interfaces must have an implementation in a DynamicInterfaceCastableImplementation-attributed interface - Types attributed with 'DynamicInterfaceCastableImplementationAttribute' act as an interface implementation for a type that implements the 'IDynamicInterfaceCastable' type. As a result, it must provide an implementation of all of the members defined in the inherited interfaces, because the type that implements 'IDynamicInterfaceCastable' will not provide them otherwise.
- Argument passed to TaskCompletionSource constructor should be TaskCreationOptions enum instead of TaskContinuationOptions enum - TaskCompletionSource has constructors that take TaskCreationOptions that control the underlying Task, and constructors that take object state that's stored in the task. Accidentally passing a TaskContinuationOptions instead of a TaskCreationOptions will result in the call treating the options as state.
- Arithmetic expressions should declare precedence - A C# statement contains a complex arithmetic expression which omits parenthesis around operators.
- Attribute constructor should not use unnecessary parenthesis - TODO.
- Attributes should not share line - Each attribute should be placed on its own line of code.
- Avoid NullReferenceException - __
- Avoid comparison with bool constant - __
- Avoid constant arrays as arguments - Constant arrays passed as arguments are not reused when called repeatedly, which implies a new array is created each time. Consider extracting them to 'static readonly' fields to improve performance if the passed array is not mutated within the called method.
- Avoid implicit culture-sensitive methods - __
- Avoid inexact read with 'Stream.Read' - A call to 'Stream.Read' may return fewer bytes than requested, resulting in unreliable code if the return value is not checked.
- Avoid locking on publicly accessible instance - __
- Avoid nested ?: operators - __
- Avoid redundant length argument - An explicit length calculation can be error-prone and can be avoided when slicing to end of the buffer.
- Avoid unnecessary boxing of value type - __
- Avoid unsealed attributes - The .NET Framework class library provides methods for retrieving custom attributes. By default, these methods search the attribute inheritance hierarchy. Sealing the attribute eliminates the search through the inheritance hierarchy and can improve performance.
- Avoid unused private fields - Private fields were detected that do not appear to be accessed in the assembly.
- Avoid usage of using alias directive - __
- Avoid using 'Enumerable.Any()' extension method - Prefer using 'IsEmpty', 'Count' or 'Length' properties whichever available, rather than calling 'Enumerable.Any()'. The intent is clearer and it is more performant than using 'Enumerable.Any()' extension method.
- Avoid using redundant else - The 'if' block contains a jump statement (break, continue, goto, return, throw, yield break). Using 'else' is redundant and needlessly maintains a higher nesting level.
- Avoid zero-length array allocations - __
- Backing field for a DependencyProperty should be static and readonly - Backing field for a DependencyProperty should be static and readonly.
- Backing field for a DependencyProperty should match registered name - A dependency property's backing field should be named with the name it is registered with suffixed by 'Property'. This is the convention in the framework.
- Backing field for a DependencyPropertyKey should match registered name - A DependencyPropertyKey's backing field must be named with the name it is registered with suffixed by 'PropertyKey'.
- Backing field for a RoutedCommand should be static and readonly - Backing field for a RoutedCommand should be static and readonly.
- Backing field for a RoutedEvent should match registered name - A routed event's backing field should be named with the name it is registered with suffixed by 'Event'.
- Backing member for DependencyProperty should have standard documentation text - Backing member for DependencyProperty should have standard documentation text.
- Backing member for RoutedEvent should have standard documentation text - Backing member for RoutedEvent should have standard documentation text.
- Backing member for a RoutedEvent should be static and readonly - Backing member for a RoutedEvent should be static and readonly.
- Braces for multi-line statements should not share line - The opening or closing brace within a C# statement, element, or expression is not placed on its own line.
- Braces should not be omitted - The opening and closing braces for a C# statement have been omitted.
- Braces should not be omitted from multi-line child statement - The opening and closing braces for a multi-line C# statement have been omitted.
- CLR accessor for attached property must match registered type - CLR accessor for attached property must match registered type.
- CLR method for a DependencyProperty must match registered name - CLR methods for accessing a DependencyProperty must have names matching the name the DependencyProperty is registered with.
- CLR property for a DependencyProperty should match registered name - A CLR property accessor for a DependencyProperty must have the same name as the DependencyProperty is registered with.
- CLR property type should match registered type - CLR property type should match registered type.
- Call 'Enumerable.ThenBy' instead of 'Enumerable.OrderBy' - __
- Call extension method as instance method - __
- Cast sender to containing type - Cast sender to correct type.
- Cast sender to correct type - Cast sender to correct type.
- Cast value to correct type - Cast value to correct type.
- Cast value to correct type - Cast value to correct type.
- Chained statement blocks should not be preceded by blank line - Chained C# statements are separated by a blank line.
- Closing attribute brackets should be spaced correctly - A closing attribute bracket within a C# element is not spaced correctly.
- Closing brace should be followed by blank line - A closing brace within a C# element, statement, or expression is not followed by a blank line.
- Closing braces should be spaced correctly - A closing brace within a C# element is not spaced correctly.
- Closing braces should not be preceded by blank line - A closing brace within a C# element, statement, or expression is preceded by a blank line.
- Closing generic brackets should be spaced correctly - A closing generic bracket within a C# element is not spaced correctly.
- Closing parenthesis should be on line of last parameter - The closing parenthesis or bracket in a call to or declaration of a C# method/indexer/attribute/array/constructor/delegate is not placed on the same line as the last parameter.
- Closing parenthesis should be on line of opening parenthesis - The closing parenthesis or bracket in a call to a C# method or indexer, or the declaration of a method or indexer, is not placed on the same line as the opening bracket when the element does not take any parameters.
- Closing parenthesis should be spaced correctly - A closing parenthesis within a C# statement is not spaced correctly.
- Closing square brackets should be spaced correctly - A closing square bracket within a C# statement is not spaced correctly.
- Code analysis suppression should have justification - A Code Analysis SuppressMessage attribute does not include a justification.
- Code should not contain blank lines at start of file - The code file has blank lines at the start.
- Code should not contain empty statements - The C# code contains an extra semicolon.
- Code should not contain multiple blank lines in a row - The C# code contains multiple blank lines in a row.
- Code should not contain multiple statements on one line - The C# code contains more than one statement on a single line.
- Code should not contain multiple whitespace in a row - The code contains multiple whitespace characters in a row.
- Code should not contain space after new or stackalloc keyword in implicitly typed array allocation - An implicitly typed array allocation within a C# code file is not spaced correctly.
- Code should not contain trailing whitespace - There should not be any whitespace at the end of a line of code.
- Colons Should Be Spaced Correctly - A colon within a C# element is not spaced correctly.
- Combine 'Enumerable.Where' method chain - __
- Combine LINQ methods - __
- Comma should be on the same line as previous parameter - A comma between two parameters in a call to a C# method or indexer, or in the declaration of a method or indexer, is not placed on the same line as the previous parameter.
- Commas should be spaced correctly - The spacing around a comma is incorrect, within a C# code file.
- Comments should contain text - The C# comment does not contain any comment text.
- Composite enum value contains undefined flag - __
- Conditional expressions should declare precedence - A C# statement contains a complex conditional expression which omits parenthesis around operators.
- Consider calling ConfigureAwait on the awaited task - When an asynchronous method awaits a Task directly, continuation occurs in the same thread that created the task. Consider calling Task.ConfigureAwait(Boolean) to signal your intention for continuation. Call ConfigureAwait(false) on the task to schedule continuations to the thread pool, thereby avoiding a deadlock on the UI thread. Passing false is a good option for app-independent libraries. Calling ConfigureAwait(true) on the task has the same behavior as not explicitly calling ConfigureAwait. By explicitly calling this method, you're letting readers know you intentionally want to perform the continuation on the original synchronization context.
- Consider making public types internal - Unlike a class library, an application's API isn't typically referenced publicly, so types can be marked internal.
- Consider using 'StringBuilder.Append(char)' when applicable - 'StringBuilder.Append(char)' is more efficient than 'StringBuilder.Append(string)' when the string is a single character. When calling 'Append' with a constant, prefer using a constant char rather than a constant string containing one character.
- Consider using 'string.Contains' instead of 'string.IndexOf' - Calls to 'string.IndexOf' where the result is used to check for the presence/absence of a substring can be replaced by 'string.Contains'.
- Const field names should begin with upper-case letter - The name of a constant C# field should begin with an upper-case letter.
- Constant values should be placed on right side of comparisons - __
- Constructor summary documentation should begin with standard text - The XML documentation header for a C# constructor does not contain the appropriate summary text.
- Containing type should be used as registered owner - When registering a DependencyProperty register containing type as owner type.
- Containing type should be used as registered owner - When registering a RoutedEvent register containing type as owner type.
- Convert 'if' to 'return' statement - __
- Convert 'if' to assignment - __
- Convert comment to documentation comment - __
- Convert interpolated string to concatenation - __
- Convert lambda expression body to expression body - __
- Declaration keywords should follow order - The keywords within the declaration of an element do not follow a standard ordering scheme.
- Declare each attribute separately - __
- Declare each type in separate file - __
- Declare enum member with zero value (when enum has FlagsAttribute) - __
- Declare enum value as combination of names - __
- Declare type inside namespace - __
- Declare using directive on top level - __
- Default label should be the last label in a switch section - __
- Define accessors for attribute arguments - __
- DependencyPropertyKey member must be declared before DependencyProperty member - DependencyPropertyKey member must be declared before DependencyProperty member.
- Dereference and access of symbols should be spaced correctly - A dereference symbol or an access-of symbol within a C# element is not spaced correctly.
- Destructor summary documentation should begin with standard text - The XML documentation header for a C# finalizer does not contain the appropriate summary text.
- Dispose methods should call base class dispose - A type that implements System.IDisposable inherits from a type that also implements IDisposable. The Dispose method of the inheriting type does not call the Dispose method of the parent type. To fix a violation of this rule, call base.Dispose in your Dispose method.
- Do not call ToImmutableCollection on an ImmutableCollection value - __
- Do not combine attributes - Each attribute usage should be placed in its own set of square brackets for maximum readability.
- Do not combine fields - Each field should be declared on its own line, in order to clearly see each field of a type and allow for proper documentation of the behavior of each field.
- Do not compare Span<T> to 'null' or 'default' - Comparing a span to 'null' or 'default' might not do what you intended. 'default' and the 'null' literal are implicitly converted to 'Span<T>.Empty'. Remove the redundant comparison or make the code more explicit by using 'IsEmpty'.
- Do not duplicate indexed element initializations - Indexed elements in objects initializers must initialize unique elements. A duplicate index might overwrite a previous element initialization.
- Do not initialize unnecessarily - The .NET runtime initializes all fields of reference types to their default values before running the constructor. In most cases, explicitly initializing a field to its default value in a constructor is redundant, adding maintenance costs and potentially degrading performance (such as with increased assembly size), and the explicit initialization can be removed. In some cases, such as with static readonly fields that permanently retain their default value, consider instead changing them to be constants or properties.
- Do not mark enums with FlagsAttribute - An externally visible enumeration is marked by using FlagsAttribute, and it has one or more values that are not powers of two or a combination of the other defined values on the enumeration.
- Do not pass a non-nullable value to 'ArgumentNullException.ThrowIfNull' - 'ArgumentNullException.ThrowIfNull' throws when the passed argument is 'null'. Certain constructs like non-nullable structs, 'nameof()' and 'new' expressions are known to never be null, so 'ArgumentNullException.ThrowIfNull' will never throw.
- Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull' - 'ArgumentNullException.ThrowIfNull' accepts an 'object', so passing a nullable struct may cause the value to be boxed.
- Do not pass non-read-only struct by read-only reference - __
- Do not place regions within elements - The C# code contains a region within the body of a code element.
- Do not prefix calls with base unless local implementation exists - A call to a member from an inherited class begins with 'base.', and the local class does not contain an override or implementation of the member.
- Do not prefix local calls with 'this.' - A call to an instance member of the local class or a base class is prefixed with
this.
. - Do not use 'WaitAll' with a single task - Using 'WaitAll' with a single task may result in performance loss, await or return the task instead.
- Do not use 'WhenAll' with a single task - Using 'WhenAll' with a single task may result in performance loss, await or return the task instead.
- Do not use Count() or LongCount() when Any() can be used - For non-empty collections, Count() and LongCount() enumerate the entire sequence, while Any() stops at the first item or the first item that satisfies a condition.
- Do not use CountAsync() or LongCountAsync() when AnyAsync() can be used - For non-empty collections, CountAsync() and LongCountAsync() enumerate the entire sequence, while AnyAsync() stops at the first item or the first item that satisfies a condition.
- Do not use Enumerable methods on indexable collections - This collection is directly indexable. Going through LINQ here causes unnecessary allocations and CPU work.
- Do not use blocking calls in a sync method (need to make calling method async) - __
- Do not use blocking calls in an async method - __
- Do not use default value type constructor - When creating a new instance of a value type T, the syntax 'default(T)' is functionally equivalent to the syntax 'new T()'. To avoid confusion regarding the behavior of the resulting instance, the first form is preferred.
- Do not use placeholder elements - The element documentation contains a <placeholder> element.
- Do not use regions - The C# code contains a region.
- Documentation lines should begin with single space - A line within a documentation header above a C# element does not begin with a single space.
- Documentation text should end with a period - A section of the XML header documentation for a C# element does not end with a period.
- Don't set DataContext and Style using SetCurrentValue - Set DataContext and Style using SetValue.
- Duplicate enum value - __
- Duplicate word in a comment - __
- Element documentation header should be preceded by blank line - An element documentation header above a C# element is not preceded by a blank line.
- Element documentation headers should not be followed by blank line - An element documentation header above a C# element is followed by a blank line.
- Element return value documentation should have text - The <returns> tag within a C# element's documentation header is empty.
- Element return value should be documented - A C# element is missing documentation for its return value.
- Element should begin with upper-case letter - The name of a C# element does not begin with an upper-case letter.
- Element should not be on a single line - A C# element containing opening and closing braces is written completely on a single line.
- Elements should be documented - A C# code element is missing a documentation header.
- Elements should be separated by blank line - Adjacent C# elements are not separated by a blank line.
- Elements should have the same indentation - Elements at the same level in the syntax tree should have the same indentation.
- Enum Storage should be Int32 - An enumeration is a value type that defines a set of related named constants. By default, the System.Int32 data type is used to store the constant value. Although you can change this underlying type, it is not required or recommended for most scenarios.
- Enum should declare explicit values - __
- Enum values should be on separate lines - Enum values should be placed on their own lines for maximum readability.
- Enumeration items should be documented - An item within a C# enumeration is missing an Xml documentation header.
- Enums should have zero value - The default value of an uninitialized enumeration, just as other value types, is zero. A nonflags-attributed enumeration should define a member by using the value of zero so that the default value is a valid value of the enumeration. If an enumeration that has the FlagsAttribute attribute applied defines a zero-valued member, its name should be ""None"" to indicate that no values have been set in the enumeration.
- Event accessors should follow order - An add accessor appears after a remove accessor within an event.
- EventArgs should not be null - __
- Exceptions should be public - An internal exception is visible only inside its own internal scope. After the exception falls outside the internal scope, only the base exception can be used to catch the exception. If the internal exception is inherited from T:System.Exception, T:System.SystemException, or T:System.ApplicationException, the external code will not have sufficient information to know what to do with the exception.
- Expression is always equal to true/false - __
- Field names should begin with lower-case letter - The name of a field in C# does not begin with a lower-case letter.
- Field names should begin with underscore - A field name in C# does not begin with an underscore.
- Field names should not begin with underscore - A field name in C# begins with an underscore.
- Field names should not contain underscore - A field name in C# contains an underscore.
- File contains no code - __
- File header company name text should match - The file header at the top of a C# code file does not contain the appropriate company name text.
- File header copyright text should match - The file header at the top of a C# code file does not contain the appropriate copyright text.
- File header file name documentation should match file name - The file attribute within copyright tag of the file header at the top of a C# code file does not contain the name of the file.
- File header should contain file name - The file header at the top of a C# code file is missing the file name.
- File header should have copyright text - The file header at the top of a C# code file is missing copyright text.
- File header should have summary - The file header at the top of a C# code file does not contain a filled-in summary tag.
- File header should have valid company text - The file header at the top of a C# code file does not contain company name text.
- File header should show copyright - The file header at the top of a C# code file is missing a copyright tag.
- File may only contain a single type - A C# code file contains more than one unique type.
- File name should match first type name - The file name of a C# code file does not match the first type declared in the file.
- File should have header - A C# code file is missing a standard file header.
- Fix documentation comment tag - __
- Format documentation comment summary - __
- Forward the 'CancellationToken' parameter to methods - Forward the 'CancellationToken' parameter to methods to ensure the operation cancellation notifications gets properly propagated, or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token.
- Forward the CancellationToken parameter to methods that take one - __
- Forward the CancellationToken using .WithCancellation() - __
- Forward the TimeProvider to methods that take one - __
- Generic type constraints should be on their own line - Each type constraint clause for a generic type parameter should be listed on a line of code by itself.
- IEqualityComparer<string> or IComparer<string> is missing - __
- Identifiers should not contain underscores - By convention, identifier names do not contain the underscore () character. This rule checks namespaces, types, members, and parameters._
- Implement IEquatable when overriding Object.Equals - When a type T overrides Object.Equals(object), the implementation must cast the object argument to the correct type T before performing the comparison. If the type implements IEquatable<T>, and therefore offers the method T.Equals(T), and if the argument is known at compile time to be of type T, then the compiler can call IEquatable<T>.Equals(T) instead of Object.Equals(object), and no cast is necessary, improving performance.
- Implement exception constructors - __
- Implement non-generic counterpart - __
- Implement standard exception constructors - Failure to provide the full set of constructors can make it difficult to correctly handle exceptions.
- Include/omit parentheses when creating new object - __
- Increment decrement symbols should be spaced correctly - An increment or decrement symbol within a C# element is not spaced correctly.
- Inline lazy initialization - __
- Inline local variable - __
- Instantiate argument exceptions correctly - A call is made to the default (parameterless) constructor of an exception type that is or derives from ArgumentException, or an incorrect string argument is passed to a parameterized constructor of an exception type that is or derives from ArgumentException.
- Interface methods should be callable by child types - An unsealed externally visible type provides an explicit method implementation of a public interface and does not provide an alternative externally visible method that has the same name.
- Interface names should begin with I - The name of a C# interface does not begin with the capital letter I.
- Invalid argument null check - __
- Invalid reference in a documentation comment - __
- Join string expressions - __
- Keywords should be spaced correctly - The spacing around a C# keyword is incorrect.
- Make class sealed - __
- Make class sealed - __
- Make class static - __
- Make class static - __
- Make field read-only - __
- Make interpolated string - __
- Make member readonly - __
- Make method an extension method - __
- Make method static (deprecated, use CA1822 instead) - __
- Make parameter ref read-only - __
- Make property static (deprecated, use CA1822 instead) - __
- Mark ISerializable types with serializable - To be recognized by the common language runtime as serializable, types must be marked by using the SerializableAttribute attribute even when the type uses a custom serialization routine through implementation of the ISerializable interface.
- Mark all non-serializable fields - An instance field of a type that is not serializable is declared in a type that is serializable.
- Mark attributes with AttributeUsageAttribute - __
- Mark attributes with AttributeUsageAttribute - __
- Mark enums with FlagsAttribute - An enumeration is a value type that defines a set of related named constants. Apply FlagsAttribute to an enumeration when its named constants can be meaningfully combined.
- Mark local variable as const - __
- Mark members as static - Members that do not access instance data or call instance methods can be marked as static. After you mark the methods as static, the compiler will emit nonvirtual call sites to these members. This can give you a measurable performance gain for performance-sensitive code.
- Mark publicly visible type with DebuggerDisplay attribute - __
- MarkupExtensionReturnType must use correct return type - MarkupExtensionReturnType must use correct return type.
- Member access symbols should be spaced correctly - The spacing around a member access symbol is incorrect, within a C# code file.
- Members defined on an interface with the 'DynamicInterfaceCastableImplementationAttribute' should be 'static' - Since a type that implements 'IDynamicInterfaceCastable' may not implement a dynamic interface in metadata, calls to an instance interface member that is not an explicit implementation defined on this type are likely to fail at runtime. Mark new interface members 'static' to avoid runtime errors.
- Merge 'else' with nested 'if' - __
- Merge 'if' with nested 'if' - __
- Merge preprocessor directives - __
- Merge switch sections with equivalent content - __
- Method overrides should not change default values - __
- Method overrides should not omit params keyword - __
- Name of CoerceValueCallback should match registered name - Name of CoerceValueCallback should match registered name.
- Name of PropertyChangedCallback should match registered name - Name of PropertyChangedCallback should match registered name.
- Name of ValidateValueCallback should match registered name - Name of ValidateValueCallback should match registered name.
- Name of the event should match registered name - Name of the event should match registered name.
- Name the invoked method OnEventName - Name the invoked method OnEventName.
- Name the invoked method OnEventName - Name the invoked method OnEventName.
- Negative signs should be spaced correctly - A negative sign within a C# element is not spaced correctly.
- Non-private readonly fields should begin with upper-case letter - The name of a non-private readonly C# field should being with an upper-case letter.
- Normalize format of enum flag value - __
- Normalize null check - __
- Normalize usage of infinite loop - __
- Nullable type symbols should be spaced correctly - A nullable type symbol within a C# element is not spaced correctly.
- Opening attribute brackets should be spaced correctly - An opening attribute bracket within a C# element is not spaced correctly.
- Opening braces should be spaced correctly - An opening brace within a C# element is not spaced correctly.
- Opening braces should not be followed by blank line - An opening brace within a C# element, statement, or expression is followed by a blank line.
- Opening braces should not be preceded by blank line - An opening brace within a C# element, statement, or expression is preceded by a blank line.
- Opening generic brackets should be spaced correctly - An opening generic bracket within a C# element is not spaced correctly.
- Opening parenthesis or bracket should be on declaration line - The opening parenthesis or bracket is not placed on the same line as the method/indexer/attribute/array name.
- Opening parenthesis should be spaced correctly - An opening parenthesis within a C# statement is not spaced correctly.
- Opening square brackets should be spaced correctly - An opening square bracket within a C# statement is not spaced correctly.
- Operator is unnecessary - __
- Operator keyword should be followed by space - The operator keyword within a C# operator overload method is not followed by any whitespace.
- Operator overloads have named alternates - An operator overload was detected, and the expected named alternative method was not found. The named alternative member provides access to the same functionality as the operator and is provided for developers who program in languages that do not support overloaded operators.
- Operators should have symmetrical overloads - A type implements the equality or inequality operator and does not implement the opposite operator.
- Optimize Enumerable.Count() usage - __
- Optimize LINQ method call - __
- Optimize StringBuilder usage - __
- Optimize StringBuilder.Append/AppendLine call - __
- Optimize method call - __
- Optimize string method usage - __
- Order elements in documentation comment - __
- Order modifiers - __
- Order named arguments according to the order of parameters - __
- Order type parameter constraints - __
- Overload operator equals on overriding value type Equals - In most programming languages there is no default implementation of the equality operator (==) for value types. If your programming language supports operator overloads, you should consider implementing the equality operator. Its behavior should be identical to that of Equals.
- Override Object.Equals(object) when implementing IEquatable<T> - When a type T implements the interface IEquatable<T>, it suggests to a user who sees a call to the Equals method in source code that an instance of the type can be equated with an instance of any other type. The user might be confused if their attempt to equate the type with an instance of another type fails to compile. This violates the "principle of least surprise".
- Override equals and operator equals on value types - For value types, the inherited implementation of Equals uses the Reflection library and compares the contents of all fields. Reflection is computationally expensive, and comparing every field for equality might be unnecessary. If you expect users to compare or sort instances, or to use instances as hash table keys, your value type should implement Equals.
- Override methods on comparable types - A public or protected type implements the System.IComparable interface. It does not override Object.Equals nor does it overload the language-specific operator for equality, inequality, less than, less than or equal, greater than or greater than or equal.
- Overriding member should not change 'params' modifier - __
- Parameter name differs from base name - __
- Parameter names should begin with lower-case letter - The name of a parameter in C# does not begin with a lower-case letter.
- Parameter names should match base declaration - Consistent naming of parameters in an override hierarchy increases the usability of the method overrides. A parameter name in a derived method that differs from the name in the base declaration can cause confusion about whether the method is an override of the base method or a new overload of the method.
- Parameter type should be nullable - Parameter type should be nullable.
- Parameters with [EditorRequired] attributes should also be marked as [Parameter] - __
- Parameters with [SupplyParameterFromQuery] attributes should also be marked as [Parameter] - __
- Partial elements should be documented - A C# partial element is missing a documentation header.
- Partial elements should declare access - The partial element does not have an access modifier defined.
- Positive signs should be spaced correctly - A positive sign within a C# element is not spaced correctly.
- Prefer 'AsSpan' over 'Substring' - 'AsSpan' is more efficient than 'Substring'. 'Substring' performs an O(n) string copy, while 'AsSpan' does not and has a constant cost.
- Prefer 'Clear' over 'Fill' - It is more efficient to use 'Clear', instead of 'Fill' with default value.
- Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString' - Use 'Convert.ToHexString' or 'Convert.ToHexStringLower' when encoding bytes to a hexadecimal string representation. These methods are more efficient and allocation-friendly than using 'BitConverter.ToString' in combination with 'String.Replace' to replace dashes and 'String.ToLower'.
- Prefer Dictionary.Contains methods - 'ContainsKey' is usually O(1), while 'Keys.Contains' may be O(n) in some cases. Additionally, many dictionary implementations lazily initialize the Keys collection to cut back on allocations.
- Prefer IsEmpty over Count - For determining whether the object contains or not any items, prefer using 'IsEmpty' property rather than retrieving the number of items from the 'Count' property and comparing it to 0 or 1.
- Prefer generic overload when type is known - Using a generic overload is preferable to the 'System.Type' overload when the type is known, promoting cleaner and more type-safe code with improved compile-time checks.
- Prefer rethrowing an exception implicitly - __
- Prefer static 'HashData' method over 'ComputeHash' - It is more efficient to use the static 'HashData' method over creating and managing a HashAlgorithm instance to call 'ComputeHash'.
- Prefer strongly-typed Append and Insert method overloads on StringBuilder - StringBuilder.Append and StringBuilder.Insert provide overloads for multiple types beyond System.String. When possible, prefer the strongly-typed overloads over using ToString() and the string-based overload.
- Prefer the 'IDictionary.TryAdd(TKey, TValue)' method - Prefer a 'TryAdd' call over an 'Add' call guarded by a 'ContainsKey' check. 'TryAdd' behaves the same as 'Add', except that when the specified key already exists, it returns 'false' instead of throwing an exception.
- Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method - Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check. 'ContainsKey' and the indexer both would lookup the key under the hood, so using 'TryGetValue' removes the extra lookup.
- Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' - 'Stream' has a 'ReadAsync' overload that takes a 'Memory<Byte>' as the first argument, and a 'WriteAsync' overload that takes a 'ReadOnlyMemory<Byte>' as the first argument. Prefer calling the memory based overloads, which are more efficient.
- Prefix local calls with this - A call to an instance member of the local class or a base class is not prefixed with 'this.', within a C# code file.
- Preprocessor keywords should not be preceded by space - A C# preprocessor-type keyword is preceded by space.
- Property accessors should follow order - A get accessor appears after a set accessor within a property or indexer.
- Property changed callback should have standard documentation text - Property changed callback should have standard documentation text.
- Property documentation should have value - The XML header documentation for a C# property does not contain a <value> tag.
- Property documentation should have value text - The XML header documentation for a C# property contains an empty <value> tag.
- Property summary documentation should match accessors - The documentation text within a C# property’s <summary> tag does not match the accessors within the property.
- Property summary documentation should omit accessor with restricted access - The documentation text within a C# property’s <summary> tag takes into account all of the accessors within the property, but one of the accessors has limited access.
- Protected should come before internal - The keyword '0' is positioned after the keyword '1' within the declaration of a 0 1 C# element.
- Provide a parameterless constructor that is as visible as the containing type for concrete types derived from 'System.Runtime.InteropServices.SafeHandle' - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions.
- Put constructor initializers on their own line - A constructor initializer, including the colon character, should be on its own line.
- Query clause should begin on new line when previous clause spans multiple lines - A clause within a C# query expression begins on the same line as the previous clause, when the previous clause spans across multiple lines.
- Query clause should follow previous clause - A C# query clause does not begin on the same line as the previous clause, or on the next line.
- Query clauses should be on separate lines or all on one line - The clauses within a C# query expression are not all placed on the same line, and each clause is not placed on its own line.
- Query clauses spanning multiple lines should begin on own line - A clause within a C# query expression spans across multiple lines, and does not begin on its own line.
- Reduce 'if' nesting - __
- Register containing member name as name for routed command - Register containing member name as name for routed command.
- Register containing type as owner for routed command - Register containing type as owner for routed command.
- Register name and owning type for routed command - Register containing type as owner for routed command.
- Remove 'partial' modifier from type with a single part - __
- Remove argument list from attribute - __
- Remove braces - __
- Remove braces from if-else - __
- Remove delegate parenthesis when possible - A call to a C# anonymous method does not contain any method parameters, yet the statement still includes parenthesis.
- Remove empty Finalizers - Finalizers should be avoided where possible, to avoid the additional performance overhead involved in tracking object lifetime.
- Remove empty statement - __
- Remove empty syntax - __
- Remove enum default underlying type - __
- Remove original exception from throw statement - __
- Remove redundant 'ToCharArray' call - __
- Remove redundant 'ToString' call - __
- Remove redundant 'as' operator - __
- Remove redundant 'sealed' modifier - __
- Remove redundant Dispose/Close call - __
- Remove redundant argument value - __
- Remove redundant assignment - __
- Remove redundant async/await - __
- Remove redundant auto-property initialization - __
- Remove redundant base constructor call - __
- Remove redundant base interface - __
- Remove redundant boolean literal - __
- Remove redundant cast - __
- Remove redundant catch block - __
- Remove redundant constructor - __
- Remove redundant default switch section - __
- Remove redundant delegate creation - __
- Remove redundant field initialization - __
- Remove redundant overriding member - __
- Remove redundant parentheses - __
- Remove redundant statement - __
- Remove trailing white-space - __
- Remove unnecessary 'else' - __
- Remove unnecessary braces from record declaration - __
- Remove unnecessary braces in switch section - __
- Remove unnecessary case label - __
- Remove unused member declaration - __
- Remove useless OrderBy call - __
- Remove useless ToString call - __
- Replace constant Enum.ToString with nameof - __
- Resource can be disposed asynchronously - __
- Rethrow to preserve stack details - __
- Return Task.FromResult instead of returning null - __
- Return completed task instead of returning null - __
- Seal internal types - When a type is not accessible outside its assembly and has no subtypes within its containing assembly, it can be safely sealed. Sealing types can improve performance.
- Seal methods that satisfy private interfaces - An inheritable public type provides an overridable method implementation of an internal (Friend in Visual Basic) interface. To fix a violation of this rule, prevent the method from being overridden outside the assembly.
- Semicolons should be spaced correctly - The spacing around a semicolon is incorrect, within a C# code file.
- Sender should be 'this' for instance events - __
- Set mutable dependency properties using SetCurrentValue - Prefer setting mutable dependency properties using SetCurrentValue.
- Simplify 'default' expression - __
- Simplify Nullable<T> to T? - __
- Simplify argument null check - __
- Simplify boolean comparison - __
- Simplify coalesce expression - __
- Simplify code branching - __
- Simplify conditional expression - __
- Simplify lazy initialization - __
- Simplify logical negation - __
- Simplify nested using statement - __
- Simplify numeric comparison - __
- Single line comments should begin with single space - A single-line comment within a C# code file does not begin with a single space.
- Single-line comment should be preceded by blank line - A single-line comment within C# code is not preceded by a blank line.
- Single-line comments should not be followed by blank line - A single-line comment within C# code is followed by a blank line.
- Single-line comments should not use documentation style slashes - The C# code contains a single-line comment which begins with three forward slashes in a row.
- Sort enum members - __
- Specify a culture or use an invariant version - Specify culture to help avoid accidental implicit dependency on current culture. Using an invariant version yields consistent results regardless of the culture of an application.
- Specify marshaling for P/Invoke string arguments - A platform invoke member allows partially trusted callers, has a string parameter, and does not explicitly marshal the string. This can cause a potential security vulnerability.
- Split parameters should start on line after declaration - The parameters to a C# method or indexer call or declaration span across multiple lines, but the first parameter does not start on the line after the opening bracket.
- Split variable declaration - __
- Statement should not be on a single line - A C# statement containing opening and closing braces is written completely on a single line.
- Statement should not use unnecessary parenthesis - A C# statement contains parenthesis which are unnecessary and should be removed.
- Statement should not use unnecessary parenthesis - A C# statement contains parenthesis which are unnecessary and should be removed.
- Static field names should begin with underscore - A static field name in C# does not begin with an underscore.
- Static holder types should be Static or NotInheritable - __
- Static readonly fields should begin with upper-case letter - The name of a static readonly field does not begin with an upper-case letter.
- Store files as UTF-8 with byte order mark - Source files should be saved using the UTF-8 encoding with a byte order mark
- String contains an implicit end of line character - __
- StringComparison is missing - __
- StyleTypedProperty is missing - StyleTypedProperty is missing.
- Symbols should be spaced correctly - The spacing around an operator symbol is incorrect, within a C# code file.
- System using directives should be placed before other using directives - A using directive which declares a member of the 'System' namespace appears after a using directive which declares a member of a different namespace, within a C# code file.
- Test for NaN correctly - This expression tests a value against Single.Nan or Double.Nan. Use Single.IsNan(Single) or Double.IsNan(Double) to test the value.
- Test for empty strings using string length - Comparing strings by using the String.Length property or the String.IsNullOrEmpty method is significantly faster than using Equals.
- The callback is trivial, convert to lambda - The callback is trivial, convert to lambda for better locality.
- This method uses runtime marshalling even when the 'DisableRuntimeMarshallingAttribute' is applied - This method uses runtime marshalling even when runtime marshalling is disabled, which can cause unexpected behavior differences at runtime due to different expectations of a type's native layout.
- Type parameter names should begin with T - The name of a C# type parameter does not begin with the capital letter T.
- Types that own disposable fields should be disposable - A class declares and implements an instance field that is a System.IDisposable type, and the class does not implement IDisposable. A class that declares an IDisposable field indirectly owns an unmanaged resource and should implement the IDisposable interface.
- URI-like parameters should not be strings - This rule assumes that the parameter represents a Uniform Resource Identifier (URI). A string representation or a URI is prone to parsing and encoding errors, and can lead to security vulnerabilities. 'System.Uri' class provides these services in a safe and secure manner.
- Unconstrained type parameter checked for null - __
- Unnecessary assignment - __
- Unnecessary call to 'Contains(item)' - Do not guard 'Add(item)' or 'Remove(item)' with 'Contains(item)' for the set. The former two already check whether the item exists and will return if it was added or removed.
- Unnecessary call to 'Dictionary.ContainsKey(key)' - Do not guard 'Dictionary.Remove(key)' with 'Dictionary.ContainsKey(key)'. The former already checks whether the key exists, and will not throw if it does not.
- Unnecessary enum flag - __
- Unnecessary explicit use of enumerator - __
- Unnecessary interpolated string - __
- Unnecessary interpolation - __
- Unnecessary null check - __
- Unnecessary null-forgiving operator - __
- Unnecessary raw string literal - __
- Unnecessary semicolon at the end of declaration - __
- Unnecessary unsafe context - __
- Unnecessary usage of verbatim string literal - __
- Unused element in a documentation comment - __
- Unused parameter - __
- Unused type parameter - __
- Use "" or 'string.Empty' - __
- Use 'Cast' instead of 'Select' to cast - __
- Use 'Count/Length' property instead of 'Any' method - __
- Use 'Environment.CurrentManagedThreadId' - 'Environment.CurrentManagedThreadId' is simpler and faster than 'Thread.CurrentThread.ManagedThreadId'.
- Use 'Environment.ProcessId' - 'Environment.ProcessId' is simpler and faster than 'Process.GetCurrentProcess().Id'.
- Use 'Environment.ProcessPath' - 'Environment.ProcessPath' is simpler and faster than 'Process.GetCurrentProcess().MainModule.FileName'.
- Use 'HasFlag' method or bitwise operator - __
- Use 'Order' instead of 'OrderBy' - __
- Use 'StartsWith' instead of 'IndexOf' - It is both clearer and faster to use 'StartsWith' instead of comparing the result of 'IndexOf' to zero.
- Use 'ThrowIfCancellationRequested' - 'ThrowIfCancellationRequested' automatically checks whether the token has been canceled, and throws an 'OperationCanceledException' if it has.
- Use 'for' statement instead of 'while' statement - __
- Use 'is' operator instead of 'as' operator - __
- Use 'is' operator instead of SequenceEqual - __
- Use 'string.Equals' - It is both clearer and likely faster to use 'string.Equals' instead of comparing the result of 'string.Compare' to zero.
- Use 'string.IsNullOrEmpty' method - __
- Use 'var' or explicit type - __
- Use --/++ operator instead of assignment - __
- Use ArgumentException throw helper - Throw helpers are simpler and more efficient than an if block constructing a new exception instance.
- Use ArgumentNullException throw helper - Throw helpers are simpler and more efficient than an if block constructing a new exception instance.
- Use ArgumentOutOfRangeException throw helper - Throw helpers are simpler and more efficient than an if block constructing a new exception instance.
- Use Array.Empty<T>() - __
- Use AsSpan or AsMemory instead of Range-based indexers when appropriate - The Range-based indexer on string values produces a copy of requested portion of the string. This copy is usually unnecessary when it is implicitly used as a ReadOnlySpan or ReadOnlyMemory value. Use the AsSpan method to avoid the unnecessary copy.
- Use AsSpan or AsMemory instead of Range-based indexers when appropriate - The Range-based indexer on array values produces a copy of requested portion of the array. This copy is usually unnecessary when it is implicitly used as a ReadOnlySpan or ReadOnlyMemory value. Use the AsSpan method to avoid the unnecessary copy.
- Use AsSpan or AsMemory instead of Range-based indexers when appropriate - The Range-based indexer on array values produces a copy of requested portion of the array. This copy is often unwanted when it is implicitly used as a Span or Memory value. Use the AsSpan method to avoid the copy.
- Use AttributeUsageAttribute - __
- Use DateTime.UnixEpoch - __
- Use DateTimeOffset.UnixEpoch - __
- Use EventArgs.Empty - __
- Use EventArgs.Empty - __
- Use EventHandler<T> - __
- Use Guid.Empty - __
- Use InvokeVoidAsync when the returned value is not used - __
- Use Length/Count property instead of Count() when available - Enumerable.Count() potentially enumerates the sequence while a Length/Count property is a direct access.
- Use ObjectDisposedException throw helper - Throw helpers are simpler and more efficient than an if block constructing a new exception instance.
- Use Regex instance instead of static method - __
- Use SequenceEqual instead of equality operator - __
- Use SetValue in setter - Use SetValue in setter.
- Use String.Equals instead of equality operator - __
- Use StringComparer.GetHashCode instead of string.GetHashCode - __
- Use StringComparison when comparing strings - __
- Use Task.ConfigureAwait - __
- Use ^ operator - __
- Use a cached 'SearchValues' instance - Using a cached 'SearchValues' instance is more efficient than passing values to 'IndexOfAny'/'ContainsAny' directly.
- Use an explicit StringComparer when possible - __
- Use anonymous function or method group - __
- Use async/await when necessary - __
- Use auto-implemented property - __
- Use block body or expression body - __
- Use braces consistently - The opening and closing braces of a chained if/else if/else construct were included for some clauses, but omitted for others.
- Use built-in type alias - The code uses one of the basic C# types, but does not use the built-in alias for the type.
- Use char literal for a single character lookup - 'string.Contains(char)' is available as a better performing overload for single char lookup.
- Use char overload - The char overload is a better performing overload than a string with a single char.
- Use coalesce expression - __
- Use coalesce expression instead of 'if' - __
- Use coalesce expression instead of conditional expression - __
- Use compound assignment - __
- Use conditional access - __
- Use conditional access instead of conditional expression - __
- Use constant instead of field - __
- Use containing member as key when creating a ComponentResourceKey - Use containing member as key when creating a ComponentResourceKey.
- Use containing type when creating a ComponentResourceKey - Use containing type when creating a ComponentResourceKey.
- Use correct argument for [AttachedPropertyBrowsableForType] - Use correct argument for [AttachedPropertyBrowsableForType].
- Use correct handler type - Use correct handler type.
- Use direct methods instead of LINQ methods - __
- Use element access - __
- Use enum field explicitly - __
- Use exception filter - __
- Use explicitly/implicitly typed array - __
- Use implicit/explicit object creation - __
- Use indexer instead of LINQ methods - __
- Use lambda expression instead of anonymous method - __
- Use lambda syntax - Lambda expressions are more succinct and easier to read than anonymous methods, so they should are preferred whenever the two are functionally equivalent.
- Use langword in XML comment - __
- Use line endings correctly at end of file - Code should not contain blank lines at the end of the file
- Use literal suffix notation instead of casting - Use literal suffix notation instead of casting, in order to improve readability, avoid bugs related to illegal casts and ensure that optimal IL is produced.
- Use literals where appropriate - A field is declared static and read-only (Shared and ReadOnly in Visual Basic), and is initialized by using a value that is computable at compile time. Because the value that is assigned to the targeted field is computable at compile time, change the declaration to a const (Const in Visual Basic) field so that the value is computed at compile time instead of at runtime.
- Use method chaining - __
- Use nameof operator - __
- Use nameof operator in ArgumentException - __
- Use nameof to express symbol names - Using nameof helps keep your code valid when refactoring.
- Use nameof() instead of constant - Use nameof() as it is less fragile than constant.
- Use nameof() instead of literal - Use nameof() as it is less fragile than string literal.
- Use ordinal string comparison - A string comparison operation that is nonlinguistic does not set the StringComparison parameter to either Ordinal or OrdinalIgnoreCase. By explicitly setting the parameter to either StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase, your code often gains speed, becomes more correct, and becomes more reliable.
- Use parentheses to make not pattern clearer - __
- Use pattern matching instead of combination of 'as' operator and null check - __
- Use pattern matching instead of combination of 'is' operator and cast operator - __
- Use pattern matching instead of equality operators for discrete value - __
- Use pattern matching instead of equality operators for null check - __
- Use pattern matching instead of inequality operators for discrete value - __
- Use pattern matching instead of inequality operators for null check - __
- Use predefined type - __
- Use raw string literal - __
- Use read-only auto-implemented property - __
- Use readable conditions - When a comparison is made between a variable and a literal, the variable should be placed on the left-hand-side to maximize readability.
- Use short-circuiting operator - __
- Use span-based 'string.Concat' - It is more efficient to use 'AsSpan' and 'string.Concat', instead of 'Substring' and a concatenation operator.
- Use string interpolation instead of 'string.Concat' - __
- Use string.Create instead of FormattableString - __
- Use string.Empty for empty strings - The C# code includes an empty string, written as "".
- Use string.Length instead of comparison with empty string - __
- Use tabs correctly - The code contains a tab or space character which is not consistent with the current project settings.
- Use the 'StringComparison' method overloads to perform case-insensitive string comparisons - Avoid calling 'ToLower', 'ToUpper', 'ToLowerInvariant' and 'ToUpperInvariant' to perform case-insensitive string comparisons because they lead to an allocation. Instead, prefer calling the method overloads of 'Contains', 'IndexOf' and 'StartsWith' that take a 'StringComparison' enum value to perform case-insensitive comparisons. Switching to using an overload that takes a 'StringComparison' might cause subtle changes in behavior, so it's important to conduct thorough testing after applying the suggestion. Additionally, if a culturally sensitive comparison is not required, consider using 'StringComparison.OrdinalIgnoreCase'.
- Use the Regex source generator - __
- Use trailing comma in multi-line initializers - A multi-line initializer in a C# code file should use a comma on the last line.
- Using alias directives should be ordered alphabetically by alias name - The using-alias directives within a C# code file are not sorted alphabetically by alias name.
- Using alias directives should be placed after other using directives - A using-alias directive is positioned before a regular using directive.
- Using directives should be ordered alphabetically by namespace - The using directives within a C# code file are not sorted alphabetically by namespace.
- Using directives should be placed correctly - A C# using directive is placed outside of a namespace element.
- Using directives should be qualified - All using directives should be qualified.
- Using static directives should be ordered alphabetically - All using static directives should be ordered alphabetically.
- Using static directives should be placed at the correct location. - A using static directive is positioned before a regular or after an alias using directive.
- Validate arguments correctly - __
- Validate arguments correctly in iterator methods - __
- Value type object is never equal to null - __
- ValueConversion must use correct types - ValueConversion must use correct types.
- Variable names should begin with lower-case letter - The name of a variable in C# does not begin with a lower-case letter.
- Variable names should not be prefixed - A field name in C# is prefixed with 'm', 's_', or 't_'._
- Void return value should not be documented - A C# code element does not contain a return value, or returns void, but the documentation header for the element contains a <returns> tag.
- While-do footer should not be preceded by blank line - The while footer at the bottom of a do-while statement is separated from the statement by a blank line.
- XmlnsDefinitions does not map all namespaces with public types - XmlnsDefinitions does not map all namespaces with public types.
- [ConstructorArgument] must match - [ConstructorArgument] must match the name of the constructor parameter.
- [deprecated] Avoid usage of do statement to create an infinite loop - __
- [deprecated] Avoid usage of for statement to create an infinite loop - __
- [deprecated] Avoid usage of while statement to create an infinite loop - __
- [deprecated] Format documentation summary on a single line - __
- [deprecated] Format documentation summary on multiple lines - __
- [deprecated] Remove empty 'else' clause - __
- [deprecated] Remove empty 'finally' clause - __
- [deprecated] Remove empty destructor - __
- [deprecated] Remove empty initializer - __
- [deprecated] Remove empty namespace declaration - __
- [deprecated] Remove empty region - __
- [deprecated] Remove empty statement - __
- [deprecated] Remove redundant comma in initializer - __
- [deprecated] Remove unnecessary blank line - __
- [deprecated] Use 'var' instead of explicit type (in foreach) - __
- [deprecated] Use 'var' instead of explicit type (when the type is not obvious) - __
- [deprecated] Use 'var' instead of explicit type (when the type is obvious) - __
- [deprecated] Use bit shift operator - __
- [deprecated] Use explicit type instead of 'var' (foreach variable) - __
- [deprecated] Use explicit type instead of 'var' (when the type is not obvious) - __
- [deprecated] Use explicit type instead of 'var' (when the type is obvious) - __
rewrite-dotnet
- Analyze a .NET project using upgrade-assistant - Run upgrade-assistant analyze across a repository to analyze changes required to upgrade projects to a newer version of .NET. This recipe will generate an
org.openrewrite.dotnet.UpgradeAssistantAnalysis
data table containing the report details. - Upgrade a .NET project using upgrade-assistant - Run upgrade-assistant upgrade across a repository to upgrade projects to a newer version of .NET.
rewrite-gradle
- Add Gradle dependency - Add a gradle dependency to a
build.gradle
file in the correct configuration based on where it is used. - Add Gradle platform dependency - Add a gradle platform dependency to a
build.gradle
file in the correct configuration based on where it is used. - Add Gradle property - Add a property to the
gradle.properties
file. - Module has dependency - Searches for Gradle Projects (modules) that have a dependency matching the specified id or implementing class. Places a
SearchResult
marker on all sources within a project with a matching dependency. This recipe is intended to be used as a precondition for other recipes. For example this could be used to limit the application of a spring boot migration to only projects that use spring-boot-starter, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) file that use the dependency, use theFindDependency
recipe instead. - Module has plugin - Searches for Gradle Projects (modules) that have a plugin matching the specified id or implementing class. Places a
SearchResult
marker on all sources within a project with a matching plugin. This recipe is intended to be used as a precondition for other recipes. For example this could be used to limit the application of a spring boot migration to only projects that apply the spring dependency management plugin, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) file applying the plugin, use theFindPlugins
recipe instead. - Update Gradle wrapper - Update the version of Gradle used in an existing Gradle wrapper. Queries services.gradle.org to determine the available releases, but prefers the artifact repository URL which already exists within the wrapper properties file. If your artifact repository does not contain the same Gradle distributions as services.gradle.org, then the recipe may suggest a version which is not available in your artifact repository.
- Update a Gradle plugin by id - Update a Gradle plugin by id to a later version defined by the plugins DSL. To upgrade a plugin dependency defined by
buildscript.dependencies
, use theUpgradeDependencyVersion
recipe instead. - Upgrade Gradle dependency versions - Upgrade the version of a dependency in a build.gradle file. Supports updating dependency declarations of various forms: *
String
notation:"group:artifact:version"
*Map
notation:group: 'group', name: 'artifact', version: 'version'
Can update version numbers which are defined earlier in the same file in variable declarations. - Upgrade transitive Gradle dependencies - Upgrades the version of a transitive dependency in a Gradle build file. There are many ways to do this in Gradle, so the mechanism for upgrading a transitive dependency must be considered carefully depending on your style of dependency management.
rewrite-hcl
- Move content to another file - Move content to another HCL file, deleting it in the original file.
rewrite-hibernate
- Remove table from single table inherited entity - For Single Table Inherited Entities Hibernate ignores the
@Table
annotation on child entities. From Version 6.6 it is considered an error.
rewrite-java
- Create Java class - Create a new, empty Java class.
- Find the oldest Java version in use - The oldest Java version in use is the lowest Java version in use in any source set of any subproject of a repository. It is possible that, for example, the main source set of a project uses Java 8, but a test source set uses Java 17. In this case, the oldest Java version in use is Java 8.
- Find type mappings - Study the frequency of
J
types and theirJavaType
type attribution. - Study the size of the classpath by source set - Emit one data table row per source set in a project, with the number of types in the source set.
rewrite-java-dependencies
- Add Gradle or Maven dependency - For a Gradle project, add a gradle dependency to a
build.gradle
file in the correct configuration based on where it is used. Or For a maven project, Add a Maven dependency to apom.xml
file in the correct scope based on where it is used. - Dependency resolution diagnostic - Recipes which manipulate dependencies must be able to successfully access the artifact repositories and resolve dependencies from them. This recipe produces two data tables used to understand the state of dependency resolution. The Repository accessibility report lists all the artifact repositories known to the project and whether respond to network access. The network access is attempted while the recipe is run and so is representative of current conditions. The Gradle dependency configuration errors lists all the dependency configurations that failed to resolve one or more dependencies when the project was parsed. This is representative of conditions at the time the LST was parsed.
- Find minimum JUnit version - A recipe to find the minimum version of JUnit dependencies. This recipe is designed to return the minimum version of JUnit in a project. It will search for JUnit 4 and JUnit 5 dependencies in the project. If both versions are found, it will return the minimum version of JUnit 4. If a minimumVersion is provided, the recipe will search to see if the minimum version of JUnit used by the project is no lower than the minimumVersion. For example: if the minimumVersion is 4, and the project has JUnit 4.12 and JUnit 5.7, the recipe will return JUnit 4.12. If the project has only JUnit 5.7, the recipe will return JUnit 5.7. Another example: if the minimumVersion is 5, and the project has JUnit 4.12 and JUnit 5.7, the recipe will not return any results.
- Find relocated dependencies - Find Maven and Gradle dependencies and Maven plugins that have relocated to a new
groupId
orartifactId
. Relocation information comes from the oga-maven-plugin maintained by Jonathan Lermitage, Filipe Roque and others. This recipe makes no changes to any source file by default. AddchangeDependencies=true
to change dependencies, but note that you might need to run additional recipes to update imports and adopt other breaking changes. - Find the oldest matching dependency version in use - The oldest dependency version in use is the lowest dependency version in use in any source set of any subproject of a repository. It is possible that, for example, the main source set of a project uses Jackson 2.11, but a test source set uses Jackson 2.16. In this case, the oldest Jackson version in use is Java 2.11.
- Module has dependency - Searches for both Gradle and Maven modules that have a dependency matching the specified groupId and artifactId. Places a
SearchResult
marker on all sources within a module with a matching dependency. This recipe is intended to be used as a precondition for other recipes. For example this could be used to limit the application of a spring boot migration to only projects that use spring-boot-starter, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) or pom.xml file applying the plugin, use theFindDependency
recipe instead. - Remove a Gradle or Maven dependency - For Gradle project, removes a single dependency from the dependencies section of the
build.gradle
. For Maven project, removes a single dependency from the<dependencies>
section of the pom.xml. - Repository has dependency - Searches for both Gradle and Maven modules that have a dependency matching the specified groupId and artifactId. Places a
SearchResult
marker on all sources within a repository with a matching dependency. This recipe is intended to be used as a precondition for other recipes. For example this could be used to limit the application of a spring boot migration to only projects that use a springframework dependency, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) or pom.xml file applying the plugin, use theFindDependency
recipe instead. - Upgrade Gradle or Maven dependency versions - For Gradle projects, upgrade the version of a dependency in a
build.gradle
file. Supports updating dependency declarations of various forms: *String
notation:"group:artifact:version"
*Map
notation:group: 'group', name: 'artifact', version: 'version'
It is possible to update version numbers which are defined earlier in the same file in variable declarations. For Maven projects, upgrade the version of a dependency by specifying a group ID and (optionally) an artifact ID using Node Semver advanced range selectors, allowing more precise control over version updates to patch or minor releases. - Upgrade transitive Gradle or Maven dependencies - Upgrades the version of a transitive dependency in a Maven pom.xml or Gradle build.gradle. Leaves direct dependencies unmodified. Can be paired with the regular Upgrade Dependency Version recipe to upgrade a dependency everywhere, regardless of whether it is direct or transitive.
rewrite-java-security
- Enable CSRF attack prevention - Cross-Site Request Forgery (CSRF) is a type of attack that occurs when a malicious web site, email, blog, instant message, or program causes a user's web browser to perform an unwanted action on a trusted site when the user is authenticated. See the full OWASP cheatsheet.
- Find and fix vulnerable Nuget dependencies - This software composition analysis (SCA) tool detects and upgrades dependencies with publicly disclosed vulnerabilities. This recipe both generates a report of vulnerable dependencies and upgrades to newer versions with fixes. This recipe only upgrades to the latest patch version. If a minor or major upgrade is required to reach the fixed version, this recipe will not make any changes. Vulnerability information comes from the GitHub Security Advisory Database, which aggregates vulnerability data from several public databases, including the National Vulnerability Database maintained by the United States government. Dependencies following Semantic Versioning will see their patch version updated where applicable.
- Find and fix vulnerable dependencies - This software composition analysis (SCA) tool detects and upgrades dependencies with publicly disclosed vulnerabilities. This recipe both generates a report of vulnerable dependencies and upgrades to newer versions with fixes. This recipe by default only upgrades to the latest patch version. If a minor or major upgrade is required to reach the fixed version, this can be controlled using the
maximumUpgradeDelta
option. Vulnerability information comes from the GitHub Security Advisory Database, which aggregates vulnerability data from several public databases, including the National Vulnerability Database maintained by the United States government. Upgrades dependencies versioned according to Semantic Versioning. Last updated: 2025-08-11T1102. - Find licenses in use in third-party dependencies - Locates and reports on all licenses in use.
- Prevent clickjacking - The
frame-ancestors
directive can be used in a Content-Security-Policy HTTP response header to indicate whether or not a browser should be allowed to render a page in a<frame>
or<iframe>
. Sites can use this to avoid Clickjacking attacks by ensuring that their content is not embedded into other sites. - Remove unused dependencies - Scans through source code collecting references to types and methods, removing any dependencies that are not used from Maven or Gradle build files. This recipe takes reflective access into account: When reflective access to a class is made unambiguously via a string literal, such as:
Class.forName("java.util.List")
that is counted correctly. When reflective access to a class is made ambiguously via anything other than a string literal no dependencies will be removed. This recipe takes transitive dependencies into account: When a direct dependency is not used but a transitive dependency it brings in is in use the direct dependency is not removed. - Software bill of materials - Produces a software bill of materials (SBOM) for a project. An SBOM is a complete list of all dependencies used in a project, including transitive dependencies. The produced SBOM is in the CycloneDX XML format. Supports Gradle and Maven. Places a file named sbom.xml adjacent to the Gradle or Maven build file.
- XML parser XXE vulnerability - Avoid exposing dangerous features of the XML parser by updating certain factory settings.
rewrite-jenkins
- Add plugin developer team to CODEOWNERS - Adds the
{artifactId}-plugin-developers
team to all files in.github/CODEOWNERS
if absent. - Create
index.jelly
if it doesn't exist - Jenkins tooling requiressrc/main/resources/index.jelly
exists with a description. - Upgrade jenkins java version - Upgrades the version of java specified in Jenkins groovy scripts. Will not downgrade if the version is newer than the specified version.
rewrite-liberty
- Removes invalid JNDI properties - Remove the use of invalid JNDI properties from Hashtable.
rewrite-maven
- Add Maven dependency - Add a Maven dependency to a
pom.xml
file in the correct scope based on where it is used. - Add a configuration option for the Maven runtime - Add a new configuration option for the Maven runtime if not already present.
- Add managed Maven dependency - Add a managed Maven dependency to a
pom.xml
file. - Add the Develocity Maven extension - To integrate the Develocity Maven extension into Maven projects, ensure that the
develocity-maven-extension
is added to the.mvn/extensions.xml
file if not already present. Additionally, configure the extension by adding the.mvn/develocity.xml
configuration file. - Increment Maven project version - Increase Maven project version by incrementing either the major, minor, or patch version as defined by semver. Other versioning schemes are not supported.
- Manage dependencies - Make existing dependencies managed by moving their version to be specified in the dependencyManagement section of the POM.
- Module has dependency - Searches for Maven modules that have a dependency matching the specified groupId and artifactId. Places a
SearchResult
marker on all sources within a module with a matching dependency. This recipe is intended to be used as a precondition for other recipes. For example this could be used to limit the application of a spring boot migration to only projects that use spring-boot-starter, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) file applying the plugin, use theFindDependency
recipe instead. - Module has plugin - Searches for Maven modules that have a plugin matching the specified groupId and artifactId. Places a
SearchResult
marker on all sources within a module with a matching plugin. This recipe is intended to be used as a precondition for other recipes. For example this could be used to limit the application of a spring boot migration to only projects that apply the spring boot plugin, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) file applying the plugin, use theFindPlugins
recipe instead. - Remove unused properties - Detect and remove Maven property declarations which do not have any usage within the project.
- Update Maven wrapper - Update the version of Maven used in an existing Maven wrapper.
- Upgrade Maven dependency version - Upgrade the version of a dependency by specifying a group and (optionally) an artifact using Node Semver advanced range selectors, allowing more precise control over version updates to patch or minor releases.
- Upgrade transitive Maven dependencies - Upgrades the version of a transitive dependency in a Maven pom file. Leaves direct dependencies unmodified. Can be paired with the regular Upgrade Dependency Version recipe to upgrade a dependency everywhere, regardless of whether it is direct or transitive.
rewrite-micronaut
- Add Maven annotation processor path - Add the groupId, artifactId, version, and exclusions of a Maven annotation processor path.
- Add
@Introspected
to classes requiring a map representation - In Micronaut 2.x a reflection-based strategy was used to retrieve that information if the class was not annotated with@Introspected
. As of Micronaut 3.x it is required to annotate classes with@Introspected
that are used in this way. - Add
snakeyaml
dependency if needed - This recipe will add thesnakeyaml
dependency to a Micronaut 4 application that uses yaml configuration. - Copy non-inherited annotations from super class - As of Micronaut 3.x only annotations that are explicitly meta-annotated with
@Inherited
are inherited from parent classes and interfaces.
rewrite-migrate-java
- Add scope annotation to injected classes - Finds member variables annotated with
@Inject' and applies
@Dependent` scope annotation to the variable's type. - Adds
static
modifier to@Produces
fields that are in session beans - Ensures that the fields annotated with@Produces
which is inside the session bean (@Stateless
,@Stateful
, or@Singleton
) are declaredstatic
. - Convert
@lombok.Value
class to Record - Convert Lombok@Value
annotated classes to standard Java Records. - Migrate Joda-Time to Java time - Prefer the Java standard library over third-party usage of Joda Time.
- Plan a Java version migration - Study the set of Java versions and associated tools in use across many repositories.
- Project has no Jakarta annotations - Mark all source as found per
JavaProject
where no Jakarta annotations are found. This is useful mostly as a precondition for recipes that require Jakarta annotations to be present - Rename getter methods to fit Lombok - Rename methods that are effectively getter to the name Lombok would give them. Limitations: - If two methods in a class are effectively the same getter then one's name will be corrected and the others name will be left as it is. - If the correct name for a method is already taken by another method then the name will not be corrected. - Method name swaps or circular renaming within a class cannot be performed because the names block each other. E.g.
int getFoo() { return ba; } int getBa() { return foo; }
stays as it is. - Rename setter methods to fit Lombok - Rename methods that are effectively setter to the name Lombok would give them. Limitations: - If two methods in a class are effectively the same setter then one's name will be corrected and the others name will be left as it is. - If the correct name for a method is already taken by another method then the name will not be corrected. - Method name swaps or circular renaming within a class cannot be performed because the names block each other. E.g.
int getFoo() { return ba; } int getBa() { return foo; }
stays as it is. - Unannotated entity attributes require a Transient annotation - In OpenJPA, attributes that are themselves entity classes are not persisted by default. EclipseLink has a different default behavior and tries to persist these attributes to the database. To keep the OpenJPA behavior of ignoring unannotated entity attributes, add the
javax.persistence.Transient
annotation to these attributes in EclipseLink. - Use latest JAXB API and runtime for Jakarta EE 8 - Update build files to use the latest JAXB runtime from Jakarta EE 8 to maintain compatibility with Java version 11 or greater. The recipe will add a JAXB run-time, in Gradle
compileOnly
+testImplementation
and Mavenprovided
scope, to any project that has a transitive dependency on the JAXB API. The resulting dependencies still use thejavax
namespace, despite the move to the Jakarta artifact. @Embeddable
classes cannot have an@Id
annotation when referenced by an@EmbeddedId
annotation - According to the Java Persistence API (JPA) specification, if an entity defines an attribute with an@EmbeddedId
annotation, the embeddable class cannot contain an attribute with an@Id
annotation. If both the@EmbeddedId
annotation and the@Id
annotation are defined, OpenJPA ignores the@Id
annotation, whereas EclipseLink throws an exception.
rewrite-nodejs
- Find Node.js projects - Find Node.js projects and summarize data about them.
- Find and fix vulnerable npm dependencies - This software composition analysis (SCA) tool detects and upgrades dependencies with publicly disclosed vulnerabilities. This recipe both generates a report of vulnerable dependencies and upgrades to newer versions with fixes. This recipe only upgrades to the latest patch version. If a minor or major upgrade is required to reach the fixed version, this recipe will not make any changes. Vulnerability information comes from the GitHub Security Advisory Database, which aggregates vulnerability data from several public databases, including the National Vulnerability Database maintained by the United States government. Dependencies following Semantic Versioning will see their patch version updated where applicable.
- Node.js dependency insight - Identify the direct and transitive Node.js dependencies used in a project.
rewrite-program-analysis
- Find LDAP injection vulnerabilities - Finds LDAP injection vulnerabilities by tracking tainted data flow from user input to LDAP queries.
- Find PII exposure in logs and external APIs - Detects when Personally Identifiable Information (PII) is exposed through logging statements or sent to external APIs without proper sanitization. This helps prevent data leaks and ensures compliance with privacy regulations like GDPR and CCPA.
- Find SQL injection vulnerabilities - Detects potential SQL injection vulnerabilities where user input flows to SQL execution methods without proper sanitization.
- Find XSS vulnerabilities - Detects potential cross-site scripting vulnerabilities where user input flows to output methods without proper sanitization.
- Find command injection vulnerabilities - Detects when user-controlled input flows into system command execution methods like Runtime.exec() or ProcessBuilder, which could allow attackers to execute arbitrary commands.
- Find path traversal vulnerabilities - Detects potential path traversal vulnerabilities where user input flows to file system operations without proper validation.
- Find unencrypted PII storage - Identifies when personally identifiable information (PII) is stored in databases, files, or other persistent storage without encryption.
- Track data lineage - Tracks the flow of data from database sources (JDBC queries, JPA entities) to API sinks (REST endpoints, GraphQL mutations) to understand data dependencies and support compliance requirements.
rewrite-properties
- Create Properties file - Create a new Properties file.
rewrite-rewrite
- Extract documentation examples from tests - Extract the before/after sources from tests annotated with
@DocumentExample
, and generate a YAML file with those examples to be shown in the documentation to show usage.
rewrite-spring
- Add logging.pattern.level for traceId and spanId - Add
logging.pattern.level
for traceId and spanId which was previously set by default, if not already set. - Applications using logging shutdown hooks - Spring Boot registers a logging shutdown hook by default for JAR-based applications to ensure that logging resources are released when the JVM exits. If your application is deployed as a WAR then the shutdown hook is not registered since the servlet container usually handles logging concerns. Most applications will want the shutdown hook. However, if your application has complex context hierarchies, then you may need to disable it. You can use the
logging.register-shutdown-hook
property to do that. - Integration scheduler pool size - Spring Integration now reuses an available
TaskScheduler
rather than configuring its own. In a typical application setup relying on the auto-configuration, this means that Spring Integration uses the auto-configured task scheduler that has a pool size of 1. To restore Spring Integration’s default of 10 threads, use thespring.task.scheduling.pool.size
property. - Is likely a Spring Boot project - Marks the project if it's likely a Spring Boot project.
- Is likely a Spring Framework project - Marks the project if it's likely a Spring Framework project.
- Is likely not a Spring Boot project - Marks the project if it's likely not a Spring Boot project.
- Maintain trailing slash URL mappings - This is part of Spring MVC and WebFlux URL Matching Changes, as of Spring Framework 6.0, the trailing slash matching configuration option has been deprecated and its default value set to false. This means that previously, a controller
@GetMapping("/some/greeting")
would match bothGET /some/greeting
andGET /some/greeting/
, but it doesn't matchGET /some/greeting/
anymore by default and will result in an HTTP 404 error. This recipe is to maintain trailing slash in all HTTP url mappings. - Merge Spring
bootstrap.yml
withapplication.yml
- In Spring Boot 2.4, support forbootstrap.yml
was removed. It's properties should be merged withapplication.yml
. - Migrate Spring Framework Dependencies to Spring Boot - Migrate Spring Framework Dependencies to Spring Boot.
- Migrate
Docket
toGroupedOpenAPI
- Migrate aDocket
bean to aGroupedOpenAPI
bean preserving group name, packages and paths. When possible the recipe will prefer property based configuration. - Migrate
web.xml
toWebApplicationInitializer
- Migrateweb.xml
toWebApplicationInitializer
for Spring applications. This allows for programmatic configuration of the web application context, replacing the need for XML-based configuration. This recipe only picks upweb.xml
files located in thesrc/main/webapp/WEB-INF
directory to avoid inference with tests. - Migrate management endpoint access value - Migrate manage endpoint access value from
false
tonone
andtrue
toread-only
. - Rename bean - Renames a Spring bean, both declaration and references.
- Replace String literals with
HttpHeaders
constants - Replace String literals withorg.springframework.http.HttpHeaders
constants. - Replace String literals with
MediaType
constants - Replace String literals withorg.springframework.http.MediaType
constants. - Separate application YAML by profile - The Spring team's recommendation is to separate profile properties into their own YAML files now.
- Update the API manifest - Keep a consolidated manifest of the API endpoints that this application exposes up-to-date.
- Upgrade Spring dependencies - Upgrades dependencies according to the specified version of spring boot. Spring boot has many direct and transitive dependencies. When a module has an explicit dependency on one of these it may also need to be upgraded to match the version used by spring boot.
- Use
AutoConfiguration#imports
- UseAutoConfiguration#imports
instead of the deprecated entryEnableAutoConfiguration
inspring.factories
when defining autoconfiguration classes.
rewrite-static-analysis
- Rename packages to lowercase - By convention all Java package names should contain only lowercase letters, numbers, and dashes. This recipe converts any uppercase letters in package names to be lowercase.
- Standardize method name casing - Fixes method names that do not follow standard naming conventions. For example,
String getFoo_bar()
would be adjusted toString getFooBar()
andint DoSomething()
would be adjusted toint doSomething()
.
rewrite-testing-frameworks
- Add Hamcrest JUnit dependency - Add Hamcrest JUnit dependency only if JUnit 4's
assertThat
orassumeThat
is used. - Add JUnit Jupiter dependencies - Adds JUnit Jupiter dependencies to a Maven or Gradle project. Junit Jupiter can be added either with the artifact junit-jupiter, or both of junit-jupiter-api and junit-jupiter-engine. This adds "junit-jupiter" dependency unless "junit-jupiter-api" or "junit-jupiter-engine" are already present.
- Find unit tests - Produces a data table showing how methods are used in unit tests.
- Remove
public
visibility of JUnit 5 tests - Removepublic
and optionallyprotected
modifiers from methods with@Test
,@ParameterizedTest
,@RepeatedTest
,@TestFactory
,@BeforeEach
,@AfterEach
,@BeforeAll
, or@AfterAll
. They no longer have to be public visibility to be usable by JUnit 5. - Replace Mockito 1.x
anyString()
/any()
withnullable(Class)
- Since Mockito 2.10anyString()
andany()
no longer matches null values. Usenullable(Class)
instead. - Replace
verifyZeroInteractions()
withverifyNoMoreInteractions()
- ReplacesverifyZeroInteractions()
withverifyNoMoreInteractions()
in Mockito tests when migration when using a Mockito version < 3.x.
rewrite-vulncheck
- Use VulnCheck Exploit Intelligence to fix vulnerabilities - This software composition analysis (SCA) tool detects and upgrades dependencies with publicly disclosed vulnerabilities. This recipe both generates a report of vulnerable dependencies and upgrades to newer versions with fixes. This recipe by default only upgrades to the latest patch version. If a minor or major upgrade is required to reach the fixed version, this can be controlled using the
maximumUpgradeDelta
option. Vulnerability information comes from VulnCheck Vulnerability Intelligence. The recipe has an option to limit fixes to only those vulnerabilities that have evidence of exploitation at various levels of severity.
rewrite-xml
- Create XML file - Create a new XML file.
- XML style Auto-detection debug - Runs XML Autodetect and records the results in data tables and search markers. A debugging tool for figuring out why XML documents get styled the way they do.
rewrite-yaml
- Copy YAML value - Copies a YAML value from one key to another. The existing key/value pair remains unaffected by this change. Attempts to merge the copied value into the new key if it already exists. Attempts to create the new key if it does not exist.
- Create YAML file - Create a new YAML file.