Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

JD.RC.EXPR.CHECK

JD.RC.EXPR.CHECK is triggered when a local variable is checked even though that check will always result in a 'true' value, so the block of code will always execute under this condition.

Vulnerability and risk

Logic flaw. Checks should only be done for properties that are not known in compile time.

Mitigation and prevention

Make sure that you are checking the right variables for the right values.

Example 1

13     void handleEvent(AWTEvent event) {
14         if (event instanceof MouseEvent) {
15             if (event != null) {
16                 handleMouseEvent((MouseEvent) event);
17             }
18         }
19     }

JD.RC.EXPR.CHECK is reported for the check on line 15, since the check on line 14 guarantees that 'event' is not null;

Example 2

13     void handleEvent(AWTEvent event) {
14         if (event != null) {
15             if (event instanceof MouseEvent) {
16                 handleMouseEvent((MouseEvent) event);
17             }
18         }
19     }

JD.RC.EXPR.CHECK is not reported for the snippet: the null check on line 14 does not guarantee that the 'event' is an instance of the MouseEvent class.

Related checkers