# 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
- Chain AssertJ AssertThat Statements
- Collapse If Statements
- Hide Default Constructor In Utility Classes
- Inline Local Variables
- Make SerialVersionUID Static Final
- Rearrange Class Members
- Remove Double Negations
- Remove Inherited Interfaces from Class Declaration
- Remove Null-Checks Before Instanceof
- Remove Redundant Close
- Remove Unnecessary Semicolons
- Remove Unused Fields
- Remove Unused Local Variables
- Remove Unused Methods
- Remove Unused Parameters in Private Methods
- Remove Unused Types
- 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 Request Mapping Annotation
- Replace equals() on Enum Constants
- Replace removeAll() with clear()
- Replace static final Collections with Collections.unmodifiable...()
- Shift AssertJ Description Before Assertion
- Split Multiple Variable Declarations
- System Out To Logging
- Use @Override Annotation
- Use Arrays Stream
- Use Comparator Methods
- Use Dedicated AssertJ Assertions
- Use Dedicated Assertions
- Use Guard Condition
- Use Optional::filter
- Use Optional::map
- Use equals() on Primitive Objects
# Free rules for jSparrow Eclipse IDE
The following rules are included directly after installation for Eclipse IDE.
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 Iterable::forEach
- 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::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 Iterable::forEach
- 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::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
# Marker
The "marker" tag marks rules that include quick-fixes. Markers give developers the ability to click and choose an automatic fix to various problems during programming. jSparrow's markers i.e. quick fixes can be used to make refactoring much faster.
List of rules with this tag:
- Add Braces to Control Statements
- Avoid Concatenation in Logging Statements
- Collapse If Statements
- Create Temp Files Using Java NIO
- Inline Local Variables
- Insert Break Statements in For-loops
- Make Fields And Variables Final
- Remove Boxing for String Conversions
- Remove Collection::addAll
- Remove Deprecated Date Constructs
- Remove Double Negations
- Remove Explicit Call To super()
- Remove Explicit Type Argument
- Remove Inherited Interfaces from Class Declaration
- Remove Lambda Expression Braces
- Remove Modifiers in Interface Properties
- Remove Null-Checks Before Instanceof
- Remove Redundant Close
- Remove Redundant Type Casts
- Remove Unnecessary Semicolons
- Remove Unnecessary Thrown Exceptions on Method Signatures
- Remove Unused Parameters in Private Methods
- Remove toString() on String
- Reorder Modifiers
- Reorder String Equality Check
- Replace Assignment with Compound Operator
- Replace Collection.sort with List.sort
- Replace Equality Check with isEmpty()
- Replace Expression Lambda with Method Reference
- Replace For-Loop with Enhanced-For-Loop
- Replace For-Loop with Iterable::forEach
- Replace For-Loop with Stream::collect(Collectors.joining())
- Replace For-Loop with Stream::findFirst
- Replace For-Loop with Stream::sum
- Replace For-Loop with Stream::takeWhile
- Replace Inefficient Constructors with valueOf()
- Replace JUnit Expected Annotation Property with assertThrows
- Replace JUnit ExpectedException with assertThrows
- Replace JUnit Timeout Annotation Property with assertTimeout
- Replace JUnit assertThat with Hamcrest
- Replace Map::get by Map::getOrDefault
- Replace Nested Loops with flatMap
- Replace Request Mapping Annotation
- Replace Set.removeAll With ForEach
- Replace Stream Collect By ToList
- Replace String Format by Formatted
- Replace While-Loop with Enhanced For-Loop
- Replace Wrong Class for Logger
- Replace equals() on Enum Constants
- Replace indexOf() with contains()
- Replace put(..) with putIfAbsent(..)
- Replace removeAll() with clear()
- Replace static final Collections with Collections.unmodifiable...()
- Reuse Random Objects
- Split Multiple Variable Declarations
- StringBuffer() to StringBuilder()
- Use @Override Annotation
- Use Arrays Stream
- Use BufferedReader::lines
- Use Collections Singleton List
- Use Comparator Methods
- Use Dedicated AssertJ Assertions
- Use Dedicated Assertions
- Use Factory Methods for Collections
- Use Files.newBufferedReader
- Use Files.newBufferedWriter
- Use Files.writeString
- Use Functional Interfaces
- Use Guard Condition
- Use Java Records
- Use Local Variable Type Inference
- Use Multi Catch
- Use Offset Based String Methods
- Use Optional::filter
- Use Optional::ifPresent
- Use Optional::ifPresentOrElse
- Use Optional::map
- Use Parameterized JPA Query
- Use Parameterized LDAP Query
- Use Parameterized Query
- Use Portable Newline
- Use Predefined Standard Charset
- Use SecureRandom
- Use Stream::collect
- Use Stream::filter
- Use Stream::map
- Use String Join
- Use String Literals
- Use StringBuilder::append
- Use Switch Expression
- Use Text Block
- Use Try-With-Resource
- Use equals() on Primitive Objects
# 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 Multi Branch If By Switch
- Replace Stream Collect By ToList
- 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 Java Records
- Use Multi Catch
- Use Optional::ifPresent
- Use Optional::ifPresentOrElse
- Use Pattern Matching for Instanceof
- Use Switch Expression
- Use Text Block
- 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()
- Replace Set.removeAll With ForEach
- 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
- Chain AssertJ AssertThat 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 Close
- Remove Redundant Type Casts
- Remove Unnecessary Thrown Exceptions on Method Signatures
- Remove Unused Fields
- Remove Unused Local Variables
- Remove Unused Methods
- Remove Unused Parameters in Private Methods
- Remove Unused Types
- 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 Multi Branch If By Switch
- Replace Request Mapping Annotation
- Replace Stream Collect By ToList
- Replace String Format by Formatted
- Replace Wrong Class for Logger
- Replace indexOf() with contains()
- Split Multiple Variable Declarations
- Use @Override Annotation
- Use Comparator Methods
- Use Dedicated AssertJ Assertions
- Use Factory Methods for Collections
- Use Java Records
- Use Local Variable Type Inference
- Use Multi Catch
- Use Optional::filter
- Use Optional::map
- Use Pattern Matching for Instanceof
- Use Switch Expression
- Use Ternary Operator
- Use Text Block
- 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
- Replace String Format by Formatted
- 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 encourage using best practices in the test code.
List of rules with this tag:
- Chain AssertJ AssertThat Statements
- Replace JUnit 3 Tests
- Replace JUnit 4 Annotations with JUnit Jupiter
- Replace JUnit 4 Assertions with JUnit Jupiter
- Replace JUnit 4 Assumptions with JUnit Jupiter
- Replace JUnit 4 Category with JUnit Jupiter Tag
- Replace JUnit Assumptions with Hamcrest Junit
- Replace JUnit Expected Annotation Property with assertThrows
- Replace JUnit ExpectedException with assertThrows
- Replace JUnit Timeout Annotation Property with assertTimeout
- Replace JUnit assertThat with Hamcrest
- Shift AssertJ Description Before Assertion
- Use Dedicated AssertJ Assertions
- Use Dedicated Assertions
# JUnit
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:
- Replace JUnit 3 Tests
- Replace JUnit 4 Annotations with JUnit Jupiter
- Replace JUnit 4 Assertions with JUnit Jupiter
- Replace JUnit 4 Assumptions with JUnit Jupiter
- Replace JUnit 4 Category with JUnit Jupiter Tag
- Replace JUnit Assumptions with Hamcrest Junit
- Replace JUnit Expected Annotation Property with assertThrows
- Replace JUnit ExpectedException with assertThrows
- Replace JUnit Timeout Annotation Property with assertTimeout
- Replace JUnit assertThat with Hamcrest
- Use Dedicated Assertions
# AssertJ
jSparrow rules having this tag encourage best practices on using the AssertJ (opens new window) library for writing fluent assertions in unit tests.
List of rules with this tag:
# Spring
jSparrow rules having this tag encourage best practices on using the Spring (opens new window) library for writing web applications.
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
- Inline Local Variables
- 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 Fields
- Remove Unused Local Variables
- Remove Unused Methods
- Remove Unused Parameters in Private Methods
- Remove Unused Types
- Remove toString() on String
- Rename Fields
- Reorder Modifiers
- Reorder String Equality Check
- Replace Concatenation with Infix-Operation
- Replace Wrong Class for Logger
- 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 JUnit Assumptions with Hamcrest Junit
- Replace JUnit assertThat with Hamcrest
- Replace Request Mapping Annotation
- Replace While-Loop with Enhanced For-Loop
- Replace equals() on Enum Constants
- Replace indexOf() with contains()
- StringBuffer() to StringBuilder()
- Use Dedicated Assertions
- 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 Iterable::forEach
- 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::sum
- Replace JUnit 3 Tests
- Replace JUnit 4 Annotations with JUnit Jupiter
- Replace JUnit 4 Assertions with JUnit Jupiter
- Replace JUnit 4 Assumptions with JUnit Jupiter
- Replace JUnit 4 Category with JUnit Jupiter Tag
- 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 Set.removeAll With ForEach
- Replace put(..) with putIfAbsent(..)
- Use Arrays Stream
- Use BufferedReader::lines
- Use Dedicated AssertJ Assertions
- 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:
# Java 11
List of rules with this tag:
# Java 14
List of rules with this tag:
# Java 15
List of rules with this tag:
# Java 16
List of rules with this tag: