Java Cheatsheets

[BASIC]

[JAVA]

Add Null to Collection

Finds places where we add null to a collection

[BASIC]

[JAVA]

Array Access

Finds array access expressions with an index expression consisting of a unary assignment

[BASIC]

[JAVA]

Call to constructor

Finds places where we call `new com.example.Class(...)`

[BASIC]

[JAVA]

Call To Method

Finds calls to com.example.Class.methodName

[BASIC]

[JAVA]

Cast expressions

Finds casts from a floating point type to an integer type

[BASIC]

[JAVA]

Catch Exception

Finds places where we catch exceptions of type com.example.AnException

[BASIC]

[JAVA]

Class extends/implements

Finds classes/interfaces that extend/implement com.example.Class

[BASIC]

[JAVA]

Find comments match pattern

Finds comments containing the word 'TODO'

[BASIC]

[JAVA]

Conditional Expressions

Finds conditional expressions of the form '... ? ... : ...' where the types of the resulting expressions differ

[BASIC]

[JAVA]

Empty Blocks

Finds empty block statements

[BASIC]

[JAVA]

Equality test on boolean

Finds tests like `==true`, `==false`, `!=true`, `!=false`

[BASIC]

[JAVA]

Field declared volatile

Finds fields with a 'volatile' modifier

[BASIC]

[JAVA]

Find references link

Generates use-definition pairs that provide the data for find-references in the code viewer.

[BASIC]

[JAVA]

If statements with empty then branch

Finds 'if' statements where the 'then' branch is an empty block statement

[BASIC]

[JAVA]

Integer Literal

Finds places where we use the integer literal `0`

[BASIC]

[JAVA]

Jump-to-definition links

Generates use-definition pairs that provide the data for jump-to-definition in the code viewer.

[BASIC]

[JAVA]

Method with many parameters

Finds methods with more than ten parameters

[BASIC]

[JAVA]

Method without return type

Finds methods whose return type is 'void'

[BASIC]

[JAVA]

Mutual recursion

Finds pairs of methods that call each other

[BASIC]

[JAVA]

Native Methods

Finds methods that are native (Java Native Interface)

[BASIC]

[JAVA]

Override of method

Finds methods that override com.example.Class.baseMethod

[BASIC]

[JAVA]

Print source code AST

Outputs a representation of a file's Abstract Syntax Tree. This query is used by the VS Code extension.

[BASIC]

[JAVA]

Qualified 'this' access

Finds 'this' accesses that are qualified by a type name

[BASIC]

[JAVA]

Read of field

Finds reads of aField (defined on com.example.Class)

[BASIC]

[JAVA]

Return statements

Finds return statements that return 'null'

[BASIC]

[JAVA]

Singleton blocks

Finds block statements containing a single statement

[BASIC]

[JAVA]

Switch statement case missing

Finds switch statements with a missing enum constant case and no default case

[BASIC]

[JAVA]

Synchronized Methods

Finds methods that are synchronized

[BASIC]

[JAVA]

Throw exception of type

Finds places where we throw com.example.AnException or one of its subtypes

[BASIC]

[JAVA]

Try-finally statements

Finds try-finally statements without a catch clause

[BASIC]

[JAVA]

Unused local variable

Finds local variables that are not accessed

[BASIC]

[JAVA]

Unused parameter

Finds parameters that are not accessed

[BASIC]

[JAVA]

Unused private method

Finds private methods that are not accessed