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

Provide a way to suppress incubating warnings #20328

Closed
asarkar opened this issue Mar 30, 2022 · 4 comments
Closed

Provide a way to suppress incubating warnings #20328

asarkar opened this issue Mar 30, 2022 · 4 comments
Labels
closed:intellij An issue with the IntelliJ IDEA side of things

Comments

@asarkar
Copy link

asarkar commented Mar 30, 2022

APIs annotated as @Incubating show up in IntelliJ as nasty yellow warnings. It's good that you're calling out unstable APIs, but when I'm using those knowingly, I want to be able to clear these warnings.

incubating

Expected Behavior

I should be able to add a suppress annotation locally, or a compiler flag globally, to clear the warning highlights in code.

Current Behavior

No such annotation or compiler flag exists.

Context

The misleading warnings take time away from real ones. IntelliJ also shows more useful warnings that are code bugs (like NPE), but get lost among the incubating warnings.

@TWiStErRob
Copy link
Contributor

TWiStErRob commented Mar 30, 2022

These warnings are coming from you IDE, not Gradle.
All Gradle does, is use the annotations properly on non-stable (subject to change/break) code.

Have you tried using the standard suppressions?

image
->
image

Note: in some cases IDEA doesn't know that it could put the suppression on the statement or parent block, it only suggests @file:Suppress, I strongly recommend scoping your suppressions to the lowest possible scope:

class BuildTimeTrackerPlugin @Inject constructor(
	private val registry: @Suppress("UnstableApiUsage") BuildEventsListenerRegistry
) : Plugin<Project> {

@asarkar
Copy link
Author

asarkar commented Mar 31, 2022

Thank you for your response. I can confirm that @Suppress("UnstableApiUsage") does have the desired effect. Two follow up questions:

  1. Is the suppression string documented somewhere because I couldn't find it.
  2. I'd still like to be able to suppress globally by adding a compiler flag. I understand the risk that the suppression should be applied to the lowest scope.

@TWiStErRob
Copy link
Contributor

TWiStErRob commented Mar 31, 2022

It's the name of the IDEA Inspection. You cannot add a compiler flag, because it's in the IDE. You can add it by the menu item I'm showing, or once you learn it, manually. You can also press "Disable inspection" or "Edit inspection profile settings" (which shows the docs). In edit, you can tune it to your liking: e.g. you can remove the Gradle annotation from the list, or tune down the level to weak warning, typo, or other. If you want to share this with others, tied to your project, version control .idea/inspectionProfiles/Project_Default.xml.

@asarkar
Copy link
Author

asarkar commented Mar 31, 2022

Thanks.

@asarkar asarkar closed this as completed Mar 31, 2022
@ov7a ov7a added closed:intellij An issue with the IntelliJ IDEA side of things and removed a:feature A new functionality to-triage labels May 23, 2023
@ov7a ov7a closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed:intellij An issue with the IntelliJ IDEA side of things
Projects
None yet
Development

No branches or pull requests

3 participants