> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/settings/code-scope-ignore-include.md).

# Code Scope (Ignore/Include)

SeaLights' Code Scope empowers you to **tailor your quality analysis**. Define **inclusion and exclusion rules** to analyze specific code areas, prioritizing relevant sections and **streamlining testing** (e.g., excluding legacy code you are not interested in getting coverage for). \
By default, the entire app's code is included. There are three ways to set Code Scope: app level, file level and method level.

***

### **Global App-Level Code Scope**

Each application has a built-in "Global Code Entities Rule" that intelligently excludes certain method-level elements based on the app's programming language. This typically includes:

* **Auto-Generated Code:** Eliminate noise from code that isn't manually written.
* **Getters and Setters:** Focus on core logic instead of routine property access.
* **Constructors:** Simplify analysis by excluding default object creation methods.
* **Deprecated Code:** Avoid analyzing outdated and potentially unsafe sections.
* **Anonymous Methods:** Streamline analysis by excluding methods defined directly within blocks of code.

By fine-tuning this global rule, you establish a solid foundation for focused and efficient analysis, ensuring that your efforts are directed toward the most impactful areas of your codebase.

<details>

<summary>Follow these steps for customization</summary>

1. Access the "Code Scope" page within "Settings".
2. Locate the relevant application.
3. Review the pre-checked code entities excluded by default.
4. Personalize your analysis:
   * Check additional entities for exclusion.
   * Uncheck entities you wish to include.

<img src="https://1255034336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxSagdStwf6CJ9cI6lA68%2Fuploads%2F06M8mcBvzMVHjfbTtW6V%2Fimage.png?alt=media&amp;token=026e8290-aa22-400c-b39b-0fd23e64c0af" alt="" data-size="original">.&#x20;

<img src="https://1255034336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxSagdStwf6CJ9cI6lA68%2Fuploads%2FycfvbDlnwNhaeJLyE5iR%2Fimage.png?alt=media&amp;token=e60dfdc6-02db-4a42-ae3d-1b2c30cccc02" alt="" data-size="original">

</details>

***

### **File-Level Code Scope**

SeaLights' Code Scope offers **granular control** at the file level. This enables you to find a **sweet spot between accuracy and maintenance**, tailoring your analysis to focus on critical sections while keeping management manageable. Rule types:

* **Include:** Focuses analysis on specific code areas. Ideal for analyzing smaller scopes or excluding irrelevant sections. For example, If you want to analyze the coverage for API tests, create an "Include" rule for this particular test stage that targets only the files relevant for those APIs.
* **Ignore:** Removes specific code from analysis, streamlining your focus. For example, excluding legacy code you are not interested in getting coverage for.

{% hint style="info" %}
**Rule Conflicts:**

Please note that when defining both "Include" and "Ignore" rules for the same code scope, the "Ignore" rule will take precedence. This ensures you have clear control over what gets excluded from your analysis.
{% endhint %}

Newly added files within a scoped folder automatically adhere to the defined rules, ensuring your analysis stays up-to-date. No need to manually update every time your codebase changes!

<details>

<summary>Follow these steps for customization</summary>

