# Add Konsist Existing To Project (Baseline)

Retrofitting Konsist into a project that hasn't followed strict structural guidelines can pose initial challenges, necessitating a thoughtful approach to smoothly transition without disrupting ongoing development. Unlike most linters, which provide a [baseline file](https://developer.android.com/studio/write/lint#snapshot), Konsist follows a different methodology (for now).

{% hint style="success" %}
The baseline file will be added in the future.
{% endhint %}

There are two approaches that can be employed when retrofitting Konsist into an existing project[#create-more-granular-scopes](#create-more-granular-scopes "mention") and [#suppress-annotation](#suppress-annotation "mention").

## Create Granular Scopes

Scope represents a set of Kotlin files. The scope allows to verification of all Kotlin files in the project or only a subset of the project code base.

{% hint style="info" %}
See [koscope](https://docs.konsist.lemonappdev.com/writing-tests/koscope "mention").
{% endhint %}

When refactoring an existing application, you can either choose to first refactor a module and then add a Konsist test or initially add the Konsist test to identify errors, followed by the necessary refactor. Both strategies aim to ensure modules align with Konsist's structural guidelines.

Consider this The `MyDiet` application with feature 3 modules:

<figure><img src="https://3782930697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYeSMx6WDKivnwWx7PdP%2Fuploads%2F5uF3s9HH9UZge0vSC6xZ%2Fimage.png?alt=media&#x26;token=2a5dcfa1-2e68-4f8e-ac2c-0d8639bab80f" alt=""><figcaption></figcaption></figure>

At first, the Konsist test can be applied to a single module:

```kotlin
Konsist
    .scopeFromModule("featureCaloryCalculator")
    .classes()
    .assertTrue { it.hasTestClasses() }
```

{% hint style="info" %}
To review the content of a given scope see [debug-konsist-test](https://docs.konsist.lemonappdev.com/features/debug-konsist-test "mention").
{% endhint %}

As refactoring proceeds and code gets aligned, the Konsist scope can be extended to another feature module (`featureGroceryListGenerator`):

```kotlin
Konsist
    .scopeFromModule("featureCaloryCalculator", "featureGroceryListGenerator")
    .classes()
    .assertTrue { it.hasTest() }
```

When entire code base (all modules) are aligned with the Konsist tests, the scope can be retrieved from the entire project:

```kotlin
Konsist
    .scopeFromProject()
    .classes()
    .assertTrue { it.hasTest() }
```

Usage of project scope (`scopeFromProject` ) is a recommended approach because it helps to guard future modules without modifying the existing Konsist test.

Konsist provides a flexible API to create scopes from modules, source sets, packages, files, etc., and combine these scopes together. See [koscope](https://docs.konsist.lemonappdev.com/writing-tests/koscope "mention").

## Suppress Annotation

The second approach, Suppress Annotation, may be helpful when to Konsist swiftly without making substantial alterations to the existing kotlin files. See [#suppress](#suppress "mention").
