apache / apache/grails-intellij-plugin

False-positive unused import on controller in its spec

Open
#339 0 comments 0 reactions 0 assignees View on GitHub
bug imported-from-youtrack
Dominant language
Java
Stars
17
Forks
4
Avg merge
5d 15h
Merged PRs (30d)
4

Description

I have code of this form in a Grails (2.5.6) project:

```groovy
import MyController
import grails.test.mixin.TestFor
import spock.lang.Specification

@TestFor(MyController)
class MyControllerSpec extends Specification { ... }
```
The import of the controller is reported as unused by the resp. inspection, but Optimize Import does not remove it:

_⚠️ attachment `image.png` was not included in the export_

Since the import is _not_ obsolete, it shouldn't trigger the warning.

---

*1 attachment(s) referenced here (`image.png`) are not part of the CSV export.*
*Imported from [IDEA-201195](https://youtrack.jetbrains.com/issue/IDEA-201195) · Type: Bug · Votes: 0*
*Comments, attachments, dates and reporter are not part of the export — follow the link above for the full history.*

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the case in a Grails 2.5.6 project using a controller spec with @TestFor(MyController), then trace the unused-import inspection's handling of that annotation. Done means the controller import is no longer reported as unused and Optimize Import continues to preserve it.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.