Code Inspections and Intentions
< Refactoring | Source Code Generation >
Intelligent code analysis within the IDE
Code inspections provide valuable on-the-fly client-side analysis of your source code. Not only can you be confident that your code is ready to send to the server, but Illuminated Cloud can also provide insights about ways your code can be improved or streamlined and even apply the corresponding fixes or changes with a single keystroke.
The JetBrains IDEs already include many useful code inspections for supported languages, and commercial editions seamlessly integrate external static code analyzers such as ESLint.
Illuminated Cloud includes a number of Salesforce-specific code inspections and intentions for Apex, Aura, Lightning, and Salesforce Functions development, and new code inspections and intentions will be added in subsequent releases.
Annotation and Modifier Agreement
Reports situations where annotations and modifiers are not in proper agreement with one another. For example, an abstract method can only exist in an abstract class, a global method can only exist in a global class, overridden methods must use the override modifier, etc.
Quick fixes for this inspection either remove the offending annotation/modifier or change the corresponding annotations/modifiers to resolve the issue.
ApexDoc Validation
Reports issues in ApexDoc comments, including missing comments on type and member declarations at or above a configurable visibility threshold and missing or malformed ApexDoc tags.
Quick fixes for this inspection either add an ApexDoc comment, if not present, or reformats and rebuilds an existing ApexDoc comment to resolve all issues that do not require explicit user input.
Aura Deprecated Component
Reports usages of deprecated Aura components to indicate to the user they should be migrated to the corresponding replacing component(s) where possible.
Control Flow Analysis
Performs control flow analysis on Apex source files to report issues such as unreachable statements (those that follow return or throw statements in the same statement block), methods with non-void return types but without return paths via return statements or throw statements, methods with void return types which attempt to return values, etc.
Quick fixes for this inspection assist with resolution of these issues, e.g., removing unreachable statements, changing method return types to match returned values, adding and removing return statements to match the method signature, etc.
Control Flow Statement Without Braces
Reports any if, while, do/while, or for statements without braces. Braces make the code easier to read and help prevent errors when modifying the code.
The quick fix for this inspection wraps the statement body with braces.
Deprecated API Usage
Reports usages of Apex declarations with the @Deprecated annotation.
Duplicate Declaration
Reports declarations with names/signatures that already exist in the same declaration scope.
The quick fix for this inspection navigates to the duplicate declaration.
Field Can Be Made Static
Reports instance variables that can safely be made static. This inspection ignores global fields by default but can be configured to report them if desired.
The quick fix for this inspection adds a static modifier to the field declaration and updates all instance-based usages of the field to be class-based.
File Contents Verification
Reports Apex source files with invalid contents, either where top-level declarations are invalid for the file type or the single top-level declaration name does not match the source file name.
The quick fixes for this inspection assist with resolution of these issues, e.g., renaming top-level declarations to match containing files or renaming/moving containing files to match the top-level declarations.
Illegal Assignment
Reports illegal assignments and comparisons as a result of incompatible types.
The quick fixes for this inspection add a cast operator of the expected type or, if appropriate, change the method return type to the returned type.
Incomplete Concrete Class Declaration
Reports concrete classes which don't implement all required abstract/interface methods from base types.
The quick fixes for this inspection add valid implementations of all unimplemented methods or add the abstract modifier to the enclosing class.
Invalid Type
Reports declarations with invalid types, e.g., a variable declared as type 'void'.
Keyword Does Not Use Preferred Case
Reports keywords which don't use the preferred case exactly. While Apex is a case-insensitive language, variations in case within the same code base can be confusing.
The quick fix for this inspection changes the keyword to its preferred form.
Method Can Be Made Static
Reports instance methods that can safely be made static. This inspection reports private methods by default but can be configured to report public and global methods if desired. It also ignores methods with empty bodies by default but can be configured to report them.
The quick fix for this inspection adds a static modifier to the method declaration and updates all instance-based usages of the method to be class-based.
PMD Salesforce
Integrates real-time PMD Apex, Visualforce, and XML static code analysis into Illuminated Cloud 2.
Quick fixes for this inspection navigate to the rule in the PMD rule set configuration file that resulted in a reported violation, disable the rule via XML block comment in the rule set file, and assist with changing the associated rule priority.
Safe Navigation Operator Usage
Reports invalid usages of the Apex safe navigation operator (?.).
The quick fix for this inspection offers to migrate invalid usages of the safe navigation operator (?.) to the standard navigation operator (.).
Salesforce Function JavaScript Type Inference Hints
Reports JSDoc tags in JavaScript-based Salesforce functions that don't include (correct) type inference hints and helps to provide them for more accurate JavaScript type inference and therefore more accurate offered code completions, integrated documentation, etc.
The quick fix for this inspection adds type inference hints for the standard JavaScript Salesforce function inputs.
Scope Agreement
Reports situations where class methods are invoked from instances of the same type, instance methods are invoked from class methods, and similar.
Quick fixes for this inspection offer to assist with resolution of these types of scope agreement issues.
SLDS Deprecated Class
Reports usages of deprecated SLDS classes to indicate to the user they should be migrated to the corresponding replacing classes where possible.
The quick fix for this inspection replaces the deprecated SLDS class (BEM which uses "--") with the replacing class (which uses "_").
Unresolvable Method or Constructor Signature
Reports method and constructor invocations that cannot be resolved to corresponding signatures.
Unresolvable Reference
Reports references that cannot be resolved to corresponding declarations.
The quick fix for this inspection generates valid implementations of the unresolvable declaration based on name and type information inferred from the usage.
Unused Declaration
Reports classes, methods or fields in the specified inspection scope that are not used or not reachable from entry points.
The quick fix for this inspection removes the unused declaration.
Usage Case Does Not Match Declaration Case
Reports usages of declarations where the usage case doesn't match the declaration case exactly. While Apex is a case-insensitive language, differences in case between declarations and their usages can be confusing.
The quick fix for the inspection changes the usage to its declaration form.
Variable Is Assigned To Itself
Reports assignment of a variable to itself, most often the result of trying to initialize or update the value of a member variable from a constructor or method parameter with the same name.
The quick fix for this inspection adds a this. qualification to the assignment target if the value is assigned to a member variable and a local variable exists with the same name.
Dealing With False Positives
Code inspections can be easily suppressed for false positives, modified for a different severity, or disabled entirely.