Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make plugin testable by stubbing the detekt instance avoiding compiler classpath errors #177

Merged
merged 3 commits into from Jun 7, 2022

Conversation

arturbosch
Copy link
Member

@arturbosch arturbosch commented Jun 5, 2022

Needs detekt/detekt#4923 to remove the DetektStub hack at runtime.

@@ -22,7 +22,7 @@ class DetektAnnotator : ExternalAnnotator<PsiFile, List<Finding>>() {
if (!collectedInfo.project.isDetektEnabled()) {
return emptyList()
}
if (collectedInfo.isKotlinFile()) {
Copy link
Member Author

@arturbosch arturbosch Jun 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was wrong. It would have skipped every Kotlin file but did not because apparently psiFile.language != KotlinLanguage.INSTANCE,
Fixing the tests made this mistake obvious.
Testing for KtFile does not work either as IntelliJ may use some kind of LightPsiElement structures.
We have to compare language id's here. Kotlin light elements also use KotlinLanguage.INSTANCE.

@arturbosch arturbosch merged commit 8551673 into main Jun 7, 2022
@arturbosch arturbosch deleted the make-plugin-testable branch June 7, 2022 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant