# Detecting Problems

## Circular dependencies

```
MATCH
   (t:Type)-[:DEPENDS_ON*]->(t)
RETURN
   t
```

## Entities used in facade services

```
MATCH
   (facade:Facade)-[:DECLARES]->(method),
   (method)-[:HAS]->()-[:OF_TYPE*]->(receivedtype:Entity),
   (method)-[:RETURNS]->(returntype:Entity)
WHERE
   (method.visibility="public" OR method.visibility="protected")
RETURN
   facade.name AS service,
   method.name AS method,
   collect(distinct receivedtype.name) AS received,
   returntype.name AS returned
```

## Controllers with public final methods

```
MATCH (c:Controller)-[:DECLARES]->(m:Method { visibility: 'public' })
WHERE
   EXISTS(m.final)
RETURN
   c.name as controller,
   m.name as method
```

## Default fields

```
MATCH
   (class)-[:DECLARES]->(field:Field)
WHERE
   field.visibility = 'default'
   AND (
      field.synthetic = false
      OR NOT EXISTS(field.synthetic)
   )
RETURN DISTINCT
   class.name AS class,
   field.name AS field
ORDER BY
   class,
   field
```

## Methods Not Used

```
MATCH
   (service)-[:DECLARES]->(method:Method)
WHERE
   method.name <> 'null'
   AND NOT ()-[:INVOKES]->(method)
RETURN DISTINCT 
   service.name AS service,
   method.name AS method
```

## Components Not Used

```
MATCH
   (component:Java)
WHERE
   NOT ()-[:DEPENDS_ON]->(component)
   AND NOT component:Test
   AND NOT component:Controller
   AND NOT component:Configuration
RETURN DISTINCT 
   component.name AS component
```


---

# Agent Instructions: 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://bernardo.gitbook.io/development-docs-java/jqassistant/queries/detecting-problems.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.