1. Navigate to the "Code Scope" page within "Settings".
2. Select the relevant application.
3. Define include / ignore **rules for individual test stages or all stages collectively**, customizing your analysis to specific testing needs. Define multiple rules per app/stage (order doesn't matter).
4. Leverage the flexibility to edit, duplicate and delete rules.&#x20;

<img src="https://1255034336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxSagdStwf6CJ9cI6lA68%2Fuploads%2FSlgCuDwFaPwyh8RGGmdC%2Fimage.png?alt=media&amp;token=0788a1b8-8918-422c-8c65-486cc6cfcfd9" alt="" data-size="original">

</details>

***

### **Method-Level Code Scope**

SeaLights' Code Scope offers fine-grained **method-level exclusions** directly within the **Test Gaps Analysis report**. You can pinpoint individual methods, mark them for exclusion as needed and focus your analysis on truly relevant code.

Excluded methods automatically become "Ignore" rules in the Code Scope settings, ensuring your analysis adapts effortlessly as your codebase evolves.

{% hint style="info" %}
**Note!** Excluded methods remain visible in the report but are marked as ignored for clarity.
{% endhint %}

<details>

<summary>Follow these steps for customization</summary>

1. From the Test Gaps Analysis report **drill down** to a specific file with untested methods.
2. **Select specific methods** you want to exclude from analysis.
3. These exclusions are automatically reflected as **"Ignore" rules** under the relevant app in the Code Scope settings page.
4. You can easily **review or delete** these rules as needed.

<img src="https://1255034336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxSagdStwf6CJ9cI6lA68%2Fuploads%2Fx0gh7G8AgTDDEQPHjRzc%2Fimage.png?alt=media&amp;token=7c690cb9-2a89-4d0f-8313-e8b0495d785b" alt="" data-size="original">

<img src="https://1255034336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxSagdStwf6CJ9cI6lA68%2Fuploads%2FLMU4LJWNXhgbmwBdLz90%2Fimage.png?alt=media&amp;token=dfa1b596-1d4e-4ac6-b864-ae95f3e5e048" alt="" data-size="original">

</details>

***

## **Bulk Upload Rules**

When managing rules across many applications, SeaLights provides a **bulk upload workflow** that lets you configure rules for all your apps at once using a CSV file, instead of setting them one application at a time.

There are two modes:

* **Append:** Add new rules on top of your existing ones. Nothing is removed, current rules stay intact.
* **Replace All:** Replace every existing rule across all applications with the contents of your CSV file. Use this when treating your CSV as the single source of truth.

{% hint style="warning" %}
**Replace All is irreversible.** All existing code scope rules across all apps will be permanently deleted and replaced with the uploaded file. Download your current rules as a backup before proceeding.&#x20;
{% endhint %}

**CSV Format**

The CSV file must include the following columns:

<table><thead><tr><th width="161.66796875">Column</th><th width="89.49609375">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>app</code></td><td>✅</td><td>Application name, must match the app name in SeaLights exactly</td></tr><tr><td><code>test_stage</code></td><td>✅</td><td>Stage name (nter the exact stage name as it appears in SeaLights. e.g., <code>Unit Tests</code>) or <code>All</code> to apply the rule across every stage</td></tr><tr><td><code>rule_type</code></td><td>✅</td><td><code>ignore</code> or <code>include</code></td></tr><tr><td><code>rule_condition</code></td><td>✅</td><td><code>starts_with</code>, <code>ends_with</code>, <code>contains</code>, <code>exact_match</code>, or <code>entire_app</code></td></tr><tr><td><code>method</code></td><td>—</td><td>Method name for method-level rules. When specified, <code>rule_type</code> must be <code>ignore</code></td></tr><tr><td><code>path</code></td><td>—</td><td>File path or pattern. Required unless <code>rule_condition</code> is <code>entire_app</code> or a method is specified</td></tr><tr><td><code>reason</code></td><td>✅</td><td>Free-text note explaining the rule, required for traceability</td></tr></tbody></table>

<details>

<summary>Follow these steps to bulk upload rules:</summary>

1. Navigate to the **Code Scope** page within **Settings**.
2. Click **Bulk Upload Rules** at the top of the page.
3. **Choose a mode** — Append to add rules, or Replace All to overwrite everything.
4. **Download** the CSV template (Append) or your existing rules (Replace All) and prepare your file.
5. **Upload** your CSV on the next step. SeaLights validates column structure and row values instantly.
6. Review any errors or warnings in the validation table — only rows with issues are shown.
7. Once all errors are resolved, click **Apply**.

</details>

**Validation**

When you upload a CSV, SeaLights performs two independent checks:

* **Column structure** — verifies all required columns are present in the header row.
* **Row-level data** — checks each row for missing values, invalid `rule_type` or `rule_condition` values, and method rules with an incorrect rule type.

Rows with **errors** block the upload and must be fixed. Rows with **warnings** (e.g., an unrecognized app name or test stage) are informational — the upload can proceed.

{% hint style="info" %}
**Keep in mind!** Only invalid or warning rows are shown in the validation table. Valid rows are counted in the summary but not listed — making it practical to work with files containing hundreds of rules.&#x20;
{% endhint %}

***

{% hint style="info" %}
**Keep in mind!** Code Scope rules take effect from the next reported build in SeaLights. Unless using the new Coverage Analysis, where all rules take effect on the following data refresh (every 15 minutes).
{% endhint %}

By defining Code Scope, you can tailor the analysis to specific code areas, gain valuable insights into software quality, and focus on improving the most critical sections of your codebase.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/settings/code-scope-ignore-include.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
