# Tags
Tags describe properties of jSparrow rules with the intent of grouping similar rules together and making them easier to find and search for.
# Coding Conventions
Coding conventions for Java consist of a set of recommended code styles and best practices. Rules with this tag will alter source code parts to follow guides such as the Google Java Style Guide (opens new window) more closely.
List of rules with this tag:
- Avoid Concatenation in Logging Statements
- Collapse If Statements
- Hide Default Constructor In Utility Classes
- Make SerialVersionUID Static Final
- Rearrange Class Members
- Remove Double Negations
- Remove Inherited Interfaces from Class Declaration
- Remove Null-Checks Before Instanceof
- Remove Unnecessary Semicolons
- Remove Unused Parameters in Private Methods
- Rename Fields
- Reorder Modifiers
- Replace Assignment with Compound Operator
- Replace Collection.sort with List.sort
- Replace Equality Check with isEmpty()
- Replace Inefficient Constructors with valueOf()
- Replace equals() on Enum Constants
- Replace removeAll() with clear()
- Replace static final Collections with Collections.unmodifiable...()
- Split Multiple Variable Declarations
- System Out To Logging
- Use @Override Annotation
- Use Arrays Stream
- Use Comparator Methods
- Use Guard Condition
- Use Optional::filter
- Use Optional::map
- Use equals() on Primitive Objects
# Free
Rules with this tag are free to use without limitation. See jSparrow Starter Registration for more details.
List of rules with this tag:
- Collapse If Statements
- Organize Imports
- Remove Boxing for String Conversions
- Remove Double Negations
- Remove Null-Checks Before Instanceof
- Remove Unnecessary Semicolons
- Remove Unnecessary Thrown Exceptions on Method Signatures
- Remove toString() on String
- Reorder String Equality Check
- Replace Equality Check with isEmpty()
- Replace Expression Lambda with Method Reference
- Replace For-Loop with Enhanced-For-Loop
- Replace Inefficient Constructors with valueOf()
- Replace equals() on Enum Constants
- Split Multiple Variable Declarations
- Use @Override Annotation
- Use Offset Based String Methods
- Use Optional::filter
- Use SecureRandom
- Use Try-With-Resource
# IO Operations
This tag marks rules that deal with I/O operations provided by java.io
(opens new window) or java.nio
(opens new window).
List of rules with this tag:
# Lambda
Lambda expressions are anonymous and unnamed functions that enable you to treat functionality as a method argument or code as data. Lambda expressions are an integral part of the java.util.stream
API.
Whenever a rule has this tag, it means that either a lambda expression is introduced or manipulated.
List of rules with this tag:
- Remove Lambda Expression Braces
- Replace Expression Lambda with Method Reference
- Replace For-Loop with Stream::Match
- Replace For-Loop with Stream::collect(Collectors.joining())
- Replace For-Loop with Stream::findFirst
- Replace For-Loop with Stream::forEach
- Replace For-Loop with Stream::sum
- Replace For-Loop with Stream::takeWhile
- Replace JUnit Expected Annotation Property with assertThrows
- Replace JUnit ExpectedException with assertThrows
- Replace JUnit Timeout Annotation Property with assertTimeout
- Replace Nested Loops with flatMap
- Use BufferedReader::lines
- Use Comparator Methods
- Use Functional Interfaces
- Use Optional::filter
- Use Optional::ifPresent
- Use Optional::ifPresentOrElse
- Use Optional::map
- Use Stream::collect
- Use Stream::filter
- Use Stream::map
# Logging
Logging frameworks ease and standardize the process of logging for the Java platform. In particular, they provide flexibility by avoiding explicit output to the console. The location where logs are written becomes independent of the code and can be customized at runtime.
Rules marked with this tag either introduce logging or improve aspects of the same.
List of rules with this tag:
# Loop
A loop is an instruction that repeats until a specified condition is reached. Examples would be for
, while
, or forEach
loops. Respectively, rules with this tag will interact with such loops.
List of rules with this tag:
- Insert Break Statements in For-loops
- Replace For-Loop with Enhanced-For-Loop
- Replace For-Loop with Stream::Match
- Replace For-Loop with Stream::collect(Collectors.joining())
- Replace For-Loop with Stream::findFirst
- Replace For-Loop with Stream::forEach
- Replace For-Loop with Stream::sum
- Replace For-Loop with Stream::takeWhile
- Replace Nested Loops with flatMap
- Replace While-Loop with Enhanced For-Loop
- Use BufferedReader::lines
- Use Stream::collect
- Use Stream::filter
- Use Stream::map
# Old Language Constructs
With additions to the Java platform, a shift towards new best practices is not uncommon, leading to old language constructs that can be improved by using more modern alternatives.
jSparrow rules having this tag replace such constructs with more up-to-date alternatives.
List of rules with this tag:
- Replace Collection.sort with List.sort
- Replace Equality Check with isEmpty()
- Replace For-Loop with Enhanced-For-Loop
- Replace Map::get by Map::getOrDefault
- Replace While-Loop with Enhanced For-Loop
- Replace indexOf() with contains()
- Replace put(..) with putIfAbsent(..)
- System Out To Logging
- Use BufferedReader::lines
- Use Collections Singleton List
- Use Factory Methods for Collections
- Use Files.newBufferedReader
- Use Files.newBufferedWriter
- Use Files.writeString
- Use Functional Interfaces
- Use Multi Catch
- Use Optional::ifPresent
- Use Optional::ifPresentOrElse
- Use Try-With-Resource
# Performance
Performance in programs is usually related to avoiding unnecessary computations, optimizing loops, or using efficient methods provided by common APIs.
For rules, this tag indicates that a code fragment is replaced by a more performant one.
List of rules with this tag:
- Avoid Concatenation in Logging Statements
- Insert Break Statements in For-loops
- Remove Boxing for String Conversions
- Remove toString() on String
- Replace Concatenation with Infix-Operation
- Replace For-Loop with Stream::collect(Collectors.joining())
- Replace Inefficient Constructors with valueOf()
- StringBuffer() to StringBuilder()
- Use Arrays Stream
- Use Collections Singleton List
- Use Files.newBufferedReader
- Use Files.newBufferedWriter
- Use Files.writeString
- Use Offset Based String Methods
- Use Predefined Standard Charset
- Use String Join
- Use String Literals
- Use StringBuilder::append
# Readability
Readability refers to the ease with which a human reader can comprehend the purpose, control flow, and operation of source code. It affects aspects of quality, including portability, usability, and most importantly maintainability.
According to that, rules marked with this tag improve on such aspects.
List of rules with this tag:
- Add Braces to Control Statements
- Avoid Concatenation in Logging Statements
- Collapse If Statements
- Make Fields And Variables Final
- Organize Imports
- Rearrange Class Members
- Reformat Code
- Remove Collection::addAll
- Remove Deprecated Date Constructs
- Remove Explicit Call To super()
- Remove Explicit Type Argument
- Remove Modifiers in Interface Properties
- Remove Null-Checks Before Instanceof
- Remove Redundant Type Casts
- Remove Unnecessary Thrown Exceptions on Method Signatures
- Remove Unused Parameters in Private Methods
- Rename Fields
- Reorder Modifiers
- Replace Assignment with Compound Operator
- Replace Collection.sort with List.sort
- Replace Equality Check with isEmpty()
- Replace JUnit Expected Annotation Property with assertThrows
- Replace JUnit ExpectedException with assertThrows
- Replace JUnit Timeout Annotation Property with assertTimeout
- Replace indexOf() with contains()
- Split Multiple Variable Declarations
- Use @Override Annotation
- Use Comparator Methods
- Use Factory Methods for Collections
- Use Local Variable Type Inference
- Use Multi Catch
- Use Optional::filter
- Use Optional::map
- Use Try-With-Resource
# Security
Security issues refer to vulnerabilities that can be exploited by an attacker to perform unauthorized actions within a computer program. Rules marked with this tag replace vulnerable code fragments with secure alternatives.
List of rules with this tag:
# String Manipulation
String manipulation is the process of creating, parsing, or changing String
variables or literals. Typical operations on strings include a concatenation of values or the creation of a String
output based on the input of another type.
jSparrow rules having this tag will therefore be related to such String
operations.
List of rules with this tag:
- Remove Boxing for String Conversions
- Remove toString() on String
- Reorder String Equality Check
- Replace Concatenation with Infix-Operation
- StringBuffer() to StringBuilder()
- Use Offset Based String Methods
- Use Portable Newline
- Use String Join
- Use String Literals
- Use StringBuilder::append
- Use StringUtils Methods
- Use equals() on Primitive Objects
# Testing
jSparrow rules having this tag are designed to improve JUnit test cases by making use of the new features in JUnit 5 (opens new window) and other related testing libraries.
List of rules with this tag:
# Java Version Tags
Each rule has one Java version related tag, indicating the minimum required Java version of a project to apply the rule.
# Java 1.1
List of rules with this tag:
- Add Braces to Control Statements
- Avoid Concatenation in Logging Statements
- Collapse If Statements
- Escape User Inputs in SQL Queries
- Hide Default Constructor In Utility Classes
- Make Fields And Variables Final
- Make SerialVersionUID Static Final
- Organize Imports
- Rearrange Class Members
- Reformat Code
- Remove Boxing for String Conversions
- Remove Deprecated Date Constructs
- Remove Double Negations
- Remove Explicit Call To super()
- Remove Inherited Interfaces from Class Declaration
- Remove Modifiers in Interface Properties
- Remove Null-Checks Before Instanceof
- Remove Redundant Type Casts
- Remove Unnecessary Semicolons
- Remove Unnecessary Thrown Exceptions on Method Signatures
- Remove Unused Parameters in Private Methods
- Remove toString() on String
- Rename Fields
- Reorder Modifiers
- Reorder String Equality Check
- Replace Concatenation with Infix-Operation
- Reuse Random Objects
- Split Multiple Variable Declarations
- System Out To Logging
- Use Guard Condition
- Use Offset Based String Methods
- Use Parameterized JPA Query
- Use Parameterized Query
- Use String Literals
- Use StringUtils Methods
- Use equals() on Primitive Objects
# Java 1.2
List of rules with this tag:
# Java 1.3
List of rules with this tag:
# Java 1.4
List of rules with this tag:
# Java 5
List of rules with this tag:
- Insert Break Statements in For-loops
- Replace For-Loop with Enhanced-For-Loop
- Replace For-Loop with Stream::collect(Collectors.joining())
- Replace Inefficient Constructors with valueOf()
- Replace While-Loop with Enhanced For-Loop
- Replace equals() on Enum Constants
- Replace indexOf() with contains()
- StringBuffer() to StringBuilder()
- Use Portable Newline
- Use String Join
- Use StringBuilder::append
# Java 6
List of rules with this tag:
# Java 7
List of rules with this tag:
# Java 8
List of rules with this tag:
- Remove Lambda Expression Braces
- Replace Collection.sort with List.sort
- Replace Expression Lambda with Method Reference
- Replace For-Loop with Stream::Match
- Replace For-Loop with Stream::collect(Collectors.joining())
- Replace For-Loop with Stream::findFirst
- Replace For-Loop with Stream::forEach
- Replace For-Loop with Stream::sum
- Replace JUnit 4 Annotations with JUnit Jupiter
- Replace JUnit Expected Annotation Property with assertThrows
- Replace JUnit ExpectedException with assertThrows
- Replace JUnit Timeout Annotation Property with assertTimeout
- Replace Map::get by Map::getOrDefault
- Replace Nested Loops with flatMap
- Replace put(..) with putIfAbsent(..)
- Use Arrays Stream
- Use BufferedReader::lines
- Use Functional Interfaces
- Use Optional::filter
- Use Optional::ifPresent
- Use Optional::map
- Use Stream::collect
- Use Stream::filter
- Use Stream::map
# Java 9
List of rules with this tag:
# Java 10
List of rules with this tag: