> For the complete documentation index, see [llms.txt](https://knowledgebase.autorabit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.autorabit.com/product-guides/codescan/quality-rules/dudataflowanomalyanalysis-rule.md).

# DUDataflowAnomalyAnalysis Rule

As per the **DUDataflowAnomalyAnalysisRule**, the rule analyzes the **data flow of variables**, not just whether they appear to be used in the code.

The rule flags a variable when all of the following conditions are met:

* The variable is defined.
* It later goes out of scope (becomes undefined) when the method exits.
* There exists at least one valid execution path where the variable is never referenced.

A **reference** means an actual read or method call on the variable (for example, accessing a property or invoking a method).

**Return statements are not treated as references by this rule.**

There is also a possibility of violation if the method exits before reaching the variable usage due to an **exception statement**.

The **DUDataflowAnomalyAnalysis rule** analyzes the data flow of local variables throughout a method. It does not just look at the code as a whole; it traces **every possible execution path through the method individually**. It flags a violation when a variable is defined but there exists at least one execution path where it is never read or used before the method exits. Even if a variable is used on one path, if there is even one path where it is never touched, the rule will flag it.

**Expected Behavior**

The **DUDataflowAnomalyAnalysis rule** performs **path-sensitive dataflow analysis** and evaluates every possible execution path in a method. If there is any path where the variable is defined but never read before the method exits, the rule will raise a violation, even if it is used in other branches.

If the goal is to detect variables that are simply never used, the **UnusedLocalVariable rule** may better fit the requirement. Otherwise, the issue can be **marked as a False Positive if the behavior is expected**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://knowledgebase.autorabit.com/product-guides/codescan/quality-rules/dudataflowanomalyanalysis-rule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
