Github
Join us on Slack
Search…
Introduction to OpenRewrite
Getting Started
Quickstart: Maven and Gradle
Recipe Development Environment
Tutorials & Guides
Common Static Analysis Issue Remediation
Automatically Fix Checkstyle Violations
Migrate to Java 11 from Java 8
Migrate to JUnit 5 from JUnit 4
Migrate to Spring Boot 2 from Spring Boot 1
Migrate to Quarkus 2 from Quarkus 1
Migrate to Micronaut 3 from Micronaut 2
Migrate to SLF4J from Log4j
Use SLF4J Parameterized Logging
Writing a Java Refactoring Recipe
Modifying Methods with JavaTemplate
Refactoring with Declarative YAML Recipes
Automating Maven Dependency Management
Running Rewrite without build tool plugins
Writing recipes over multiple source file types
Reference
Latest versions of every OpenRewrite module
Maven Plugin Configuration
Gradle Plugin Configuration
JsonPath and JsonPathMatcher Reference
Declarative YAML Format
Method Patterns
Dependency Version Selectors
Recipes
Gradle
Hcl
Java
Add ASLv2 license header
Add license header
Add or update annotation attribute
Change method access level
Change method name
Change method target to static
Change method target to variable
Change static field access to static method access
Change type
Delete method argument
Order imports
Randomize tree IDs
Remove annotation
Remove interface implementations
Remove static import
Remove unused imports
Rename package name
Reorder method arguments
Replace constant with literal value
Simplify a call chain
Update source positions
Use static import
Uses @RewriteSkip annotation
Cleanup
Add missing @Override to overriding and implementing methods
Add serialVersionUID to a Serializable class when missing
Atomic Boolean, Integer, and Long equality checks compare their values
BigDecimal rounding constants to RoundingMode enums
Boolean checks should not be inverted
CaseInsensitive comparisons do not alter case
Catch clause should do more than just rethrow
Change StringBuilder and StringBuffer character constructor arg to String
Code cleanup
Common static analysis issues
Control flow statement indentation
Covariant equals
Default comes last
Enum values should be compared with "=="
Equals avoids null
Explicit initialization
Externalizable classes have no-arguments constructor
Fall through
Fields in a Serializable class should either be transient or serializable
Finalize classes with private constructors
Finalize local variables
Fix missing braces
Hidden field
Hide utility class constructor
Java API best practices
Jump statements should not be redundant
Method name casing
Method parameter padding
Modifier order
Multiple variable declarations
Nested enums are not static
No C-style array declarations
No double brace initialization
No primitive wrappers for #toString() or #compareTo(..)
No whitespace after
No whitespace before
Operator wrapping
Pad empty for loop components
Prefer while over for loops
Redundant file creation
Reformat local variable names to camelCase
Reformat private field names to camelCase
Remove Nullable and CheckForNull annotations from primitives
Remove author tags from JavaDocs
Remove empty blocks
Remove extra semicolons
Remove finalize() method
Remove redundant casts
Remove unnecessary parentheses
Remove unneeded block
Remove unused local variables
Remove unused private methods
Rename caught exceptions in empty catch blocks to ignored
Rename methods named hashcode, equal, or tostring.
Replace duplicate String literals
Set charset encoding explicitly when calling String#getBytes. This will not override any existing ex
Simplify boolean expression
Simplify boolean return
Simplify compound statement
Simplify consecutive assignments
Simplify constant if branch execution
Simplify lambda blocks to expressions
Static methods not final
Typecast parenthesis padding
Unnecessary String#toString()
Unnecessary String#valueOf(..)
Unnecessary close in try-with-resources
Unnecessary explicit type arguments
Unnecessary throws
Use Collection interfaces
Use Collection#isEmpty() instead of comparing size()
Use Collections#emptyList(), emptyMap(), and emptySet()
Use Map#containsKey
Use String.equals() on String literals
Use String::replace() when fist parameter is not a real regular expression
Use comparison rather than equality checks in for conditions
Use diamond operator
Use explicit types on lambda arguments
Use indexOf(String, int)
Use lambdas where possible
Use method references in lambda
Use primitive wrapper valueOf method
Write octal values as decimal
finalize() calls super
for loop counters incremented in update
for loop counters should use postfix operators
indexOf should not compare greater than zero
indexOf() replaceable by contains()
switch statements should have at least 3 case clauses
Format
JHipster
Logging
Micronaut
Modernize
OpenRewrite best practices
Quarkus
Search
Security
Spring
Testing
JSON
Maven
Properties
XML
YAML
CircleCI
Concourse
Github Actions
Kubernetes
Terraform
Concepts & Explanations
Abstract Syntax Trees
Recipes
Visitors
Styles
Environment
Markers
JavaTemplate
Pointcut Expressions
Design Partners
Design Partner 1
Powered By
GitBook
Hidden field
** org.openrewrite.java.cleanup.HiddenField**
Refactor local variables or parameters which shadow a field defined in the same class.
Tags
RSPEC-1117
Source
​
Github
,
Issue Tracker
,
Maven Central
​
groupId: org.openrewrite
artifactId: rewrite-java
version: 7.22.0
Usage
This recipe has no required configuration parameters and comes from a rewrite core library. It can be activated directly without adding any dependencies.
Gradle
Maven
build.gradle
1
plugins
{
2
id
(
"org.openrewrite.rewrite"
)
version
(
"5.20.0"
)
3
}
4
​
5
rewrite
{
6
activeRecipe
(
"org.openrewrite.java.cleanup.HiddenField"
)
7
}
8
​
9
repositories
{
10
mavenCentral
()
11
}
Copied!
pom.xml
1
<
project
>
2
<
build
>
3
<
plugins
>
4
<
plugin
>
5
<
groupId
>
org.openrewrite.maven
</
groupId
>
6
<
artifactId
>
rewrite-maven-plugin
</
artifactId
>
7
<
version
>
4.23.0
</
version
>
8
<
configuration
>
9
<
activeRecipes
>
10
<
recipe
>
org.openrewrite.java.cleanup.HiddenField
</
recipe
>
11
</
activeRecipes
>
12
</
configuration
>
13
</
plugin
>
14
</
plugins
>
15
</
build
>
16
</
project
>
Copied!
Recipes can also be activated directly from the command line by adding the argument
-Drewrite.activeRecipes=org.openrewrite.java.cleanup.HiddenField
Previous
Fix missing braces
Next
Hide utility class constructor
Last modified
1d ago
Export as PDF
Copy link
Contents
Tags
Source
Usage